Im writing a launch file for turtlesim and my custom node. I need to call a rosservice /turtleX/teleport_absolute 'x=1.0 y=1.0 theta=0.0' and a rosservice clear every time I run my node.
Is it possible to put this calls in a launchfile and how would you do it?
My launchfile so far:
<launch>
<node name="turtlesim" pkg="turtlesim" type="turtlesim_node"/>
<node name="turtle_lawnmower" pkg="turtle_lawnmower" type="turtle_lawnmower_node"/>
</launch>
There are two ways of doing this. First you can simply write another node that's sole job is to call the service. I'm not sure if I would strictly recommend this, but it would give you more control on parameters and conditional logic surrounding when the service is called.
The second option is to launch the ROS service as it's own node in the launch file.
<launch>
<node name="turtlesim" pkg="turtlesim" type="turtlesim_node"/>
<node name="turtle_lawnmower" pkg="turtle_lawnmower" type="turtle_lawnmower_node"/>
<node pkg="rosservice" type="rosservice" name="turtle_serv" args="call /turtleX/teleport_absolute x=1.0 y=1.0 theta=0.0"/>
</launch>
Note that since I don't know the exact definition of your service file I'm guessing on that parameter format, and you might have to adjust that yourself.