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 #define L_JOY_LIMIT_X 1830
18 #define H_JOY_LIMIT_X 2050
19 #define L_JOY_LIMIT_Y 1940
20 #define H_JOY_LIMIT_Y 2160
21 
22 #define CRC_INIT 0xffff
23 #define CRC_POLYNOMIAL 0x1021
24 
28 class Parser : public QObject
29 {
30  Q_OBJECT
31 
32  public:
36  explicit Parser() = default;
37 
41  ~Parser() = default;
42 
48  bool parseFrame(const std::string& frame);
49 
53  void processData();
54 
55  signals:
60  void changedLeftMotorGSpeed(const QString& speedValue);
61 
66  void changedRightMotorGSpeed(const QString& speedValue);
67 
72  void changedLeftMotorSpeed(const QString& speedValue);
73 
78  void changedRightMotorSpeed(const QString& speedValue);
79 
84  void changedLeftMotorAcceleration(const QString& accelerationValue);
85 
90  void changedRightMotorAcceleration(const QString& accelerationValue);
91 
96  void changedJoystick(const QPoint& coordinates);
97 
102  void changedBattery(int battery);
103 
108  void changedLidar(const std::map<float, int> lidarData);
109 
114  void leftMotorDirection(const int& direction);
115 
120  void rightMotorDirection(const int& direction);
121 
126 
131 
132  private:
139  float calculateSpeedRight(const int& xAxis, const int& yAxis);
140 
147  float calculateSpeedLeft(const int& xAxis, const int& yAxis);
148 
153  int _xAxis;
154  int _yAxis;
155  int _battery;
156  std::map<float, int> _lidarData;
157  int _CRC16;
158 };
159 
160 #endif /* PARSER_HH */
Parsing class for a processing data from the serial port frame.
Definition: parser.hh:29
int _xAxis
The joystick swing on the x axis.
Definition: parser.hh:153
float calculateSpeedLeft(const int &xAxis, const int &yAxis)
Calculate speed value on the left motor from the joystick swing.
Definition: parser.cpp:190
float calculateSpeedRight(const int &xAxis, const int &yAxis)
Calculate speed value on the right motor from the joystick swing.
Definition: parser.cpp:136
void changedRightMotorAcceleration(const QString &accelerationValue)
A signal emitted when parsed data of the right motor acceleration is ready.
void setObstacleCloseStatus()
Set the Obstacle Close Status.
void changedLidar(const std::map< float, int > lidarData)
A signal emitted when parsed data of the lidar is ready.
void leftMotorDirection(const int &direction)
A signal emitted to pass wheel rotating direction to the openGL widget.
int _leftAcceleration
The left motor acceleration.
Definition: parser.hh:151
Parser()=default
Construct a new Parser object.
void changedLeftMotorGSpeed(const QString &speedValue)
A signal emitted when parsed data of the left motor given speed is ready.
void changedBattery(int battery)
A signal emitted when parsed data of the battery voltage is ready.
void processData()
Process data from a one frame.
Definition: parser.cpp:72
bool parseFrame(const std::string &frame)
Parse line from the serial port into managed variables.
Definition: parser.cpp:21
void changedRightMotorSpeed(const QString &speedValue)
A signal emitted when parsed data of the right motor speed is ready.
int _CRC16
Sent CRC from the device.
Definition: parser.hh:157
void changedLeftMotorSpeed(const QString &speedValue)
A signal emitted when parsed data of the left motor speed is ready.
int _battery
The battery voltage.
Definition: parser.hh:155
void changedJoystick(const QPoint &coordinates)
A signal emitted when parsed data of a joystick swing is ready.
int _leftSpeed
The left motor speed.
Definition: parser.hh:149
int _rightSpeed
The right motor speed.
Definition: parser.hh:150
void changedRightMotorGSpeed(const QString &speedValue)
A signal emitted when parsed data of the right motor given speed is ready.
~Parser()=default
Destroy the Parser object.
void resetObstacleCloseStatus()
Reset the Obstacle Close Status.
int _rightAcceleration
The right motor acceleration.
Definition: parser.hh:152
void rightMotorDirection(const int &direction)
A signal emitted to pass wheel rotating direction to the openGL widget.
void changedLeftMotorAcceleration(const QString &accelerationValue)
A signal emitted when parsed data of the left motor acceleration is ready.
int _yAxis
The joystick swing on the y axis.
Definition: parser.hh:154
std::map< float, int > _lidarData
Data from a laser sensor.
Definition: parser.hh:156