Skip to content

Commit a3da7c8

Browse files
authored
Merge pull request #3 from ika-rwth-aachen/doc/code-api
Improve Code API Documentation
2 parents c673e3b + 18fed80 commit a3da7c8

File tree

3 files changed

+62
-36
lines changed

3 files changed

+62
-36
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,3 +333,5 @@ CATKIN_IGNORE
333333
.history
334334

335335
# End of https://www.gitignore.io/api/ros,c++,linux,macos,python,pycharm,visualstudiocode
336+
337+
!doc/mainpage.dox

doc/mainpage.dox

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**
2+
3+
\mainpage
4+
5+
\htmlinclude manifest.html
6+
7+
\b mqtt_client provides a ROS nodelet that enables connected ROS-based devices or robots to exchange ROS messages via an MQTT broker using the MQTT protocol. This works generically for arbitrary ROS message types.
8+
9+
Please note that this is the Code API Documentation. Check out the <a href=https://github.com/ika-rwth-aachen/mqtt_client>GitHub repository</a> for more information on how to use the package, including a <i>Quick Start</i> guide.
10+
11+
<ul>
12+
<li><a href=files.html>Files</a></li>
13+
<li><a href=annotated.html>Classes</a></li>
14+
<li><a href=index-msg.html>Msg/Srv Documentation</a></li>
15+
</ul>
16+
17+
*/

include/mqtt_client/MqttClient.h

Lines changed: 43 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,13 @@ SOFTWARE.
4040

4141

