From 997a4caf1dad4c98e5dc37d9ae9ff0145d9f8842 Mon Sep 17 00:00:00 2001 From: Carlos San Vicente Date: Tue, 20 Jul 2021 17:37:11 +0200 Subject: [PATCH] Minor fixes Signed-off-by: Carlos San Vicente --- rclcpp/topics/minimal_subscriber/README.md | 19 ++++++++++--------- rclcpp/topics/minimal_subscriber/package.xml | 2 ++ .../time_triggered_wait_set_subscriber.cpp | 2 -- .../wait_set_subscriber.cpp | 1 - rclcpp/wait_set/CMakeLists.txt | 8 ++++++++ rclcpp/wait_set/package.xml | 1 + 6 files changed, 21 insertions(+), 12 deletions(-) diff --git a/rclcpp/topics/minimal_subscriber/README.md b/rclcpp/topics/minimal_subscriber/README.md index a8f78efd..4075613f 100644 --- a/rclcpp/topics/minimal_subscriber/README.md +++ b/rclcpp/topics/minimal_subscriber/README.md @@ -4,9 +4,10 @@ This package contains a few different strategies for creating nodes which receiv * `lambda.cpp` uses a C++11 lambda function * `member_function.cpp` uses a C++ member function callback * `not_composable.cpp` uses a global function callback without a Node subclass - * `wait_set.cpp` uses a `rclcpp::WaitSet` to wait and poll for data - * `static_wait_set.cpp` uses a `rclcpp::StaticWaitSet` to wait and poll for data - * `wait_set_time_triggered.cpp` uses a `rclcpp::Waitset` and a timer to poll for data periodically + * `wait_set_subscriber.cpp` uses a `rclcpp::WaitSet` to wait and poll for data + * `static_wait_set_subscriber.cpp` uses a `rclcpp::StaticWaitSet` to wait and poll for data + * `time_triggered_wait_set_subscriber.cpp` uses a `rclcpp::Waitset` and a timer to poll for data + periodically Note that `not_composable.cpp` instantiates a `rclcpp::Node` _without_ subclassing it. This was the typical usage model in ROS 1, but this style of coding is not compatible with composing multiple nodes into a single process. @@ -16,9 +17,9 @@ All of these nodes do the same thing: they create a node called `minimal_subscri When a message arrives on that topic, the node prints it to the screen. We provide multiple examples of different coding styles which achieve this behavior in order to demonstrate that there are many ways to do this in ROS 2. -The following examples `wait_set.cpp`, `static_wait_set.cpp` and `wait_set_time_triggered.cpp` -show how to use a subscription in a node using a `rclcpp` wait-set. This is not a common use case -in ROS 2 so this is not the recommended strategy to use by-default. This strategy makes sense -in some specific situations, for example when the developer needs to have more control over -callback order execution, create custom triggering conditions or use the timeouts provided by the -wait-sets. \ No newline at end of file +The following examples `wait_set_subscriber.cpp`, `static_wait_set_subscriber.cpp` and +`time_triggered_wait_set_subscriber.cpp` show how to use a subscription in a node using a `rclcpp` +wait-set. This is not a common use case in ROS 2 so this is not the recommended strategy to +use by-default. This strategy makes sense in some specific situations, for example when the +developer needs to have more control over callback order execution, to create custom triggering +conditions or to use the timeouts provided by the wait-sets. \ No newline at end of file diff --git a/rclcpp/topics/minimal_subscriber/package.xml b/rclcpp/topics/minimal_subscriber/package.xml index 9a95ed6d..f07e7b16 100644 --- a/rclcpp/topics/minimal_subscriber/package.xml +++ b/rclcpp/topics/minimal_subscriber/package.xml @@ -14,9 +14,11 @@ ament_cmake rclcpp + rclcpp_components std_msgs rclcpp + rclcpp_components std_msgs ament_lint_auto diff --git a/rclcpp/topics/minimal_subscriber/time_triggered_wait_set_subscriber.cpp b/rclcpp/topics/minimal_subscriber/time_triggered_wait_set_subscriber.cpp index 20b69f4e..7b5d85dc 100644 --- a/rclcpp/topics/minimal_subscriber/time_triggered_wait_set_subscriber.cpp +++ b/rclcpp/topics/minimal_subscriber/time_triggered_wait_set_subscriber.cpp @@ -37,13 +37,11 @@ class TimeTriggeredWaitSetSubscriber : public rclcpp::Node auto subscription_callback = [this](std_msgs::msg::String::UniquePtr msg) { RCLCPP_INFO(this->get_logger(), "I heard: '%s'", msg->data.c_str()); }; - subscription_ = this->create_subscription( "topic", 10, subscription_callback, subscription_options); - auto timer_callback = [this]() -> void { std_msgs::msg::String msg; rclcpp::MessageInfo msg_info; diff --git a/rclcpp/topics/minimal_subscriber/wait_set_subscriber.cpp b/rclcpp/topics/minimal_subscriber/wait_set_subscriber.cpp index 3987ce07..79dddce2 100644 --- a/rclcpp/topics/minimal_subscriber/wait_set_subscriber.cpp +++ b/rclcpp/topics/minimal_subscriber/wait_set_subscriber.cpp @@ -34,7 +34,6 @@ class WaitSetSubscriber : public rclcpp::Node auto subscription_callback = [this](std_msgs::msg::String::UniquePtr msg) { RCLCPP_INFO(this->get_logger(), "I heard: '%s'", msg->data.c_str()); }; - subscription_ = this->create_subscription( "topic", 10, diff --git a/rclcpp/wait_set/CMakeLists.txt b/rclcpp/wait_set/CMakeLists.txt index 0ae62e45..eed3ff51 100644 --- a/rclcpp/wait_set/CMakeLists.txt +++ b/rclcpp/wait_set/CMakeLists.txt @@ -53,6 +53,14 @@ add_executable(wait_set_composed src/wait_set_composed.cpp) target_link_libraries(wait_set_composed talker listener) ament_target_dependencies(wait_set_composed rclcpp) +install(TARGETS + talker + listener + ARCHIVE DESTINATION lib + LIBRARY DESTINATION lib + RUNTIME DESTINATION bin +) + install(TARGETS wait_set static_wait_set diff --git a/rclcpp/wait_set/package.xml b/rclcpp/wait_set/package.xml index da971efb..74d0c554 100644 --- a/rclcpp/wait_set/package.xml +++ b/rclcpp/wait_set/package.xml @@ -18,6 +18,7 @@ example_interfaces rclcpp + rclcpp_components std_msgs