diff --git a/dsr_agents/CHANGELOG.rst b/dsr_agents/CHANGELOG.rst
index c09d033..d4c4032 100644
--- a/dsr_agents/CHANGELOG.rst
+++ b/dsr_agents/CHANGELOG.rst
@@ -29,6 +29,7 @@ X.X.X (XX-XX-2024)
* Added unit tests.
* Added on_cleanup function to delete nodes.
* Navigation and docking agents now inherit from action_node.
+* Added std_msgs::String to the topic_agent.
0.7.0 (19-06-2024)
------------------
diff --git a/dsr_agents/CMakeLists.txt b/dsr_agents/CMakeLists.txt
index b8240c9..185c2be 100644
--- a/dsr_agents/CMakeLists.txt
+++ b/dsr_agents/CMakeLists.txt
@@ -58,6 +58,7 @@ find_package(rclcpp_action REQUIRED)
find_package(rclcpp_components REQUIRED)
find_package(rclcpp_lifecycle REQUIRED)
find_package(sensor_msgs REQUIRED)
+find_package(std_msgs REQUIRED)
find_package(tf2_ros REQUIRED)
find_package(tf2_msgs REQUIRED)
find_package(tf2_sensor_msgs REQUIRED)
@@ -167,6 +168,7 @@ target_link_libraries(topic_agent
rclcpp_components::component
rclcpp_lifecycle::rclcpp_lifecycle
${sensor_msgs_TARGETS}
+ ${std_msgs_TARGETS}
)
# Add topic agent executable
@@ -233,6 +235,7 @@ ament_export_dependencies(
rclcpp_components
rclcpp_lifecycle
sensor_msgs
+ std_msgs
tf2_ros
tf2_msgs
tf2_sensor_msgs
diff --git a/dsr_agents/package.xml b/dsr_agents/package.xml
index 0703784..4da8517 100644
--- a/dsr_agents/package.xml
+++ b/dsr_agents/package.xml
@@ -21,6 +21,7 @@
rclcpp_components
rclcpp_lifecycle
sensor_msgs
+ std_msgs
tf2_ros
tf2_msgs
tf2_sensor_msgs
diff --git a/dsr_agents/src/topic_agent.cpp b/dsr_agents/src/topic_agent.cpp
index f086068..7c182d2 100644
--- a/dsr_agents/src/topic_agent.cpp
+++ b/dsr_agents/src/topic_agent.cpp
@@ -23,6 +23,7 @@
#include "sensor_msgs/msg/image.hpp"
#include "sensor_msgs/image_encodings.hpp"
#include "sensor_msgs/msg/laser_scan.hpp"
+#include "std_msgs/msg/string.hpp"
#include "rclcpp_lifecycle/lifecycle_node.hpp"
// DSR
@@ -251,6 +252,18 @@ void TopicAgent::modify_attributes(
this->get_logger(), "Update [%s] node with attributes: ", node.value().name().c_str());
}
}
+
+template<>
+void TopicAgent::modify_attributes(
+ std::optional & node, const std_msgs::msg::String & msg)
+{
+ // Modify the attributes of the node
+ G_->add_or_modify_attrib_local(node.value(), msg.data);
+ // Print the attributes of the node
+ RCLCPP_DEBUG(
+ this->get_logger(), "Update [%s] node with attributes: ", node.value().name().c_str());
+}
+
} // namespace dsr_agents
#include "rclcpp_components/register_node_macro.hpp"