DIT168 Group9  0.9
Miniature remote-controlled vehicle using OpenDavinci and Libcluon
PS4Controller.hpp
1 #pragma once
2 
3 #include <iostream>
4 #include <fstream>
5 #include <unistd.h>
6 #include <iomanip>
7 #include "cluon/OD4Session.hpp"
8 #include "Messages.hpp"
9 
10 static constexpr float MIN_AXES_VALUE = -32768.0f;
11 static constexpr float MAX_AXES_VALUE = 32767.0f;
13 static constexpr float m_MAX_DECELERATION = -1.0f;
14 static constexpr float m_MAX_ACCELERATION = 0.16f;
15 //static constexpr float m_MAX_STEERING_ANGLE_RIGHT = 45.0f; /**< Max Steering Angle, must be positive.*/
16 //static constexpr float m_MAX_STEERING_ANGLE_LEFT = 28.0f; /**< Max Steering Angle, must be positive.*/
17 //static constexpr float m_OFFSET = -0.12f;
18 
19 opendlv::proxy::PedalPositionReading pedalPositionReading;
20 opendlv::proxy::GroundSteeringReading steeringReading;
21 opendlv::proxy::ButtonPressed buttonPressed;
22 
27 typedef enum {
28  Square = 0,
29  X = 1,
30  Circle = 2,
31  Triangle = 3,
32  L1 = 4,
33  R1 = 5,
34  L2 = 6,
35  R2 = 7,
36  Share = 8,
37  Options = 9,
38  LStick = 10,
39  RStick = 11,
40  PS = 12,
41 } PS4Button;
42 
47 typedef enum {
48  LStickX = 0,
49  LStickY = 1,
50  RStickX = 2,
51  L2Y = 3,
52  R2Y = 4,
53  RStickY = 5,
54  PadX = 6,
55  PadY = 7
56 } PS4Axis;
57 
66 typedef struct {
67  uint32_t timestamp;
68  int16_t data;
69  uint8_t type;
70  uint8_t id;
71 } PS4Event;
72 
79 uint16_t findButton(PS4Event* event);
80 
86 void sendButtonPressed(uint16_t button, cluon::OD4Session* od4Session);
87 
92 void roundValue(float* number);