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

rosserial communication too slow and not fixed

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

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;
   pub_speed.publish(&wheel_msg);
}

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;
    pub_ref.publish(output);
  }
...

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
0

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

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

Question Tools

2 followers

Stats

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

Seen: 1,415 times

Last updated: Sep 30 '17