File tree Expand file tree Collapse file tree 1 file changed +19
-8
lines changed
simple_node/include/simple_node/actions Expand file tree Collapse file tree 1 file changed +19
-8
lines changed Original file line number Diff line number Diff line change @@ -101,21 +101,32 @@ class ActionServer : public rclcpp_action::Server<ActionT> {
101101
102102 rclcpp_action::CancelResponse
103103 handle_cancel (const std::shared_ptr<GoalHandle> goal_handle) {
104-
105104 (void )goal_handle;
106-
107- this ->server_canceled = true ;
108-
109- if (this ->cancel_callback != nullptr ) {
110- this ->cancel_callback ();
111- }
112-
113105 return rclcpp_action::CancelResponse::ACCEPT;
114106 }
115107
116108 void handle_execute (const std::shared_ptr<GoalHandle> goal_handle) {
109+
117110 this ->goal_handle = goal_handle;
118111 this ->server_canceled = false ;
112+
113+ using namespace std ::placeholders;
114+ std::thread{std::bind (&ActionServer::execute, this , _1), goal_handle}
115+ .detach ();
116+
117+ while (this ->goal_handle != nullptr ) {
118+ if (this ->goal_handle ->is_canceling ()) {
119+
120+ if (this ->cancel_callback != nullptr ) {
121+ this ->cancel_callback ();
122+ }
123+ this ->server_canceled = true ;
124+ break ;
125+ }
126+ }
127+ }
128+
129+ void execute (const std::shared_ptr<GoalHandle> goal_handle) {
119130 this ->execute_callback (goal_handle);
120131 this ->goal_handle = nullptr ;
121132 }
You can’t perform that action at this time.
0 commit comments