ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A
Ask Your Question

rosserial communication too slow and not fixed

asked 2017-02-22 15:50:16 -0500

filconsoli gravatar image

Hardware: Odroid XU4 and arduino Uno that communicate over the serial port using rosserial.

I'm testing the serial communication that seems to be very slow and variable.

Custom message sent:

float32 speed_dx
float32 speed_sx

The code I'm using on arduino is:

void loop()
   while(micros() - loop_timer < 1000000)  nh.spinOnce();

   loop_timer = micros();
   wheel_msg.speed_dx = loop_timer;

void callback(const car_msgs::wheel_speed &ref_msg){

  wheel_msg.speed_sx = micros() - ref_msg.speed_dx;

I publish 1 msg/s and in the meanwhile I continuously call nh.spinOnce(), in order to receive the message when ready.

On Odroid side I simply publish the message back:

void callback(const car_msgs::wheel_speed &input)
    output.speed_dx = input.speed_dx;
    output.speed_sx = input.speed_sx;

In this way I'm able to compute how many time pass from when I publish the message from arduino to when I get it back.

If I push the baud rate to 1Mbps (which seems to be the maximum supported on Arduino), it takes from 3.5 ms to 7.5 ms.

Why the communication is so slow and not fixed even if the message is always the same?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2017-09-30 18:49:59 -0500

rreignier gravatar image

First, keep in mind that a serial communication is always slow because limited by the baudrate.

But you are on a small 8-bit microcontroller on one side so don't expect too much speed. On the other side, you have an operating system that handle the process when it has the time to.

If you need a latency below the millisecond, your setup should be upgraded to another solution I guess.

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



Asked: 2017-02-22 15:50:16 -0500

Seen: 1,099 times

Last updated: Sep 30 '17