# What to use with amcl to get the robot current Velocity, geometry_msgs or nav_msg/Odometry??

Im using amcl amd gmapping for localisation. So I just want to know the robot velocity when it is zero ( or very small value) and its position ( the distance) to some reference object in the map by that zero velocity. So im not doing navigation, just localisation and analysing. So I think best way is to use geometry_msgs with twist.twist.linear.x and twist.twist.angular.z to get the linear and angular Velocity . Is that correct or I have to to nav_msgs/Odometry to get the velocity and position of the robot??? Any help¿

edit retag close merge delete

1
( 2012-09-11 07:13:22 -0500 )edit

Sort by » oldest newest most voted

If implemented correctly nav_msgs/Odometry should be the better way.

The twist is usually what is sent to the robot, and the Odometry what the robot currently does. If you send velocity zero, it doesn't mean that the robot immediately stops. Odometry should give you what is actually happening and not what someone commands.

Note however, that odometry usually only mean wheel revolutions. Depending on your hardware and setting that might be totally OK, but if the robot slips down a slop, although the wheel are stopped neither method works.

more

I am not exactly sure what you really want to achieve but I have done something similar in my project.
I use actionlib to send goals to the robot and wait until the goal have been reached. Then I recorded the position of the robot for later analysis. You can see a part of the code below. It of cause requires that the whole navigation stack is running.

    goal.target_pose.header.frame_id = "/map";

goal.target_pose.pose.position.x = 1.5;
goal.target_pose.pose.position.y = -7.0;

angle = tf::createQuaternionFromRPY(0.0, 0.0, -M_PI_2 );
goal.target_pose.pose.orientation.x = (float)angle.x();
goal.target_pose.pose.orientation.y = (float)angle.y();
goal.target_pose.pose.orientation.z = (float)angle.z();
goal.target_pose.pose.orientation.w = (float)angle.w();

ROS_INFO("Sending goal");
ac.sendGoal(goal);
ac.waitForResult();

try {

}
catch( tf::TransformException ex ) {

ROS_ERROR("%s", ex.what() );
}

ROS_INFO("Ground truth: %f %f", transform.getOrigin().x(), transform.getOrigin().y());

more