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

How to know the direction that the Robot is pointing to from pose?

asked 2014-11-06 23:43:13 -0500

ish45 gravatar image

I am making a plot of the position and orientation of the robot in excel, I want to represent the direction of the robot in free space. But, I have a quaternion value from robot's pose like below:

pose = [0.23853423125670908, -0.00658252361852945, -0.058558705984261855]

How do I use this quaternion = -0.058558705984261855 and represent the direction of the robot?

Please if somebody has a clue. Its very urgent.

Thanks

edit retag flag offensive close merge delete

Comments

1

You should provide more information. Where do you get these values from? What robot are you talking about (something like turtlebot with x,y,theta or a arm with an end effector)? What is the root of you world coordinate system?

Rabe gravatar image Rabe  ( 2014-11-07 06:39:39 -0500 )edit

It is a mobile robot like turtlebot. The message type is Odometry obtained from nav_msgs.msg. I obtain pose from this message type. In this pose, the first two values are easting and northing. The third value is the yaw value. Can you tell me if its possible to know direction using yaw value?

ish45 gravatar image ish45  ( 2014-11-07 06:55:49 -0500 )edit
1

In that case, as dornhege said, the direction IS the yaw value. At some point you have defined a world reference system. Maybe it is the first position the robot is in, when you start the program. From this orientation, the yaw value tells you in which direction the robot is currently pointing.

Rabe gravatar image Rabe  ( 2014-11-07 07:57:29 -0500 )edit

Thanks. But how do I use yaw = -0.058558705984261855 and give it a direction in the form of an arrow? Seems difficult to me.

ish45 gravatar image ish45  ( 2014-11-07 09:31:28 -0500 )edit

I don't know how to plot in excel. Depending on how you define an arrow in excel, you might need to transform the value from rad to degree. But I guess for plotting in excel, this is the wrong forum to ask.

Rabe gravatar image Rabe  ( 2014-11-07 10:39:19 -0500 )edit

So, do you agree that the yaw value that I have mentioned is in radians?

ish45 gravatar image ish45  ( 2014-11-07 11:11:52 -0500 )edit

It most likely is. But you can check that very easily via moving the robot. Let it turn for 180degrees and check the values. Or keep the orientation and just move forward a bit, check which values change by how much.

Rabe gravatar image Rabe  ( 2014-11-07 11:18:30 -0500 )edit

If you know how to draw a line segment in Excel (is that possible?) and you just want to see which direction it's pointing, make the line start point (0, 0) and the end (cos(yaw), sin(yaw)).

Tom Moore gravatar image Tom Moore  ( 2014-11-07 12:34:19 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted
1

answered 2014-11-07 04:24:11 -0500

Rabe gravatar image

I think you might have mixed up some words (and since english isn't my native language, the following might not be 100% correct):

A quaternion always has 4 values. Since your "pose" has 3, it either is the position in xyz and you dereferenced the values wrong. Or it is the orientation in euler values, most likely in r(oll) p(itch) y(aw), which basicly is the value you are looking for in radians.

As I said, at this point I am not to certain if "pose" is either another word for "orientation" or for "position". But those values are definetly not a quaternion.

edit flag offensive delete link more

Comments

1

Yet another guess might be that it's x, y, theta.

dornhege gravatar image dornhege  ( 2014-11-07 05:46:10 -0500 )edit

You are right. Quaternion are 4 values. Do you know how to know the direction of the robot or the heading from the these 4 quaternion values?

ish45 gravatar image ish45  ( 2014-11-07 05:47:26 -0500 )edit

You are right that value is the yaw value. Do you know how to convert this yaw value and know the direction that the robot is pointing towards?

ish45 gravatar image ish45  ( 2014-11-07 05:58:53 -0500 )edit

If it is a yaw, the robot is pointing in the direction of the yaw value.

dornhege gravatar image dornhege  ( 2014-11-07 06:41:43 -0500 )edit
0

answered 2014-11-07 08:18:33 -0500

Tom Moore gravatar image

Here's a sample nav_msgs/Odometry message, the first part of which is a geometry_msgs/Pose message:

header: 
  seq:        239
  stamp: 
    secs: 1408542253
    nsecs:  730130796
  frame_id: odom
child_frame_id: base_link
pose: 
  pose: 
    position: 
      x: 19.4294389
      y: -1.4772684
      z: -0.6923008
    orientation: 
      x: 0.01773404
      y: 0.01089619
      z: -0.0490339
      w: 0.99858021
  covariance: [0.00145422, 0.00000001, 0.00000018, -0.0000000, 0.00000000, 0.00000000, 0.00000001, 0.00145451, -0.0000003, -0.0000000, -0.0000000, 0.00000000, 0.00000018, -0.0000003, 0.01903145, 0.00000000, -0.0000000, 0.00000000, -0.0000000, -0.0000000, 0.00000000, 0.00000099, 0.00000000, 0.00000000, 0.00000000, -0.0000000, -0.0000000, 0.00000000, 0.00000099, -0.0000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, -0.0000000, 0.00000099]

The part you need is the "orientation." It is represented as a quaternion instead of Euler angles. To get the Euler angles, you need to carry out a conversion. If you want to do it with C++, you can do something like this:

tf::Quaterion quat;
tf::quaternionMsgToTF(msg->pose.pose.orientation, orientation);
tf::Matrix3x3 orTmp(quat);
orTmp.getRPY(roll, pitch, yaw);

If you're doing it in Excel, you'll need to carry out the conversion yourself. If you're simply after the robot's heading, you want the "yaw" value.

edit flag offensive delete link more

Comments

Thanks for your answer. Now, I got this yaw value = -0.058558705984261855. How do I create an arrow in the direction pointed by this yaw value. Which direction does this point to. Assuming initially, the robot had yaw = 0. I have never attempted anything like this before.

ish45 gravatar image ish45  ( 2014-11-07 09:33:18 -0500 )edit

Sorry, just making sure I understand you: did you fill out your Odometry message so that the heading (yaw) is stored in the Z position variable? Your "pose" should have (X, Y, Z) position. The orientation is defined using the (X, Y, Z, W) quaternion.

Tom Moore gravatar image Tom Moore  ( 2014-11-07 12:29:22 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2014-11-06 23:43:13 -0500

Seen: 3,102 times

Last updated: Nov 07 '14