From 02882fcc2b0433ae45e58461aa7255b804f494d7 Mon Sep 17 00:00:00 2001 From: Shane Loretz Date: Thu, 16 Aug 2018 16:11:54 -0700 Subject: [PATCH 1/3] Use consolidated rcl_wait_set_clear() --- rclcpp/src/rclcpp/executor.cpp | 16 ++-------------- rclcpp/src/rclcpp/graph_listener.cpp | 4 ++-- 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/rclcpp/src/rclcpp/executor.cpp b/rclcpp/src/rclcpp/executor.cpp index 49d344c7fb..df7b6fa945 100644 --- a/rclcpp/src/rclcpp/executor.cpp +++ b/rclcpp/src/rclcpp/executor.cpp @@ -410,20 +410,8 @@ Executor::wait_for_work(std::chrono::nanoseconds timeout) ); } // clear wait set - if (rcl_wait_set_clear_subscriptions(&wait_set_) != RCL_RET_OK) { - throw std::runtime_error("Couldn't clear subscriptions from wait set"); - } - if (rcl_wait_set_clear_services(&wait_set_) != RCL_RET_OK) { - throw std::runtime_error("Couldn't clear servicess from wait set"); - } - if (rcl_wait_set_clear_clients(&wait_set_) != RCL_RET_OK) { - throw std::runtime_error("Couldn't clear clients from wait set"); - } - if (rcl_wait_set_clear_guard_conditions(&wait_set_) != RCL_RET_OK) { - throw std::runtime_error("Couldn't clear guard conditions from wait set"); - } - if (rcl_wait_set_clear_timers(&wait_set_) != RCL_RET_OK) { - throw std::runtime_error("Couldn't clear timers from wait set"); + if (rcl_wait_set_clear(&wait_set_) != RCL_RET_OK) { + throw std::runtime_error("Couldn't clear wait set"); } if (rcl_wait_set_resize_subscriptions( diff --git a/rclcpp/src/rclcpp/graph_listener.cpp b/rclcpp/src/rclcpp/graph_listener.cpp index 3e08e5865c..ddba125b0b 100644 --- a/rclcpp/src/rclcpp/graph_listener.cpp +++ b/rclcpp/src/rclcpp/graph_listener.cpp @@ -136,8 +136,8 @@ GraphListener::run_loop() throw_from_rcl_error(ret, "failed to resize wait set"); } } - // Clear the wait set's guard conditions. - ret = rcl_wait_set_clear_guard_conditions(&wait_set_); + // Clear the wait set. + ret = rcl_wait_set_clear(&wait_set_); if (RCL_RET_OK != ret) { throw_from_rcl_error(ret, "failed to clear wait set"); } From 59fe567e76b80b945294ed055d73f7d5ca2fe77e Mon Sep 17 00:00:00 2001 From: Shane Loretz Date: Thu, 16 Aug 2018 17:54:10 -0700 Subject: [PATCH 2/3] Use consolidated rcl_wait_set_resize() --- rclcpp/src/rclcpp/executor.cpp | 43 ++++------------------------ rclcpp/src/rclcpp/graph_listener.cpp | 2 +- 2 files changed, 7 insertions(+), 38 deletions(-) diff --git a/rclcpp/src/rclcpp/executor.cpp b/rclcpp/src/rclcpp/executor.cpp index df7b6fa945..308bd556c2 100644 --- a/rclcpp/src/rclcpp/executor.cpp +++ b/rclcpp/src/rclcpp/executor.cpp @@ -414,44 +414,13 @@ Executor::wait_for_work(std::chrono::nanoseconds timeout) throw std::runtime_error("Couldn't clear wait set"); } - if (rcl_wait_set_resize_subscriptions( - &wait_set_, memory_strategy_->number_of_ready_subscriptions()) != RCL_RET_OK) - { - throw std::runtime_error( - std::string("Couldn't resize the number of subscriptions in wait set : ") + - rcl_get_error_string_safe()); - } - - if (rcl_wait_set_resize_services( - &wait_set_, memory_strategy_->number_of_ready_services()) != RCL_RET_OK) - { - throw std::runtime_error( - std::string("Couldn't resize the number of services in wait set : ") + - rcl_get_error_string_safe()); - } - - if (rcl_wait_set_resize_clients( - &wait_set_, memory_strategy_->number_of_ready_clients()) != RCL_RET_OK) - { + rcl_ret_t ret = rcl_wait_set_resize( + &wait_set_, memory_strategy_->number_of_ready_subscriptions(), + memory_strategy_->number_of_guard_conditions(), memory_strategy_->number_of_ready_timers(), + memory_strategy_->number_of_ready_clients(), memory_strategy_->number_of_ready_services()); + if (RCL_RET_OK != ret) { throw std::runtime_error( - std::string("Couldn't resize the number of clients in wait set : ") + - rcl_get_error_string_safe()); - } - - if (rcl_wait_set_resize_guard_conditions( - &wait_set_, memory_strategy_->number_of_guard_conditions()) != RCL_RET_OK) - { - throw std::runtime_error( - std::string("Couldn't resize the number of guard_conditions in wait set : ") + - rcl_get_error_string_safe()); - } - - if (rcl_wait_set_resize_timers( - &wait_set_, memory_strategy_->number_of_ready_timers()) != RCL_RET_OK) - { - throw std::runtime_error( - std::string("Couldn't resize the number of timers in wait set : ") + - rcl_get_error_string_safe()); + std::string("Couldn't resize the wait set : ") + rcl_get_error_string_safe()); } if (!memory_strategy_->add_handles_to_wait_set(&wait_set_)) { diff --git a/rclcpp/src/rclcpp/graph_listener.cpp b/rclcpp/src/rclcpp/graph_listener.cpp index ddba125b0b..acb6858119 100644 --- a/rclcpp/src/rclcpp/graph_listener.cpp +++ b/rclcpp/src/rclcpp/graph_listener.cpp @@ -131,7 +131,7 @@ GraphListener::run_loop() // Resize the wait set if necessary. if (wait_set_.size_of_guard_conditions < (node_graph_interfaces_.size() + 2)) { - ret = rcl_wait_set_resize_guard_conditions(&wait_set_, node_graph_interfaces_.size() + 2); + ret = rcl_wait_set_resize(&wait_set_, 0u, node_graph_interfaces_.size() + 2, 0u, 0u, 0u); if (RCL_RET_OK != ret) { throw_from_rcl_error(ret, "failed to resize wait set"); } From cc85162178dd5d007c2354b375690bab4a208a03 Mon Sep 17 00:00:00 2001 From: Shane Loretz Date: Mon, 27 Aug 2018 11:52:16 -0700 Subject: [PATCH 3/3] 0 -> 0u --- rclcpp/src/rclcpp/graph_listener.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rclcpp/src/rclcpp/graph_listener.cpp b/rclcpp/src/rclcpp/graph_listener.cpp index acb6858119..7062a3af53 100644 --- a/rclcpp/src/rclcpp/graph_listener.cpp +++ b/rclcpp/src/rclcpp/graph_listener.cpp @@ -131,7 +131,7 @@ GraphListener::run_loop() // Resize the wait set if necessary. if (wait_set_.size_of_guard_conditions < (node_graph_interfaces_.size() + 2)) { - ret = rcl_wait_set_resize(&wait_set_, 0u, node_graph_interfaces_.size() + 2, 0u, 0u, 0u); + ret = rcl_wait_set_resize(&wait_set_, 0, node_graph_interfaces_.size() + 2, 0, 0, 0); if (RCL_RET_OK != ret) { throw_from_rcl_error(ret, "failed to resize wait set"); }