0
$\begingroup$

Rosanswers logo

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


Originally posted by Astronaut on ROS Answers with karma: 330 on 2012-08-20

Post score: 1


Original comments

Comment by Lorenz on 2012-08-21:
That should be fine. But please open a new question for things that are not related to your original question.

Comment by Astronaut on 2012-08-21:
ok. thanks

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

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);

Originally posted by Lorenz with karma: 22731 on 2012-08-20

This answer was ACCEPTED on the original site

Post score: 2


Original comments

Comment by Astronaut on 2012-08-20:
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?

Comment by Lorenz on 2012-08-20:
Just use transformed_corner_1.getOrigin() to get its position vector in the map frame.

Comment by Lorenz on 2012-08-22:
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.

Comment by Astronaut on 2012-08-23:
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??

Comment by Astronaut on 2012-08-27:
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

Comment by Lorenz on 2012-08-27:
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.

Comment by Astronaut on 2012-08-27:
Ok. Sorry. Did not meaned something bad. Just wanted to ask

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.