ros-drivers / rosserial

A ROS client library for small, embedded devices, such as Arduino. See: http://wiki.ros.org/rosserial
517 stars 525 forks source link

Multiple launch of rosserial_python #390

Closed nnn112358 closed 4 years ago

nnn112358 commented 6 years ago

I tried wifi communication between one Ubuntu(16.04) and multiple arduino(ESP32) by using ROS. Executed with the following command

Ubuntu

roscore rosrun rosserial_python serial_node.py tcp

arduino(ESP32)

I used the following https://qiita.com/nnn112358/items/1cd4517ea2faa57e9c13#arduino%E3%81%AE%E5%AE%9F%E8%A3%85

As I confirmed, rosserial_python seems to be doing one-on-one communication between Ubuntu and arduino(ESP32).

I want to launch more than one rosserial_python, but I do not know how to specify a specific TCP port.

Please give me some information if you have been challenged elsewhere.

romainreignier commented 6 years ago

From the source code, you have to specify one more argument to the command line on the rosserial_python side:

https://github.com/ros-drivers/rosserial/blob/6b996aae81df509614c08b3c9ed9ce7a27d2c7a0/rosserial_python/nodes/serial_node.py#L67

For the ESP side, you have to call the setConnection method with two arguments to specify the port before the initNode method, like in the example:

https://github.com/ros-drivers/rosserial/blob/6b996aae81df509614c08b3c9ed9ce7a27d2c7a0/rosserial_arduino/src/ros_lib/examples/Esp8266HelloWorld/Esp8266HelloWorld.ino#L50

Saums commented 5 years ago

Does assigning different ports to different Arduinos, allow you to have multiple connections?

romainreignier commented 5 years ago

Yes, it should works. Be aware of conflicts on topics names.