# position and orientation of the robot

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{
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

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

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)),
tf::Stamped<tf::Pose> corner2(
tf::Pose(tf::Quaternion(0, 0, 0, 1), tf::Vector3(0.30, 0.45, 0.0)),
tf::Stamped<tf::Pose> corner3(
tf::Pose(tf::Quaternion(0, 0, 0, 1), tf::Vector3(-0.30, -0.45, 0.0)),
tf::Stamped<tf::Pose> corner4(
tf::Pose(tf::Quaternion(0, 0, 0, 1), tf::Vector3(-0.30, 0.45, 0.0)),

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

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: