ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

[ROS2] call service :"waiting for service to become available"

asked 2020-02-28 05:06:36 -0500

jlepers gravatar image

updated 2020-02-28 05:39:46 -0500


I'm using the std_srvs/srv/Trigger service:

 rclcpp::Client<std_srvs::srv::Trigger>::SharedPtr init = node->create_client<std_srvs::srv::Trigger>("/init");

 auto trig = std::make_shared<std_srvs::srv::Trigger::Request>();
 auto trig_result = init->async_send_request(trig);

if (rclcpp::spin_until_future_complete(node, trig_result) ==
                    RCLCPP_INFO(node->get_logger(),"Init motor succesfull.");

First I check if the service is live:

 ros2 service list

I can find the /init service so I want to call it like in following tutorial :

ros2 service call /init std_srvs/srv/Trigger

The only response I get is:

> waiting for service to become available ...

What am I doing wrong calling or creating this service ?


edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2020-02-28 07:23:22 -0500

marguedas gravatar image

You don't seem to be creating a service server anywhere, only a client. This is likely the reason why you get the message "waiting for service to become available ..."

Is there another node in your system providing the /initservice ? If not you need to create a service server similar to this tutorial

edit flag offensive delete link more


void CanopenChainComponent::handle_recover( const std::shared_ptr<std_srvs::srv::trigger::request> request, std::shared_ptr<std_srvs::srv::trigger::response> response)

jlepers gravatar image jlepers  ( 2020-02-28 07:36:57 -0500 )edit

This is the signature of a service callback without additional context. Could you please edit your question and provide the exact code that you are using? How you are creating the rclcpp::Service etc

Do you succeed to call the service with the C++ snippet code you showed above or does that fail too ?

marguedas gravatar image marguedas  ( 2020-02-28 11:04:15 -0500 )edit

Question Tools

1 follower


Asked: 2020-02-28 05:06:36 -0500

Seen: 4,331 times

Last updated: Feb 28 '20