# 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

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

edit retag close merge delete

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

Sort by » oldest newest most voted 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);

more

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?

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

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

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