0
$\begingroup$

Rosanswers logo

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?


Originally posted by filconsoli on ROS Answers with karma: 1 on 2017-02-22

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

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.


Originally posted by rreignier with karma: 544 on 2017-09-30

This answer was ACCEPTED on the original site

Post score: 0

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.