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

Difference in rate when running arduino w/ and without ROS

asked 2017-08-09 11:32:22 -0600

j3ven7 gravatar image

I have arduino code that takes readings from a bunch of sensors (IMU, hall sensors, encoder, gps). The details of the code are unimportant, but as it stands the loop runs at about 100hz on the arduino when ROS is not running. However, when I run ROS on my raspberry pi (which is connected to the arduino) the rate slows to about 10hz. I run all of my nodes in rospy at 100hz, so I am unsure if this delay is incurred by serial communication or something else. At the end of my arduino code my node head makes a call to spinOnce(). If I am running rospy on my raspberry pi should I be using a multi-threaded spin()? Any thoughts or other ideas? Has anyone experienced an issue like this and been able to fix it? I need to be running at at least 50 hz to get the PID controller we use working.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2017-08-10 04:23:25 -0600

On the arduino side, everything is running serialized on the single microcontroller core. This means that all message serialization and receiving/sending via serial (which happens when spinOnce() is called) takes up cycles that cannot be spent otherwise. If you send/receive a lot of data that could thus explain the slowdown.

edit flag offensive delete link more


I have four total nodes, one of which is from the rosserial_python library. When I run the other three nodes without serial communication I can run at 100hz and the PID controller is splendid. However, when I turn on the serial node this is when I have the problem described above.

j3ven7 gravatar image j3ven7  ( 2017-08-10 12:02:57 -0600 )edit

I hope this info helps ^ I haven't modified which is sort of concerning and I only publish in my arduino code, and ROS is actually running on a raspberry pi 3 connected to the ARduino due

j3ven7 gravatar image j3ven7  ( 2017-08-10 12:03:30 -0600 )edit

Question Tools



Asked: 2017-08-09 11:32:22 -0600

Seen: 828 times

Last updated: Aug 10 '17