Roomba App  1.0
parser.hh
Go to the documentation of this file.
1 
12 #ifndef PARSER_HH
13 #define PARSER_HH
14 
15 #include <QObject>
16 
17 typedef unsigned char byte;
18 typedef unsigned short int word;
19 
20 #define L_JOY_LIMIT_X 1830 // JOYSTICK DEFAULT LOWER LIMIT IN AXIS X (DATA READ FROM ANALOG INPUT)
21 #define H_JOY_LIMIT_X 2050 // JOYSTICK DEFAULT HIGH LIMIT IN AXIS X (DATA READ FROM ANALOG INPUT)
22 #define L_JOY_LIMIT_Y 1940 // JOYSTICK DEFAULT LOWER LIMIT IN AXIS Y (DATA READ FROM ANALOG INPUT)
23 #define H_JOY_LIMIT_Y 2160 // JOYSTICK DEFAULT HIGH LIMIT IN AXIS Y (DATA READ FROM ANALOG INPUT)
24 
25 #define CRC_INIT 0xffff
26 #define CRC_POLYNOMIAL 0x1021
27 
31 class Parser : public QObject
32 {
33  Q_OBJECT
34 
35  public:
39  explicit Parser();
40 
44  ~Parser();
45 
51  bool parseFrame(const std::string& frame);
52 
56  void processData();
57 
58  signals:
63  void changedLeftMotorGSpeed(const QString& speedValue);
64 
69  void changedRightMotorGSpeed(const QString& speedValue);
70 
75  void changedLeftMotorSpeed(const QString& speedValue);
76 
81  void changedRightMotorSpeed(const QString& speedValue);
82 
87  void changedLeftMotorAcceleration(const QString& accelerationValue);
88 
93  void changedRightMotorAcceleration(const QString& accelerationValue);
94 
99  void changedJoystick(const QPoint& coordinates);
100 
105  void changedBattery(int battery);
106 
111  void changedLidar(const std::map<float, int> lidarData);
112 
113  private:
120  float calculateSpeedRight(const int& xAxis, const int& yAxis);
121 
128  float calculateSpeedLeft(const int& xAxis, const int& yAxis);
129 
135  float calculateAcceleration(const int& acceleration);
136 
139 
142 
143  int _xAxis;
144  int _yAxis;
145 
146  int _battery;
147 
148  std::map<float, int> _lidarData;
149 
150  int _CRC16;
151 };
152 
153 #endif // PARSER_HH
The Parser class.
Definition: parser.hh:32
int _xAxis
Definition: parser.hh:143
float calculateSpeedLeft(const int &xAxis, const int &yAxis)
Calculate speed value on left motor from joystick swing.
Definition: parser.cpp:168
float calculateSpeedRight(const int &xAxis, const int &yAxis)
Calculate speed value on right motor from joystick swing.
Definition: parser.cpp:105
float calculateAcceleration(const int &acceleration)
calculateAcceleration
Definition: parser.cpp:231
Parser()
Construct new Parser object.
Definition: parser.cpp:21
void changedRightMotorAcceleration(const QString &accelerationValue)
Signal emitted when parsed data of right motor acceleration is ready.
void changedLidar(const std::map< float, int > lidarData)
Signal emitted when parsed data of lidar is ready.
~Parser()
Destruct Parser object.
Definition: parser.cpp:23
int _leftAcceleration
Definition: parser.hh:140
void changedLeftMotorGSpeed(const QString &speedValue)
Signal emitted when parsed data of left motor given speed is ready.
void changedBattery(int battery)
Signal emitted when parsed data of battery voltage is ready.
void processData()
processData
Definition: parser.cpp:76
bool parseFrame(const std::string &frame)
Parse line from serial port into managed variables.
Definition: parser.cpp:25
void changedRightMotorSpeed(const QString &speedValue)
Signal emitted when parsed data of right motor speed is ready.
int _CRC16
Definition: parser.hh:150
void changedLeftMotorSpeed(const QString &speedValue)
Signal emitted when parsed data of left motor speed is ready.
int _battery
Definition: parser.hh:146
void changedJoystick(const QPoint &coordinates)
Signal emitted when parsed data of joystick swing is ready.
int _leftSpeed
Definition: parser.hh:137
int _rightSpeed
Definition: parser.hh:138
void changedRightMotorGSpeed(const QString &speedValue)
Signal emitted when parsed data of right motor given speed is ready.
int _rightAcceleration
Definition: parser.hh:141
void changedLeftMotorAcceleration(const QString &accelerationValue)
Signal emitted when parsed data of left motor acceleration is ready.
int _yAxis
Definition: parser.hh:144
std::map< float, int > _lidarData
Definition: parser.hh:148
unsigned char byte
Definition: parser.hh:17
unsigned short int word
Definition: parser.hh:18