@@ -195,7 +195,7 @@ class ClientBase : public rclcpp::Waitable
195195 rclcpp::Waitable::SharedPtr
196196 get_intra_process_waitable ();
197197
198- protected:
198+ protected:
199199 RCLCPP_ACTION_PUBLIC
200200 ClientBase (
201201 rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_base,
@@ -316,7 +316,7 @@ class ClientBase : public rclcpp::Waitable
316316 setup_intra_process (
317317 uint64_t ipc_action_client_id,
318318 IntraProcessManagerWeakPtr weak_ipm);
319-
319+
320320 // End API for communication between ClientBase and Client<>
321321 // ---------------------------------------------------------
322322
@@ -508,36 +508,36 @@ class Client : public ClientBase
508508 }
509509 };
510510
511- bool intra_process_send_done = false ;
512-
513- std::lock_guard<std::recursive_mutex> lock (ipc_mutex_);
514-
515- if (use_intra_process_) {
516- auto ipm = weak_ipm_.lock ();
517- if (!ipm) {
518- throw std::runtime_error (
511+ bool intra_process_send_done = false ;
512+
513+ std::lock_guard<std::recursive_mutex> lock (ipc_mutex_);
514+
515+ if (use_intra_process_) {
516+ auto ipm = weak_ipm_.lock ();
517+ if (!ipm) {
518+ throw std::runtime_error (
519519 " intra process send goal called after destruction of intra process manager" );
520- }
521- bool intra_process_server_available = ipm->action_server_is_available (ipc_action_client_id_);
522-
520+ }
521+ bool intra_process_server_available = ipm->action_server_is_available (ipc_action_client_id_);
522+
523523 // Check if there's an intra-process action server available matching this client.
524524 // If there's not, we fall back into inter-process communication, since
525525 // the server might be available in another process or was configured to not use IPC.
526- if (intra_process_server_available) {
527- ipm->intra_process_action_send_goal_request <ActionT>(
526+ if (intra_process_server_available) {
527+ ipm->intra_process_action_send_goal_request <ActionT>(
528528 ipc_action_client_id_,
529529 std::move (goal_request),
530530 callback);
531- intra_process_send_done = true ;
532- }
531+ intra_process_send_done = true ;
533532 }
534-
535- if (!intra_process_send_done) {
533+ }
534+
535+ if (!intra_process_send_done) {
536536 // Send inter-process goal request
537- this ->send_goal_request (
537+ this ->send_goal_request (
538538 std::static_pointer_cast<void >(goal_request),
539539 callback);
540- }
540+ }
541541
542542 // TODO(jacobperron): Encapsulate into it's own function and
543543 // consider exposing an option to disable this cleanup
@@ -848,53 +848,53 @@ class Client : public ClientBase
848848 // The client callback to be called when server calculates the result, using the server
849849 // response as argument.
850850 auto callback =
851- [goal_handle, this ](std::shared_ptr<void > response) mutable
852- {
851+ [goal_handle, this ](std::shared_ptr<void > response) mutable
852+ {
853853 // Wrap the response in a struct with the fields a user cares about
854- WrappedResult wrapped_result;
855- using GoalResultResponse = typename ActionT::Impl::GetResultService::Response;
856- auto result_response = std::static_pointer_cast<GoalResultResponse>(response);
857- wrapped_result.result = std::make_shared<typename ActionT::Result>();
858- *wrapped_result.result = result_response->result ;
859- wrapped_result.goal_id = goal_handle->get_goal_id ();
860- wrapped_result.code = static_cast <ResultCode>(result_response->status );
861- goal_handle->set_result (wrapped_result);
862- std::lock_guard<std::recursive_mutex> lock (goal_handles_mutex_);
863- goal_handles_.erase (goal_handle->get_goal_id ());
864- };
865-
866- try {
867- bool intra_process_send_done = false ;
868-
869- std::lock_guard<std::recursive_mutex> lock (ipc_mutex_);
870-
871- if (use_intra_process_) {
872- auto ipm = weak_ipm_.lock ();
873- if (!ipm) {
874- throw std::runtime_error (
854+ WrappedResult wrapped_result;
855+ using GoalResultResponse = typename ActionT::Impl::GetResultService::Response;
856+ auto result_response = std::static_pointer_cast<GoalResultResponse>(response);
857+ wrapped_result.result = std::make_shared<typename ActionT::Result>();
858+ *wrapped_result.result = result_response->result ;
859+ wrapped_result.goal_id = goal_handle->get_goal_id ();
860+ wrapped_result.code = static_cast <ResultCode>(result_response->status );
861+ goal_handle->set_result (wrapped_result);
862+ std::lock_guard<std::recursive_mutex> lock (goal_handles_mutex_);
863+ goal_handles_.erase (goal_handle->get_goal_id ());
864+ };
865+
866+ try {
867+ bool intra_process_send_done = false ;
868+
869+ std::lock_guard<std::recursive_mutex> lock (ipc_mutex_);
870+
871+ if (use_intra_process_) {
872+ auto ipm = weak_ipm_.lock ();
873+ if (!ipm) {
874+ throw std::runtime_error (
875875 " intra process send result called after destruction of intra process manager" );
876- }
877- bool intra_process_server_available =
878- ipm->action_server_is_available (ipc_action_client_id_);
879-
876+ }
877+ bool intra_process_server_available =
878+ ipm->action_server_is_available (ipc_action_client_id_);
879+
880880 // Check if there's an intra-process action server available matching this client.
881881 // If there's not, we fall back into inter-process communication, since
882882 // the server might be available in another process or was configured to not use IPC.
883- if (intra_process_server_available) {
884- ipm->intra_process_action_send_result_request <ActionT>(
883+ if (intra_process_server_available) {
884+ ipm->intra_process_action_send_result_request <ActionT>(
885885 ipc_action_client_id_,
886886 std::move (goal_result_request),
887887 callback);
888- intra_process_send_done = true ;
889- }
890- }
891-
892- if (!intra_process_send_done) {
888+ intra_process_send_done = true ;
889+ }
890+ }
891+
892+ if (!intra_process_send_done) {
893893 // Send inter-process result request
894- this ->send_result_request (
894+ this ->send_result_request (
895895 std::static_pointer_cast<void >(goal_result_request),
896896 callback);
897- }
897+ }
898898 } catch (rclcpp::exceptions::RCLError & ex) {
899899 // This will cause an exception when the user tries to access the result
900900 goal_handle->invalidate (exceptions::UnawareGoalHandleError (ex.message ));
@@ -921,35 +921,35 @@ class Client : public ClientBase
921921 }
922922 };
923923
924- bool intra_process_send_done = false ;
925-
926- std::lock_guard<std::recursive_mutex> lock (ipc_mutex_);
927-
928- if (use_intra_process_) {
929- auto ipm = weak_ipm_.lock ();
930- if (!ipm) {
931- throw std::runtime_error (
924+ bool intra_process_send_done = false ;
925+
926+ std::lock_guard<std::recursive_mutex> lock (ipc_mutex_);
927+
928+ if (use_intra_process_) {
929+ auto ipm = weak_ipm_.lock ();
930+ if (!ipm) {
931+ throw std::runtime_error (
932932 " intra process send goal called after destruction of intra process manager" );
933- }
934- bool intra_process_server_available = ipm->action_server_is_available (ipc_action_client_id_);
935-
933+ }
934+ bool intra_process_server_available = ipm->action_server_is_available (ipc_action_client_id_);
935+
936936 // Check if there's an intra-process action server available matching this client.
937937 // If there's not, we fall back into inter-process communication, since
938938 // the server might be available in another process or was configured to not use IPC.
939- if (intra_process_server_available) {
940- ipm->intra_process_action_send_cancel_request <ActionT>(
939+ if (intra_process_server_available) {
940+ ipm->intra_process_action_send_cancel_request <ActionT>(
941941 ipc_action_client_id_,
942942 std::move (cancel_request),
943943 callback);
944- intra_process_send_done = true ;
945- }
944+ intra_process_send_done = true ;
946945 }
947-
948- if (!intra_process_send_done) {
949- this ->send_cancel_request (
946+ }
947+
948+ if (!intra_process_send_done) {
949+ this ->send_cancel_request (
950950 std::static_pointer_cast<void >(cancel_request),
951951 callback);
952- }
952+ }
953953 return future;
954954 }
955955
0 commit comments