How to execute command inside launch file?
How do you run a command inside a launch file to set a param value?
I have launch file like:
<launch>
<group ns="motor_arduino">
<node pkg="rosserial_python" type="serial_node.py" name="serial_node" output="screen">
<param name="~port" value="/dev/ttyACM0" />
<param name="~baud" value="115200" />
</node>
</group>
</launch>
which allows communication with one of several Arduino Unos connected to the host computer. However, I've found that the mount path /dev/ttyACM0
is variable, and based on how the Arduino's initialize, this may be /dev/ttyACM0
or /dev/ttyACM1
.
To fix this problem, I've written a script that reads the output of udevadm info --query=all --name=/dev/ttyACM*
and determines the correct device path to use. However, how do I call this script from inside the launch file to set the port
param dynamically?
The docs show that roslaunch does support some simply substitution commands, but I don't see a way to run an arbitrary script, e.g.
<param name="~port" value="$(identify_port.py device1)" />
gives me the error:
Unknown substitution command [identify_port.py device1]. Valid commands are ['find', 'env', 'optenv', 'anon', 'arg']