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

How to use rosserial with Arduino hardware serial3?

asked 2021-02-24 05:05:23 -0500

the3kr gravatar image

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?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2021-05-20 21:21:54 -0500

nasr gravatar image

updated 2021-05-20 22:04:28 -0500

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 .
edit flag offensive delete link more

Comments

Is there another way to do this without editing another package's source code?

jayess gravatar image jayess  ( 2021-05-20 21:50:03 -0500 )edit

Unfortunately I haven't come across any other solutions that seemed to work in using other serial ports

nasr gravatar image nasr  ( 2021-05-20 22:05:09 -0500 )edit

I haven't tried this, but maybe use the "setPort" method? https://github.com/ros-drivers/rosser...

nasr gravatar image nasr  ( 2021-05-20 22:18:31 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2021-02-24 05:05:23 -0500

Seen: 271 times

Last updated: May 20 '21