Ask Your Question
4

Traveled Distance measurement

asked 2013-07-04 23:57:02 -0600

Lucile gravatar image

updated 2013-07-04 23:58:10 -0600

Hi !

I would like to measure the total distance the Turtlebot traveled while navigating. So I was wondering if there was a way to get this information from the odometry sensors ?

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
9

answered 2013-07-05 00:10:57 -0600

Procópio gravatar image

updated 2013-07-05 00:13:42 -0600

You can subscribe to the publication of the pose topic and store each publication in a pose array, for example. Then you can process that array to sum the distances between each reading.

float path_length = 0.0;
std::vector<geometry_msgs::PoseStamped>::iterator it = plan.poses.begin();
geometry_msgs::PoseStamped last_pose;
last_pose = *it;
it++;
for (; it!=plan.poses.end(); ++it) {
   path_length += hypot(  (*it).pose.position.x - last_pose.pose.position.x, 
                         (*it).pose.position.y - last_pose.pose.position.y );
   last_pose = *it;
}
ROS_INFO("... path length: %6.3f", path_length);

source of this code

you can do the same with the odometry publications, but you may have an accumulated error there.

edit flag offensive delete link more

Comments

Yes, I thought about this solution :) But I hoped there was a way to get the data from wheels' odometry and that I just didn't find it. I'll do it like this then. Thanks.

Lucile gravatar imageLucile ( 2013-07-05 01:58:46 -0600 )edit
1

you can do that, but you will have errors due to slippage, sensors, and others... if you want to try you have to find out what program is publishing the turtlebot odom, because it must access your sensors readings to build the message, so you can get those readings too and try to integrate them.

Procópio gravatar imageProcópio ( 2013-07-05 02:18:42 -0600 )edit

Hi, I have one question about what you said. I make sense the code you post, but how can calculate it in Matlab environment. Is there any easier way. Thanks.

Wentao gravatar imageWentao ( 2017-10-31 08:26:56 -0600 )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: 2013-07-04 23:57:02 -0600

Seen: 1,963 times

Last updated: Jan 13 '16