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

How to call a service from XML launch file?

asked 2023-02-19 15:04:36 -0500

ROS_Engineer gravatar image

Is there an equivalent to rosservice from ROS1 in ROS2? Much appreciated.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2023-02-20 15:54:14 -0500

ROS_Engineer gravatar image

For posterity, I found a solution using the executable tag. Let's say you wanted to spawn a second turtle in turtlesim, the below will accomplish this:

<executable
    cmd="/spawn turtlesim/srv/Spawn '{x: 1.0, y: 1.0, theta: 0, name: 'custom_turtle'}'"
    cwd="/home"
    launch-prefix="ros2 service call"
    output="screen"
    >
</executable>

I don't know what 'cwd' is used for but it should remain as "/home" or else this particular command won't work. You can also combine the launch-prefix and cmd if so desired.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2023-02-19 15:04:36 -0500

Seen: 140 times

Last updated: Feb 19 '23