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

Calling Global Localization Service in C++

asked 2012-08-07 05:32:01 -0500

pdunlap2 gravatar image

Hi all. I have found documentation on calling ros services using ros::service::call but I cannot figure out how to tell it I would like to call the /global_localization service that AMCL provides.

ros::service:call("/global_localization", ???)

What goes in place of the ???

I am working on a program that sends goals to the robot (using the /map frame) and I would like to call the service and have the robot drive around until it is localized instead of using RVIZ to give it a pose estimate manually. I know that I can use rosservice call /global_localization but I would like to do it programmatically if at all possible.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2012-08-07 05:43:26 -0500

dornhege gravatar image

rosservice type /global_localization will give you the service type to fill in there. You can lookup the contents of the request in the API description.

edit flag offensive delete link more

answered 2019-08-11 03:29:38 -0500

rajmohan747 gravatar image

updated 2022-07-02 03:35:17 -0500

On typing rosservice info /global_localization, you can observe Type: std_srvs/Empty

So you may do service call like rosservice call /global_localization "{}"


Programatically you may use it like

ros::NodeHandle nh;
ros::ServiceClient client =nh.serviceClient<std_srvs::empty>("/global_localization");
std_srvs::Empty srv;;

edit flag offensive delete link more

Question Tools


Asked: 2012-08-07 05:32:01 -0500

Seen: 1,391 times

Last updated: Jul 02 '22