Skip to content

Commit 0350b66

Browse files
authored
change priority of actions (see rclcpp:2612) (#161)
1 parent 1e37201 commit 0350b66

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

rclcpp_action/src/client.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,16 @@ ClientBase::is_ready(const rcl_wait_set_t & wait_set)
354354
}
355355

356356
pimpl_->next_ready_event = ClientBaseImpl::NO_EVENT_READY;
357+
// The following 'if' statements set the priority of execution for different entities.
358+
// The order of priority for action components are:
359+
// Status > Goal Response > Result Response > Cancel Response > Feedback.
360+
// Feedback has the lowest priority, since if the client spins slower than the
361+
// server's feedback rate, it may never process the action results.
362+
363+
if (is_status_ready) {
364+
pimpl_->next_ready_event = static_cast<size_t>(EntityType::StatusSubscription);
365+
return true;
366+
}
357367

358368
if (is_goal_response_ready) {
359369
pimpl_->next_ready_event = static_cast<size_t>(EntityType::GoalClient);
@@ -375,11 +385,6 @@ ClientBase::is_ready(const rcl_wait_set_t & wait_set)
375385
return true;
376386
}
377387

378-
if (is_status_ready) {
379-
pimpl_->next_ready_event = static_cast<size_t>(EntityType::StatusSubscription);
380-
return true;
381-
}
382-
383388
return false;
384389
}
385390

rclcpp_action/test/test_client.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,7 @@ TEST_F(TestClientAgainstServer, async_send_goal_with_feedback_callback_wait_for_
565565

566566
ASSERT_EQ(5u, wrapped_result.result->sequence.size());
567567
EXPECT_EQ(3, wrapped_result.result->sequence.back());
568-
EXPECT_EQ(5, feedback_count);
568+
EXPECT_EQ(2, feedback_count);
569569
}
570570

571571
TEST_F(TestClientAgainstServer, async_send_goal_with_result_callback_wait_for_result)
@@ -1010,11 +1010,12 @@ TEST_F(TestClientAgainstServer, execute_rcl_errors)
10101010
{
10111011
ActionGoal goal;
10121012
goal.order = 5;
1013-
auto mock = mocking_utils::patch_and_return(
1014-
"lib:rclcpp_action", rcl_action_take_result_response, RCL_RET_ERROR);
10151013

10161014
auto future_goal_handle = action_client->async_send_goal(goal, send_goal_ops);
10171015
dual_spin_until_future_complete(future_goal_handle);
1016+
auto mock = mocking_utils::patch_and_return(
1017+
"lib:rclcpp_action", rcl_action_take_result_response, RCL_RET_ERROR);
1018+
10181019
auto goal_handle = future_goal_handle.get();
10191020
auto future_result = action_client->async_get_result(goal_handle);
10201021
EXPECT_THROW(

0 commit comments

Comments
 (0)