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

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

asked 2012-09-10 15:24:13 -0600

Astronaut gravatar image

updated 2012-09-10 23:51:29 -0600

Lorenz gravatar image

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 flag offensive close merge delete

Comments

1

2 Answers

Sort by » oldest newest most voted
2

answered 2012-09-11 00:43:32 -0600

dornhege gravatar image

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.

edit flag offensive delete link more
0

answered 2012-09-10 23:26:29 -0600

Aslund gravatar image

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.header.stamp = ros::Time::now(); 

    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 {

        listener.waitForTransform("/odom", "/base_link", ros::Time::now(), ros::Duration(0.5));
        listener.lookupTransform("/odom", "/base_link", ros::Time::now(), transform);  

    }
    catch( tf::TransformException ex ) {

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

    ROS_INFO("Ground truth: %f %f", transform.getOrigin().x(), transform.getOrigin().y());
edit flag offensive delete link more

Question Tools

Stats

Asked: 2012-09-10 15:24:13 -0600

Seen: 814 times

Last updated: Sep 11 '12