Ask Your Question
1

baud rate parameter in rosserial_python arduino

asked 2015-04-09 13:12:09 -0500

Naman gravatar image

Hi all,

I am trying serial communication between the Arduino and ROS using rosserial ( http://wiki.ros.org/rosserial ). It works perfectly with the default parameter for the baud rate:

rosrun rosserial_python serial_node.py _port:=/dev/ttyACM0

but when I give a different baud rate using this:

rosrun rosserial_python serial_node.py _port:=/dev/ttyACM0 _baud:=9600

I get the following error:

[INFO] [WallTime: 1428602466.003588] ROS Serial Python Node
[INFO] [WallTime: 1428602466.016732] Connecting to /dev/ttyACM0 at 9600 baud
[ERROR] [WallTime: 1428602483.124382] Unable to sync with device; possible link problem or link software version mismatch such as hydro rosserial_python with groovy Arduino

I have rosserial-indigo-devel installed and the ROS version is indigo. The above error comes only when you specify a baud rate other than 57600 (default baud rate).
I also looked into serial_node.py and changed the default baud rate to 9600 but then also, it only works with the baud rate of 57600 and gives error if some other baud rate is specified.

Does anyone know what can be the problem?

Thanks in advance.
Naman Kumar

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
7

answered 2015-04-09 17:55:59 -0500

You can set the baud rate in your Arduino code by using nh.getHardware()->setBaud(BAUD) before you initialize the node. BAUD would be 9600 in your case.

edit flag offensive delete link more

Comments

Thank you so much! I have been wondering how to do this!

kwiesz91 gravatar imagekwiesz91 ( 2015-08-11 17:34:01 -0500 )edit

Is it also possible to specify the serial port e.g. Serial1, Serial2 for Arduino mega or a software serial port?

Ameer Hamza Khan gravatar imageAmeer Hamza Khan ( 2017-12-31 05:58:57 -0500 )edit
1

answered 2015-04-09 17:25:34 -0500

Naman gravatar image

updated 2015-04-09 17:26:01 -0500

So..rosserial_arduino was always setting the baud rate of arduino as 57600. So, for rosserial_python, only the baud rate of 57600 was working.I made rosserial_arduino run at the baud rate of 9600 (or 19200, etc.) by editing ArduinoHardware.h in <sketchbook>/libraries/ros_lib and then specified the same baud rate for rosserial_python and it is working now.
Just make sure to change the baud rates for both rosserial_arduino and rosserial_python if you want to use a non-default baud rate.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2015-04-09 13:12:09 -0500

Seen: 8,458 times

Last updated: Apr 09 '15