Calling a Rosservice attached to a macro from a Python script

asked 2022-04-05 17:14:06 -0500

zippyzoo77 gravatar image

updated 2022-04-05 17:14:51 -0500

Hello!

I am trying to use this macro as a part of a simulation I am working on. So far it does work, but in order to have it actually do what it does, I have to type a very long message into the terminal. I would eventually like to be able to call it within a python file as different tasks are divided between several robots, to change the color of a waypoint representing each task. I'm still new to ros, and I've been working my way through various resources and tutorials about services, and I'm still confused as to how I would be able to call this service, since I cannot find a srv file or directory anywhere in the macro, only the name of the service (defined in the box.gazebo.urdf.xacro).

This is how I currently call the service:

rosservice call /my_box_color "light_name: ''
cast_shadows: false
diffuse: {r: 0.50, g: 0.50, b: 0.0, a: 01.0}
specular: {r: 0.0, g: 0.0, b: 0.0, a: 0.0}
attenuation_constant: 0.0
attenuation_linear: 0.0
attenuation_quadratic: 0.0
direction: {x: 0.0, y: 0.0, z: 0.0}
pose:
  position: {x: 0.0, y: 0.0, z: 0.0}
  orientation: {x: 0.0, y: 0.0, z: 0.0, w: 0.0}"

How can I do this a python file? All the things I can find for using rospy tools seem to require building the service yourself, and having access to the service files, but I don't know where/how to find those, and the service will already exist when I instantiate the macro for each of my markers, I don't want to create it all over again, I just want to call the one that will already be there. I've already looked through the basic tutorials on services, but with this case they haven't helped me, and the rospy overview of services. I'm just really stuck as to where to even begin on this.

edit retag flag offensive close merge delete