Skip to content

Commit

Permalink
Rename minimal_subscriber waitset example
Browse files Browse the repository at this point in the history
Signed-off-by: Carlos San Vicente <carlos.sanvicente@apex.ai>
  • Loading branch information
carlossvg committed Jun 25, 2021
1 parent ed0f604 commit f66bb18
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions rclcpp/minimal_subscriber/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ ament_target_dependencies(subscriber_member_function rclcpp std_msgs)
add_executable(subscriber_not_composable not_composable.cpp)
ament_target_dependencies(subscriber_not_composable rclcpp std_msgs)

add_executable(waitset waitset.cpp)
ament_target_dependencies(waitset rclcpp std_msgs)
add_executable(subscriber_waitset subscriber_waitset.cpp)
ament_target_dependencies(subscriber_waitset rclcpp std_msgs)

install(TARGETS
subscriber_lambda
subscriber_member_function
subscriber_not_composable
waitset
subscriber_waitset
DESTINATION lib/${PROJECT_NAME})

ament_package()
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class MinimalSubscriber : public rclcpp::Node
rclcpp::WaitSet wait_set;
wait_set.add_subscription(subscription_);
while (rclcpp::ok()) {
const auto wait_result = wait_set.wait();
const auto wait_result = wait_set.wait(std::chrono::seconds(1));
if (wait_result.kind() == rclcpp::WaitResultKind::Ready) {
if (wait_result.get_wait_set().get_rcl_wait_set().subscriptions[0U]) {
std_msgs::msg::String msg;
Expand All @@ -65,12 +65,13 @@ int main(int argc, char * argv[])
rclcpp::init(argc, argv);
auto node = std::make_shared<MinimalSubscriber>();


// Option 1: loop in main
auto sub = node->get_subscription();
rclcpp::WaitSet wait_set;
wait_set.add_subscription(sub);
while (rclcpp::ok()) {
const auto wait_result = wait_set.wait();
const auto wait_result = wait_set.wait(std::chrono::seconds(1));
if (wait_result.kind() == rclcpp::WaitResultKind::Ready) {
if (wait_result.get_wait_set().get_rcl_wait_set().subscriptions[0U]) {
std_msgs::msg::String msg;
Expand All @@ -86,7 +87,6 @@ int main(int argc, char * argv[])
// Option 2: run node
// node->run();

// rclcpp::spin();
rclcpp::shutdown();
return 0;
}

0 comments on commit f66bb18

Please sign in to comment.