Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Rosservice only works on shell and not on rospy

Hi, It's my first post here so i hope everything's ok.

I have my robot "snake" in gazebo simulation already spawned and if i type in the shell

rosservice call /gazebo/delete_model "model_name: 'snake'"

it actually delete the snake. But if i run a python script with the following code:

delsnake = DeleteModel()
delsnake.model_name = 'snake'
delete = rospy.ServiceProxy('delete_model', DeleteModel)

or even

delete = rospy.ServiceProxy('delete_model', DeleteModel)
delete(model_name = 'snake')

which should be equivalent the terminal tells me:

raise ServiceException("service [%s] unavailable"%self.resolved_name)
rospy.service.ServiceException: service [/delete_model] unavailable

But the service is avaible! I cannot find a solution, the only thing i could do is actually run the command line from the python script but i don't think that's the way thing should go.

Can you help me please?

Thanks in advace!