Ask Your Question
0

Difference in rate when running arduino w/ and without ROS

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

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
0

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

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

Comments

I have four total nodes, one of which is serial_node.py 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 -0500 )edit

I hope this info helps ^ I haven't modified serial_node.py 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 -0500 )edit

Your Answer

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

Add Answer

Question Tools

2 followers

Stats

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

Seen: 264 times

Last updated: Aug 10 '17