Skip to content

Commit

Permalink
Check if goal was sent through IPC before send result
Browse files Browse the repository at this point in the history
  • Loading branch information
Mauro Passerino committed Aug 6, 2024
1 parent a2bfddf commit cd1943b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,17 @@ class ActionClientIntraProcessBase : public rclcpp::Waitable
event_info_multi_map_.erase(goal_id);
}

bool has_goal_id(size_t goal_id) const
{
// Check if the intra-process client has this goal_id
auto it = event_info_multi_map_.find(goal_id);
if (it != event_info_multi_map_.end()) {
return true;
}

return false;
}

private:
std::string action_name_;
QoS qos_profile_;
Expand Down
16 changes: 11 additions & 5 deletions rclcpp_action/include/rclcpp_action/client.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -845,12 +845,18 @@ class Client : public ClientBase
// the server might be available in another process or was configured to not use IPC.
if (intra_process_server_available) {
size_t hashed_guuid = std::hash<GoalUUID>()(goal_handle->get_goal_id());
ipc_action_client_->store_result_response_callback(
hashed_guuid, result_response_callback);

intra_process_send_done = ipm->template intra_process_action_send_result_request<ActionT>(
ipc_action_client_id_,
std::move(goal_result_request));
// check if this goal has been sent through intra-process
bool goal_sent_by_ipc = ipc_action_client_->has_goal_id(hashed_guuid);

if (goal_sent_by_ipc) {
ipc_action_client_->store_result_response_callback(
hashed_guuid, result_response_callback);

intra_process_send_done = ipm->template intra_process_action_send_result_request<ActionT>(
ipc_action_client_id_,
std::move(goal_result_request));
}
}
}

Expand Down

0 comments on commit cd1943b

Please sign in to comment.