Ask Your Question
2

how to call a service inside a node?

asked 2015-01-23 11:03:12 -0500

Robot gravatar image

I am working with summitXL. After reaching the target point I would like to set the odometry by calling the ros service "/summit_a/set_odometry". How can I call the service inside the node. Thanks in advance.

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted
2

answered 2015-01-23 11:11:35 -0500

Hey there,

Please check here: http://wiki.ros.org/ROS/Tutorials

Probably you are looking for: Writing a Simple Service and Client (C++)

edit flag offensive delete link more

Comments

1

thanks for the ans. but all I need is to call a predefined service inside my node.

Robot gravatar image Robot  ( 2015-01-23 11:13:20 -0500 )edit
1

Which is exactly what the service client tutorial teaches you.

gvdhoorn gravatar image gvdhoorn  ( 2015-01-23 11:15:06 -0500 )edit
1

but I have to call the service in the callback function where it has no nodehandle object.

Robot gravatar image Robot  ( 2015-01-23 11:26:22 -0500 )edit

You should store the NodeHandle somewhere that can be accessed inside the callback so you can use it.

tfoote gravatar image tfoote  ( 2015-03-12 13:57:19 -0500 )edit

Instead of writing all these, a simple answer would be convenient for everyone. Besides, even in that tutorial, it's not clear. There is add_two_ints variable, said to be handle, but should it have the same name when it's a function or a variable, it's vague.

Jägermeister gravatar image Jägermeister  ( 2019-08-05 07:41:59 -0500 )edit
1

answered 2019-10-21 06:49:02 -0500

mustafadurmus gravatar image

You can call a ros service inside a node like:

import rosservice
rosservice.call_service("YOUR_SERVICE_NAME",[Arguments])
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2015-01-23 11:03:12 -0500

Seen: 3,062 times

Last updated: Jan 23 '15