Rover API Documentation
rover_mqttcommand.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017 FH Dortmund and others
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Description:
9  * Rover MQTTCommand API - Class for MQTT communication related to rover tasks such as sensor publishing and control data retrieval.
10  * Header file
11  *
12  * Contributors:
13  * M.Ozcelikors <mozcelikors@gmail.com>, created RoverMQTTCommand C++API 10.12.2017
14  *
15  */
16 
17 #ifndef ROVERAPI_ROVER_MQTTCOMMAND_HPP_
18 #define ROVERAPI_ROVER_MQTTCOMMAND_HPP_
19 
21 
22 /* Defines regarding topic naming */
23 // Topic naming for control such as the following:
24 // rover/<roverID 1-99>/RoverDriving/control
25 // e.g rover/1/RoverDriving/Control
26 // Topic naming for sensor data and core data is : telemetry
27 #define topicPrefix "rover/"
28 #define drivingSubTopic "/RoverDriving/control"
29 #define telemetrySubTopic "/telemetry"
30 #define telemetryTopic "telemetry"
31 
32 /* Buffer size for received message for MQTT */
33 #define MQTT_BUFSIZE 256
34 
35 namespace rover
36 {
40  typedef struct
41  {
42  float infrared[4];
46  int8_t gy521_gyro_x;
47  int8_t gy521_gyro_y;
48  int8_t gy521_gyro_z;
52  int8_t gy521_accel_x;
53  int8_t gy521_accel_y;
54  int8_t gy521_accel_z;
55  float core[4];
57 
62 
66  typedef struct
67  {
69  int speed;
70  char command;
73 
80  {
81  private:
85  int ROVER_ID;
86 
87  public:
91  RoverMQTTCommand (char * host, const int port, const int roverID, const int qos, char * username, char * password, char * clientID);
92 
96  RoverMQTTCommand (char * host, const int port, const int roverID, const int qos, char * clientID);
97 
102 
119  int publishToTelemetryTopic (RoverSensorData_t sensor_data);
120 
138 
150  int subscribeToDrivingTopic (void);
151 
163  int unsubscribeToDrivingTopic (void);
164 
176  int connectRover (void);
177 
182  int getRoverConnected(void);
183 
189 
194  char * getTopicName (void);
195 
200  int getRoverID (void);
201 
206  void setRoverID (const int rover_id);
207 
208  };
209 }
210 
211 #endif /* ROVERAPI_ROVER_MQTTCOMMAND_HPP_ */
int data_ready
Definition: rover_mqttcommand.hpp:71
RoverDrivingMode_t
Data type to indicate rover&#39;s driving mode.
Definition: rover_mqttcommand.hpp:61
float ultrasonic_rear
Definition: rover_mqttcommand.hpp:44
Definition: rover_mqttcommand.hpp:61
int getRoverID(void)
Retrieves Rover ID.
Definition: rover_mqttcommand.cpp:302
int unsubscribeToDrivingTopic(void)
Unsubscribes to rover&#39;s driving topic.
Definition: rover_mqttcommand.cpp:220
int8_t gy521_accel_z
Definition: rover_mqttcommand.hpp:54
int connectRover(void)
connectRover connects to the MQTT broker. Each rover ideally should have only one client...
Definition: rover_mqttcommand.cpp:95
Definition: rover_mqttcommand.hpp:61
Definition: rover_mqttcommand.hpp:61
float gy521_angle_x
Definition: rover_mqttcommand.hpp:49
int8_t gy521_gyro_z
Definition: rover_mqttcommand.hpp:48
RoverPahoMQTT contains member functions to use rover as a client and to publish / subscribe to Eclips...
Definition: rover_pahomqtt.hpp:83
Definition: rover_mqttcommand.hpp:61
Definition: rover_mqttcommand.hpp:61
char command
Definition: rover_mqttcommand.hpp:70
void setRoverID(const int rover_id)
Sets Rover ID.
Definition: rover_mqttcommand.cpp:307
int ROVER_ID
Given rover identification for multi-agent MQTT communication with a single cloud.
Definition: rover_mqttcommand.hpp:85
float gy521_angle_y
Definition: rover_mqttcommand.hpp:50
int8_t gy521_gyro_y
Definition: rover_mqttcommand.hpp:47
Definition: rover_mqttcommand.hpp:61
rover Namespace contains classes to manage Rover sensors, gpio, buzzer, buttons, driving, utilities, and cloud.
Definition: rover_api.hpp:293
float gy521_angle_z
Definition: rover_mqttcommand.hpp:51
int8_t gy521_accel_y
Definition: rover_mqttcommand.hpp:53
int8_t gy521_accel_x
Definition: rover_mqttcommand.hpp:52
int subscribeToDrivingTopic(void)
Subscribes to rover&#39;s driving topic.
Definition: rover_mqttcommand.cpp:211
int speed
Definition: rover_mqttcommand.hpp:69
int getRoverConnected(void)
Returns rover connected flag.
Definition: rover_mqttcommand.cpp:100
Data type to store rover&#39;s sensor data.
Definition: rover_mqttcommand.hpp:40
Definition: rover_mqttcommand.hpp:61
float ultrasonic_front
Definition: rover_mqttcommand.hpp:43
Data type to store rover&#39;s control data.
Definition: rover_mqttcommand.hpp:66
RoverMQTTCommand(char *host, const int port, const int roverID, const int qos, char *username, char *password, char *clientID)
Copy constructor for RoverMQTTCommand class that uses username and password.
Definition: rover_mqttcommand.cpp:34
int8_t gy521_gyro_x
Definition: rover_mqttcommand.hpp:46
float hmc5883l_bearing
Definition: rover_mqttcommand.hpp:45
int publishToTelemetryTopicNonRedirected(RoverSensorData_t sensor_data)
Publishes a message to rover&#39;s telemetry topic (using unredirected topic method)
Definition: rover_mqttcommand.cpp:153
RoverMQTTCommand class is an implementation class extending RoverPahoMQTT for rover-specific topic su...
Definition: rover_mqttcommand.hpp:79
int publishToTelemetryTopic(RoverSensorData_t sensor_data)
Publishes a message to rover&#39;s telemetry topic (using redirected topic method)
Definition: rover_mqttcommand.cpp:105
RoverDrivingMode_t driving_mode
Definition: rover_mqttcommand.hpp:68
RoverControlData_t readFromDrivingTopic(void)
Returns the retrieved driving information.
Definition: rover_mqttcommand.cpp:226
~RoverMQTTCommand()
Destructor for RoverMQTTCommand class.
Definition: rover_mqttcommand.cpp:93
char * getTopicName(void)
Retrieves topic name.
Definition: rover_mqttcommand.cpp:297