Skip to content

Commit 5247422

Browse files
committed
add missing ros2 doxygen documentation
1 parent e9a1502 commit 5247422

File tree

2 files changed

+43
-18
lines changed

2 files changed

+43
-18
lines changed

mqtt_client/include/mqtt_client/MqttClient.ros2.hpp

Lines changed: 36 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ class MqttClient : public rclcpp::Node,
144144
void setup();
145145

146146
/**
147-
* TODO
147+
* @brief Checks all active ROS topics in order to set up generic subscribers.
148148
*/
149149
void setupSubscriptions();
150150

@@ -160,9 +160,16 @@ class MqttClient : public rclcpp::Node,
160160
void connect();
161161

162162
/**
163-
* @brief Serializes and publishes a generic ROS message to the MQTT broker.
163+
* @brief Publishes a generic serialized ROS message to the MQTT broker.
164164
*
165-
* TODO
165+
* Before publishing the ROS message to the MQTT broker, the ROS message type
166+
* is extracted. This type information is also sent to the MQTT broker on a
167+
* separate topic.
168+
*
169+
* The MQTT payload for the actual ROS message carries the following:
170+
* - 0 or 1 (indicating if timestamp is injected (=1))
171+
* - serialized timestamp (optional)
172+
* - serialized ROS message
166173
*
167174
* @param serialized_msg generic serialized ROS message
168175
* @param ros_topic ROS topic where the message was published
@@ -174,9 +181,18 @@ class MqttClient : public rclcpp::Node,
174181
/**
175182
* @brief Publishes a ROS message received via MQTT to ROS.
176183
*
177-
* TODO
184+
* This utilizes the generic publisher stored for the MQTT topic on which the
185+
* message was received. The publisher has to be configured to the ROS message
186+
* type of the message. If the message carries an injected timestamp, the
187+
* latency is computed and published.
188+
*
189+
* The MQTT payload is expected to carry the following:
190+
* - 0 or 1 (indicating if timestamp is injected (=1))
191+
* - serialized timestamp (optional)
192+
* - serialized ROS message
178193
*
179194
* @param mqtt_msg MQTT message
195+
* @param arrival_stamp arrival timestamp used for latency computation
180196
*/
181197
void mqtt2ros(mqtt::const_message_ptr mqtt_msg,
182198
const rclcpp::Time& arrival_stamp);
@@ -366,7 +382,9 @@ class MqttClient : public rclcpp::Node,
366382
*/
367383
static const std::string kLatencyRosTopicPrefix;
368384

369-
// TODO
385+
/**
386+
* @brief Timer to repeatedly check active ROS topics for topics to subscribe
387+
*/
370388
rclcpp::TimerBase::SharedPtr check_subscriptions_timer_;
371389

372390
/**
@@ -410,7 +428,9 @@ class MqttClient : public rclcpp::Node,
410428
*/
411429
std::map<std::string, Mqtt2RosInterface> mqtt2ros_;
412430

413-
// TODO
431+
/**
432+
* Message length of a serialized `builtin_interfaces::msg::Time` message
433+
*/
414434
uint32_t stamp_length_;
415435
};
416436

@@ -440,14 +460,12 @@ bool MqttClient::loadParameter(const std::string& key, T& value,
440460

441461

442462
/**
443-
* Serializes a ROS message to a buffer.
444-
*
445-
* TODO
463+
* Serializes a ROS message.
446464
*
447-
* @tparam T ROS message type
465+
* @tparam T ROS message type
448466
*
449-
* @param[in] msg ROS message
450-
* @param[out] buffer buffer to serialize to
467+
* @param[in] msg ROS message
468+
* @param[out] serialized_msg serialized message
451469
*/
452470
template <typename T>
453471
void serializeRosMessage(const T& msg,
@@ -459,7 +477,12 @@ void serializeRosMessage(const T& msg,
459477

460478

461479
/**
462-
* TODO
480+
* Deserializes a ROS message.
481+
*
482+
* @tparam T ROS message type
483+
*
484+
* @param[in] serialized_msg serialized message
485+
* @param[out] msg ROS message
463486
*/
464487
template <typename T>
465488
void deserializeRosMessage(const rclcpp::SerializedMessage& serialized_msg,

mqtt_client/src/MqttClient.ros2.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,14 @@ const std::string MqttClient::kLatencyRosTopicPrefix = "~/latencies/";
5959
/**
6060
* @brief Extracts string of primitive data types from ROS message.
6161
*
62-
* TODO
62+
* This is helpful to extract the actual data payload of a primitive ROS
63+
* message. If e.g. an std_msgs/msg/String is serialized to a string
64+
* representation, it also contains the field name 'data'. This function
65+
* instead returns the underlying value as string.
6366
*
64-
* @param [in] msg generic ShapeShifter ROS message
65-
* @param [out] primitive string representation of primitive message data
67+
* @param [in] serialized_msg generic serialized ROS message
68+
* @param [in] msg_type ROS message type, e.g. `std_msgs/msg/String`
69+
* @param [out] primitive string representation of primitive message data
6670
*
6771
* @return true if primitive ROS message type was found
6872
* @return false if ROS message type is not primitive
@@ -683,8 +687,6 @@ void MqttClient::mqtt2ros(mqtt::const_message_ptr mqtt_msg,
683687

684688
void MqttClient::mqtt2primitive(mqtt::const_message_ptr mqtt_msg) {
685689

686-
// TODO: not yet working with primitives published by mosquitto_pub
687-
688690
std::string mqtt_topic = mqtt_msg->get_topic();
689691
Mqtt2RosInterface& mqtt2ros = mqtt2ros_[mqtt_topic];
690692
const std::string str_msg = mqtt_msg->to_string();

0 commit comments

Comments
 (0)