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

Using multiple arduinos / running multiple nodes

asked 2012-01-18 19:51:56 -0500

Hououin Kyouma gravatar image

Hi, I have two arduinos (Uno and Duemilanove) and I want to use the two of them in parallel on one machine. However, rosserial_python does not accept multiple /dev files as parameters, so I cannot give the addresses of both arduinos to one rosserial_python node.

The other option is running multiple rosserial_python nodes with each having different parameters, but ROS does not allow that since there are multiple nodes with the same name. It should be possible to run multiple nodes on one machine, but I don't know how. Any help is appreciated, thanks in advance!

edit retag flag offensive close merge delete

5 Answers

Sort by ยป oldest newest most voted
1

answered 2012-01-19 00:54:38 -0500

joq gravatar image

Renaming the nodes should work, but you may find it more convenient to run each robot in a separate namespace.

That can be done in roslaunch using the ns attribute of the <node> or <group> tags. Or, directly with rosrun using the ROS_NAMESPACE environment variable.

edit flag offensive delete link more
3

answered 2012-01-18 21:55:56 -0500

Hansg91 gravatar image

You can run multiple nodes with different names through a launch script.

You can check here for more information on how to construct a proper launch script.

edit flag offensive delete link more

Comments

Thanks for your fast response, I will try it and tell you when it works.
Hououin Kyouma gravatar image Hououin Kyouma  ( 2012-01-18 21:59:28 -0500 )edit
Also for testing __name:=myname works.
dornhege gravatar image dornhege  ( 2012-01-19 01:54:54 -0500 )edit
Unfortunately, this didn't work for me, but I solved it using different namespaces. Thanks for the answer though.
Hououin Kyouma gravatar image Hououin Kyouma  ( 2012-01-24 23:53:03 -0500 )edit
2

answered 2015-06-27 21:24:54 -0500

MarkGalea gravatar image

updated 2015-06-27 21:26:36 -0500

I know this is a late reply, yet the information here helped me find another alternative thus sharing it might be helpful to others. What I did was change the init_node to :

rospy.init_node("serial_node", anonymous=True) rospy.loginfo("ROS Serial Python Node {}".format(rospy.get_caller_id()))

This way every node created is unique thus you can have as many serial_nodes as you wish. Till now I haven't found any repercussions and everything seems to work perfectly, if you know about any issues with my solution feel free to comment.

For those out there that do not know which file to modify, the change was carried out on serial_node.py which could be found in your ros workspace in rosserial/rosserial_python/nodes folder.

edit flag offensive delete link more

Comments

worked like a breeeeze !!! awesome thanks!!

ELLEO gravatar image ELLEO  ( 2018-03-20 16:19:54 -0500 )edit

Hy there,

this works not if I want to load the parameters in the launch file, since the name of the node changes! Any idea?

mtROS gravatar image mtROS  ( 2018-05-17 01:48:13 -0500 )edit
1

answered 2012-03-15 03:08:33 -0500

Hououin Kyouma gravatar image

updated 2012-03-15 03:27:28 -0500

joq gravatar image

Indeed, that was also an option but then you'll have two python files with the same code, which is not really an elegant solution in my opinion. I solved this problem by using a launch file which runs the same node twice, using different namespaces. This is waht you need to put in your launch file:

<node ns="arduino_zero" name="nero_arduino_zero" pkg="rosserial_python" type="serial_node.py" args="path_to_dev_file" output="screen" />
<node ns="arduino_duemilanove" name="nero_arduino_duemilanove" pkg="rosserial_python" type="serial_node.py" args="path_to_other_dev_file" output="screen" />

In this case, I called my nodes arduino_zero and arduino_duemilanove, but you can give them any name or namespace you want.

edit flag offensive delete link more

Comments

Hope it's all right jumping in on this question. Jack. By doing what you suggest are both Arduinos being talked to together or is ROS waiting on the response from one before talking to the other? From the "HelloWorld" tutorial would both Aduinos publish to chatter simultaneously or would 2nd 1 wait?

MiniMe gravatar image MiniMe  ( 2015-06-12 09:07:37 -0500 )edit

Each ROS node runs independently in its own process.

joq gravatar image joq  ( 2015-06-19 19:33:44 -0500 )edit
1

answered 2012-03-12 21:09:44 -0500

tux-lab gravatar image

I ran into the same problem and I ended up copying serial_node.py to serial_node2.py and changing rospy.init_node("serial_node") to rospy.init_node("serial_node2").

That allowed me to connect to two arduinos. So far, I am able to echo the nodes and see the outputs.

edit flag offensive delete link more

Comments

I did what you said but it didn't work for me

rosrun rosserial_python serial_node.py /dev/ttyACM0

Then when using the following command the USB is disconnected and it generates an error in the terminal rosrun rosserial_python serial_node2.py /dev/ttyACM1

Pipe gravatar image Pipe  ( 2022-06-06 22:50:42 -0500 )edit

Question Tools

Stats

Asked: 2012-01-18 19:51:56 -0500

Seen: 6,661 times

Last updated: Jun 27 '15