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

position and orientation of the robot

asked 2012-08-20 19:30:34 -0600

Astronaut gravatar image

updated 2012-08-21 02:37:06 -0600

Hello

I went through tf tutorial and some questions here (http://answers.ros.org/question/39250/getting-the-position-and-the-pose-of-robot-using-tf_listener/) . I assume that my robot is an rectangle so want to know the position of each corner point of my rectangle. So as I understand to get the position and orientation I need these two tf transforms. I wont the have the position and orientation of all four corner point of the rectangle . My rectangle have dimension 60x90cm . The center of the base_link frame is the center of the rectangle. So I know how the get the position of the center of my robot( rectangle)

    double x = transform.getOrigin().x();
    double y = transform.getOrigin().y();

Ao for the corner I need the rotation the yaw. tf::getYaw(transform.getRotation()); But how to get the conrner points , let we say A;B;C D of the robot(rectangle)

Any help?

Just like a comment. In my code to get the distance between the fixed point in the map and the center of the robot, center of the base link ( which is the centar of that rectangle I did not used a pose. I used this code. And think is ok. Schould I use pose or ok is with this?

 while (node.ok()){
    tf::StampedTransform transform;
    try{
      listener.lookupTransform("/base_link", "/door1",  
                               ros::Time(0), transform);
    }
    catch (tf::TransformException ex){
      ROS_ERROR("%s",ex.what());
    }

    double x = transform.getOrigin().x();
        double y = transform.getOrigin().y();
    double dist = sqrt(x*x + y*y);

And in launch file i labeled the door like this

<node pkg="tf" type="static_transform_publisher" name="door1" args="1 0 0 0 0 0 /odom/door1 10"/>

edit retag flag offensive close merge delete

Comments

That should be fine. But please open a new question for things that are not related to your original question.

Lorenz gravatar image Lorenz  ( 2012-08-21 02:35:13 -0600 )edit

ok. thanks

Astronaut gravatar image Astronaut  ( 2012-08-21 14:30:08 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
2

answered 2012-08-20 22:57:19 -0600

Lorenz gravatar image

I assume you want to get the corners of your robot in the map frame.

The easiest way to do that is to use tf's transformPose. Create for poses in the robot's base_link frame and transform all of them to map. Have a look at the following code snippet (assuming that you already have an instance of tf::TransformListener bound to the variable transform_listener):

tf::Stamped<tf::Pose> corner1(
    tf::Pose(tf::Quaternion(0, 0, 0, 1), tf::Vector3(0.30, -0.45, 0.0)),
    ros::Time(0), "base_link");
tf::Stamped<tf::Pose> corner2(
    tf::Pose(tf::Quaternion(0, 0, 0, 1), tf::Vector3(0.30, 0.45, 0.0)),
    ros::Time(0), "base_link");
tf::Stamped<tf::Pose> corner3(
    tf::Pose(tf::Quaternion(0, 0, 0, 1), tf::Vector3(-0.30, -0.45, 0.0)), 
    ros::Time(0), "base_link");
tf::Stamped<tf::Pose> corner4(
    tf::Pose(tf::Quaternion(0, 0, 0, 1), tf::Vector3(-0.30, 0.45, 0.0)), 
    ros::Time(0), "base_link");

tf::Stamped<tf::Pose> transformed_corner_1;
transform_listener.transformPose("map", corner_1, transformed_corner_1);
tf::Stamped<tf::Pose> transformed_corner_2;
transform_listener.transformPose("map", corner_2, transformed_corner_2);
tf::Stamped<tf::Pose> transformed_corner_3;
transform_listener.transformPose("map", corner_3, transformed_corner_3);
tf::Stamped<tf::Pose> transformed_corner_1;
transform_listener.transformPose("map", corner_4, transformed_corner_4);
edit flag offensive delete link more

Comments

And to get the vectors of this 4 corners. I mean correspond to map frame. So to get the 4 vectors. vector1= corne1 and corner 2: vector2= corner 2 and corner 3; vector3= corner3 and corner4 ; vector4= corner4 and corner 1.How to get these 4 vectors?

Astronaut gravatar image Astronaut  ( 2012-08-20 23:32:18 -0600 )edit

Just use transformed_corner_1.getOrigin() to get its position vector in the map frame.

Lorenz gravatar image Lorenz  ( 2012-08-20 23:47:52 -0600 )edit

You have asked that in a different question already and your calculation looked right. If I don't answer to a question I either don't have an answer or don't have time. Please understand that I provide support here in my free time so please don't ask new questions in comments that you already asked.

Lorenz gravatar image Lorenz  ( 2012-08-22 22:20:43 -0600 )edit

Sorry the last comment. But ho to get door point to make the distance calculation?? I mean with double x= transform.getOrigin().x() i will get the x coordinate of the door in map frame yes??

Astronaut gravatar image Astronaut  ( 2012-08-23 18:40:01 -0600 )edit

Can you help me with that please?? So with transformed_corner_1.getOrigin().x() and transformed_corner_1.getOrigin().y() and transformed_corner_2.getOrigin().x.() and transformed_corner_2.getOrigin(). y() I will get the x,y coordinate of the line segment 1 (made by the both corners of the robot

Astronaut gravatar image Astronaut  ( 2012-08-27 03:01:39 -0600 )edit

Please do not re-post comments. I might answer your question when I have time. Please read the support guidelines, in particular point 3.3.

Lorenz gravatar image Lorenz  ( 2012-08-27 03:08:21 -0600 )edit

Ok. Sorry. Did not meaned something bad. Just wanted to ask

Astronaut gravatar image Astronaut  ( 2012-08-27 03:10:28 -0600 )edit

Question Tools

Stats

Asked: 2012-08-20 19:30:34 -0600

Seen: 9,214 times

Last updated: Aug 21 '12