0
$\begingroup$

Rosanswers logo

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


Originally posted by mattMGN on ROS Answers with karma: 78 on 2017-04-14

Post score: 1

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

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.


Originally posted by NEngelhard with karma: 3519 on 2017-04-14

This answer was ACCEPTED on the original site

Post score: 2


Original comments

Comment by mattMGN on 2017-04-14:
I now understand and it is working ! Thank you very much for this accurate answer.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.