How to use rosserial with Arduino hardware serial3?
I'm trying to read neo6m GPS longitude and latitude with hardware serial3 port in arduino mega and use it together with rosserial but I'm getting a unable to sync error in rosserial. I'd to call the Serial3.begin() file in the setup function and read somewhere online that to avoid the unable to sync error, you can't have a the begin() function. So is there a way to use an arduino hardware serial port with rosserial?
Asked by the3kr on 2021-02-24 06:05:23 UTC
Answers
Assuming you have rosserial_arduino installed, navigate to the source code:
roscd rosserial_arduino
edit the file ArduinoHardware.h (inside roslib folder)
Search for iostream = &Serial;
and change that to iostream = &Serial3;
There is no need for Serial3.begin() in your arduino code. Refer to any of the Examples from ros_lib inside the Arduino IDE and use that for testing first.
Edit: Note that you need to delete the ros_lib folder inside the Arduino libraries and re-run the command (and possibly re-upload the arduino code afterwards)
rosrun rosserial_arduino make_libraries.py .
Asked by nasr on 2021-05-20 21:21:54 UTC
Comments
Is there another way to do this without editing another package's source code?
Asked by jayess on 2021-05-20 21:50:03 UTC
Unfortunately I haven't come across any other solutions that seemed to work in using other serial ports
Asked by nasr on 2021-05-20 22:05:09 UTC
I haven't tried this, but maybe use the "setPort" method? https://github.com/ros-drivers/rosserial/blob/noetic-devel/rosserial_arduino/src/ros_lib/ArduinoHardware.h
Asked by nasr on 2021-05-20 22:18:31 UTC
Comments