Ask Your Question
1

Problem with parameter in launch file [closed]

asked 2017-04-14 03:31:25 -0600

mattMGN gravatar image

Hello,

I am working with a Raspberry Pi and an Arduino on ROS indigo. I wrote this script to launch multiple nodes.

<launch>
    <node pkg="beginner_tutorials" name="xbox_joy" type="xbox_joy.py"/>
    <node pkg="joy" name="joy_node" type="joy_node"/>
        <param name="joy_node/dev" value="/dev/input/js1" />
    <node pkg="rosserial_python" name="serial_node" type="serial_node.py"/>
        <param name="port" value="/dev/ttyACM0"/>
        <param name="baud" value="115200"/>
</launch>

All nodes and parameters work, except the last one : port parameter from serial_node is not taken into account. So I get the message :

process[rosout-1]: started with pid [4606]
started core service [/rosout]
process[xbox_joy-2]: started with pid [4610]
process[joy_node-3]: started with pid [4624]
process[serial_node-4]: started with pid [4625]
  pub = rospy.Publisher('/cmd_vel',Twist)
[ERROR] [WallTime: 1492157910.346003] Error opening serial: could not open port /dev/ttyUSB0: [Errno 2] No such file or directory: '/dev/ttyUSB0'
[serial_node-4] process has finished cleanly

Roscore is looking for port /dev/ttyUSB0, instead the given one : /dev/ttyACM0. Anybody know what I am doing wrong ?

Regards

Matthieu

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by NEngelhard
close date 2017-04-14 09:55:55.848520

1 Answer

Sort by ยป oldest newest most voted
2

answered 2017-04-14 04:49:26 -0600

NEngelhard gravatar image

updated 2017-04-14 09:55:43 -0600

Let's see: After running your launch file, I checked the parameters:

[/tmp] rosparam list 
/baud
/port
(...)

So somehow there is a port argument, it's just in the global namespace instead of the local namespace of the node. XML is not python, so indentations have no meaning, the relevant part of your launch file therefore looks like

<launch>
    <node pkg="rosserial_python" name="serial_node" type="serial_node.py"/>
    <param name="port" value="/dev/ttyACM0"/>
    <param name="baud" value="115200"/>
</launch>

There is nothing that tells ROS that the port-parameter has something to do with the serial_node. (order within a launch file has also no meaning) Your mistake was to close the node-tag "serial_node.py"/> If you want the parameters to be in your local namespace, move them inside your node-tag:

<launch>
    (...)
    <node pkg="rosserial_python" name="serial_node" type="serial_node.py">
        <param name="port" value="/dev/ttyACM0"/>
        <param name="baud" value="115200"/>
    </node>
</launch>

And then your parameters will look better:

[/tmp] rosparam list 
/serial_node/baud
/serial_node/port
(...)

So that the parameters are in the right namespaces.

edit flag offensive delete link more

Comments

I now understand and it is working ! Thank you very much for this accurate answer.

mattMGN gravatar imagemattMGN ( 2017-04-14 09:01:05 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2017-04-14 03:31:25 -0600

Seen: 231 times

Last updated: Apr 14 '17