Comparing two ROS messages?

asked 2020-05-28 05:57:00 -0600

jarvis1394 gravatar image

Hello all. I am a newbie in ROS. I just have a small doubt to ask. Consider I have a robot moving from one point to another and it publishes the timestamp of the starting point and also the timestamp at the endpoint. Now i have written a subscriber to listen to the timestamps of the two timestamps, find the difference(duration it took) and print it. can someone help me out with this logic on how to approach further.

edit retag flag offensive close merge delete

Comments

Hi @jarvis1394,

What are you trying to achieve with that behaviour? Furthemore, what type of high level control you are using to move the robot?

If want to know the duration of a taks just perform a difference:

ros::Time begin = ros::Time::now();
while(...)
{
  //Do some work
}
ros::Time end = ros::Time::now();
ros::Duration time_diff = end - begin;
std::cout << "Seconds: " <<  time_diff.toSec() << std::endl;
Weasfas gravatar image Weasfas  ( 2020-06-09 17:16:48 -0600 )edit