Skip to content

Commit

Permalink
remove usage of spin until future complete from callback method
Browse files Browse the repository at this point in the history
Signed-off-by: Aleksander Szymański <bitterisland6@gmail.com>
  • Loading branch information
Bitterisland6 committed Dec 18, 2023
1 parent 858c045 commit 47f08db
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions leo_fw/src/firmware_message_converter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ class FirmwareMessageConverter : public rclcpp::Node
const std::shared_ptr<std_srvs::srv::Trigger::Request> req,
std::shared_ptr<std_srvs::srv::Trigger::Response> res)
{
constexpr std::chrono::seconds callback_timeout = std::chrono::seconds(3);
odom_merged_position.x = 0.0;
odom_merged_position.y = 0.0;
odom_merged_yaw = 0.0;
Expand All @@ -251,9 +252,9 @@ class FirmwareMessageConverter : public rclcpp::Node

auto result = reset_odometry_client->async_send_request(reset_request);

if (rclcpp::spin_until_future_complete(
this->get_node_base_interface(),
result) != rclcpp::FutureReturnCode::SUCCESS)
auto result_status = result.wait_for(callback_timeout);

if (result_status == std::future_status::ready)
{
res->success = false;
} else {
Expand Down

0 comments on commit 47f08db

Please sign in to comment.