For a lab at my university I have developed a robot with an Arduino Mega ADK that can be controlled by ROS via the rosserial package. The connection between the Arduino and the laptop running ROS is made via bluetooth. During the prototyping phase the bluetooth module, HC-05, was connected to the Serial port that is also used for flashing the Arduino. Whenever I wanted to flash the Arduino I just disconnected the bluetooth module to prevent it from interfering.
However, we need to put all the electronics in a 3D printed casing, because we don't want students to touch the electronics during the lab. This revealed that we needed a solution for the interference of the bluetooth module. One option is to turn off the bluetooth with a switch, but this is far from ideal. The other option is to force the Arduino to use another Serial port (Serial1 in this case) for communication with ROS. In ros_lib (generated withrosrun rosserial_arduino make_libraries.py
.) I found the file ArduinoHardware.h
which contains some definitions including the iostream
on lines 66-72. I changed line 71 to Serial1
which forced the Arduino to use Serial1
instead of Serial
.
Although this did the job, it is not a very elegant solution. Is there some other, better way to solve this problem? For instance, could I use #define USBCON
to change the Serial port or will this have other implications because this is for the Leonardo? (I only saw this just now, so I still have to test this)
P.S. Just to be sure, I'm looking for an answer for the client side, not the host side. I already found numerous answers for changing the port on the host side.
Originally posted by WFH27 on ROS Answers with karma: 33 on 2014-11-25
Post score: 2