Skip to content

Commit

Permalink
Added std_msgs::String to the topic_agent
Browse files Browse the repository at this point in the history
Signed-off-by: Alberto Tudela <[email protected]>
  • Loading branch information
ajtudela committed Oct 29, 2024
1 parent 742e8f9 commit 7921ca2
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions dsr_agents/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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)
------------------
Expand Down
3 changes: 3 additions & 0 deletions dsr_agents/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -233,6 +235,7 @@ ament_export_dependencies(
rclcpp_components
rclcpp_lifecycle
sensor_msgs
std_msgs
tf2_ros
tf2_msgs
tf2_sensor_msgs
Expand Down
1 change: 1 addition & 0 deletions dsr_agents/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<depend>rclcpp_components</depend>
<depend>rclcpp_lifecycle</depend>
<depend>sensor_msgs</depend>
<depend>std_msgs</depend>
<depend>tf2_ros</depend>
<depend>tf2_msgs</depend>
<depend>tf2_sensor_msgs</depend>
Expand Down
13 changes: 13 additions & 0 deletions dsr_agents/src/topic_agent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -251,6 +252,18 @@ void TopicAgent::modify_attributes<sensor_msgs::msg::LaserScan>(
this->get_logger(), "Update [%s] node with attributes: ", node.value().name().c_str());
}
}

template<>
void TopicAgent::modify_attributes<std_msgs::msg::String>(
std::optional<DSR::Node> & node, const std_msgs::msg::String & msg)
{
// Modify the attributes of the node
G_->add_or_modify_attrib_local<text_att>(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"
Expand Down

0 comments on commit 7921ca2

Please sign in to comment.