4242
/**
43-
* Namespace for the mqtt_client package
43+
* @brief Namespace for the mqtt_client package
4444
*/
4545
namespace mqtt_client {
4646

4747

4848
/**
49-
* ROS Nodelet for sending and receiving ROS messages via MQTT
49+
* @brief ROS Nodelet for sending and receiving ROS messages via MQTT
5050
*
5151
* The MqttClient enables connected ROS-based devices or robots to
5252
* exchange ROS messages via an MQTT broker using the MQTT protocol.
@@ -60,19 +60,19 @@ class MqttClient : public nodelet::Nodelet,
6060

6161
protected:
6262
/**
63-
* Initializes nodelet when nodelet is loaded.
63+
* @brief Initializes nodelet when nodelet is loaded.
6464
*
6565
* Overrides nodelet::Nodelet::onInit().
6666
*/
6767
virtual void onInit() override;
6868

6969
/**
70-
* Loads ROS parameters from parameter server.
70+
* @brief Loads ROS parameters from parameter server.
7171
*/
7272
void loadParameters();
7373

7474
/**
75-
* Loads requested ROS parameter from parameter server.
75+
* @brief Loads requested ROS parameter from parameter server.
7676
*
7777
* @param[in] key parameter name
7878
* @param[out] value variable where to store the retrieved parameter
@@ -83,7 +83,8 @@ class MqttClient : public nodelet::Nodelet,
8383
bool loadParameter(const std::string& key, std::string& value);
8484

8585
/**
86-
* Loads requested ROS parameter from parameter server, allows default value.
86+
* @brief Loads requested ROS parameter from parameter server, allows default
87+
* value.
8788
*
8889
* @param[in] key parameter name
8990
* @param[out] value variable where to store the retrieved parameter
@@ -96,7 +97,7 @@ class MqttClient : public nodelet::Nodelet,
9697
const std::string& default_value);
9798

9899
/**
99-
* Loads requested ROS parameter from parameter server.
100+
* @brief Loads requested ROS parameter from parameter server.
100101
*
101102
* @tparam T type (one of int, double, bool)
102103
*
@@ -110,7 +111,8 @@ class MqttClient : public nodelet::Nodelet,
110111
bool loadParameter(const std::string& key, T& value);
111112

112113
/**
113-
* Loads requested ROS parameter from parameter server, allows default value.
114+
* @brief Loads requested ROS parameter from parameter server, allows default
115+
* value.
114116
*
115117
* @tparam T type (one of int, double, bool)
116118
*
@@ -125,7 +127,8 @@ class MqttClient : public nodelet::Nodelet,
125127
bool loadParameter(const std::string& key, T& value, const T& default_value);
126128

127129
/**
128-
* Converts a string to a path object resolving paths relative to ROS_HOME.
130+
* @brief Converts a string to a path object resolving paths relative to
131+
* ROS_HOME.
129132
*
130133
* Resolves relative to CWD, if ROS_HOME is not set.
131134
* Returns empty path, if argument is empty.
@@ -137,22 +140,23 @@ class MqttClient : public nodelet::Nodelet,
137140
std::filesystem::path resolvePath(const std::string& path_string);
138141

139142
/**
140-
* Initializes broker connection and subscriptions.
143+
* @brief Initializes broker connection and subscriptions.
141144
*/
142145
void setup();
143146

144147
/**
145-
* Sets up the client connection options and initializes the client object.
148+
* @brief Sets up the client connection options and initializes the client
149+
* object.
146150
*/
147151
void setupClient();
148152

149153
/**
150-
* Connects to the broker using the member client and options.
154+
* @brief Connects to the broker using the member client and options.
151155
*/
152156
void connect();
153157

154158
/**
155-
* Serializes and publishes a generic ROS message to the MQTT broker.
159+
* @brief Serializes and publishes a generic ROS message to the MQTT broker.
156160
*
157161
* Before serializing the ROS message and publishing it to the MQTT broker,
158162
* metadata on the ROS message type is extracted. This type information is
@@ -170,7 +174,7 @@ class MqttClient : public nodelet::Nodelet,
170174
const std::string& ros_topic);
171175

172176
/**
173-
* Publishes a ROS message received via MQTT to ROS.
177+
* @brief Publishes a ROS message received via MQTT to ROS.
174178
*
175179
* This utilizes the ShapeShifter stored for the MQTT topic on which the
176180
* message was received. The ShapeShifter has to be configured to the ROS
@@ -189,7 +193,8 @@ class MqttClient : public nodelet::Nodelet,
189193
void mqtt2ros(mqtt::const_message_ptr mqtt_msg);
190194

191195
/**
192-
* Callback for when the client has successfully connected to the broker.
196+
* @brief Callback for when the client has successfully connected to the
197+
* broker.
193198
*
194199
* Overrides mqtt::callback::connected(const std::string&).
195200
*
@@ -198,7 +203,7 @@ class MqttClient : public nodelet::Nodelet,
198203
void connected(const std::string& cause) override;
199204

200205
/**
201-
* Callback for when the client has lost connection to the broker.
206+
* @brief Callback for when the client has lost connection to the broker.
202207
*
203208
* Overrides mqtt::callback::connection_lost(const std::string&).
204209
*
@@ -227,7 +232,8 @@ class MqttClient : public nodelet::Nodelet,
227232
IsConnected::Response& response);
228233

229234
/**
230-
* Callback for when the client receives a MQTT message from the broker.
235+
* @brief Callback for when the client receives a MQTT message from the
236+
* broker.
231237
*
232238
* Overrides mqtt::callback::message_arrived(mqtt::const_message_ptr).
233239
* If the received MQTT message contains information about a ROS message type,
@@ -239,7 +245,7 @@ class MqttClient : public nodelet::Nodelet,
239245
void message_arrived(mqtt::const_message_ptr mqtt_msg) override;
240246

241247
/**
242-
* Callback for when delivery for a MQTT message has been completed.
248+
* @brief Callback for when delivery for a MQTT message has been completed.
243249
*
244250
* Overrides mqtt::callback::delivery_complete(mqtt::delivery_token_ptr).
245251
*
@@ -248,7 +254,7 @@ class MqttClient : public nodelet::Nodelet,
248254
void delivery_complete(mqtt::delivery_token_ptr token) override;
249255

250256
/**
251-
* Callback for when a MQTT action succeeds.
257+
* @brief Callback for when a MQTT action succeeds.
252258
*
253259
* Overrides mqtt::iaction_listener::on_success(const mqtt::token&).
254260
* Does nothing.
@@ -258,7 +264,7 @@ class MqttClient : public nodelet::Nodelet,
258264
void on_success(const mqtt::token& token) override;
259265

260266
/**
261-
* Callback for when a MQTT action fails.
267+
* @brief Callback for when a MQTT action fails.
262268
*
263269
* Overrides mqtt::iaction_listener::on_failure(const mqtt::token&).
264270
* Logs error.
@@ -269,7 +275,7 @@ class MqttClient : public nodelet::Nodelet,
269275

270276
protected:
271277
/**
272-
* Struct containing broker parameters
278+
* @brief Struct containing broker parameters
273279
*/
274280
struct BrokerConfig {
275281
std::string host; ///< broker host
@@ -284,7 +290,7 @@ class MqttClient : public nodelet::Nodelet,
284290
};
285291

286292
/**
287-
* Struct containing client parameters
293+
* @brief Struct containing client parameters
288294
*/
289295
struct ClientConfig {
290296
std::string id; ///< client unique ID
@@ -310,7 +316,7 @@ class MqttClient : public nodelet::Nodelet,
310316
};
311317

312318
/**
313-
* Struct containing variables related to a ROS2MQTT connection.
319+
* @brief Struct containing variables related to a ROS2MQTT connection.
314320
*/
315321
struct Ros2MqttInterface {
316322
struct {
@@ -326,7 +332,7 @@ class MqttClient : public nodelet::Nodelet,
326332
};
327333

328334
/**
329-
* Struct containing variables related to a MQTT2ROS connection.
335+
* @brief Struct containing variables related to a MQTT2ROS connection.
330336
*/
331337
struct Mqtt2RosInterface {
332338
struct {
@@ -344,66 +350,67 @@ class MqttClient : public nodelet::Nodelet,
344350

345351
protected:
346352
/**
347-
* MQTT topic prefix under which ROS message type information is published
353+
* @brief MQTT topic prefix under which ROS message type information is
354+
* published
348355
*
349356
* Must contain trailing '/'.
350357
*/
351358
static const std::string kRosMsgTypeMqttTopicPrefix;
352359

353360
/**
354-
* ROS topic prefix under which ROS2MQTT2ROS latencies are published
361+
* @brief ROS topic prefix under which ROS2MQTT2ROS latencies are published
355362
*
356363
* Must contain trailing '/'.
357364
*/
358365
static const std::string kLatencyRosTopicPrefix;
359366

360367
/**
361-
* ROS node handle
368+
* @brief ROS node handle
362369
*/
363370
ros::NodeHandle node_handle_;
364371

365372
/**
366-
* Private ROS node handle
373+
* @brief Private ROS node handle
367374
*/
368375
ros::NodeHandle private_node_handle_;
369376

370377
/**
371-
* ROS Service server for providing connection status
378+
* @brief ROS Service server for providing connection status
372379
*/
373380
ros::ServiceServer is_connected_service_;
374381

375382
/**
376-
* Status variable keeping track of connection status to broker
383+
* @brief Status variable keeping track of connection status to broker
377384
*/
378385
bool is_connected_ = false;
379386

380387
/**
381-
* Broker parameters
388+
* @brief Broker parameters
382389
*/
383390
BrokerConfig broker_config_;
384391

385392
/**
386-
* Client parameters
393+
* @brief Client parameters
387394
*/
388395
ClientConfig client_config_;
389396

390397
/**
391-
* MQTT client variable
398+
* @brief MQTT client variable
392399
*/
393400
std::shared_ptr<mqtt::async_client> client_;
394401

395402
/**
396-
* MQTT client connection options
403+
* @brief MQTT client connection options
397404
*/
398405
mqtt::connect_options connect_options_;
399406

400407
/**
401-
* ROS2MQTT connection variables sorted by ROS topic
408+
* @brief ROS2MQTT connection variables sorted by ROS topic
402409
*/
403410
std::map<std::string, Ros2MqttInterface> ros2mqtt_;
404411

405412
/**
406-
* MQTT2ROS connection variables sorted by MQTT topic
413+
* @brief MQTT2ROS connection variables sorted by MQTT topic
407414
*/
408415
std::map<std::string, Mqtt2RosInterface> mqtt2ros_;
409416
};

0 commit comments

Comments
 (0)