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

convert the yaw Euler angle into into the range [0 , 360].

asked 2014-03-18 06:59:36 -0500

underwater gravatar image

Hi everyone,

I used the following code to get the yaw Euler angle:

// Convert quaternion to RPY.
  tf::Quaternion q;
  tf::quaternionMsgToTF(imu_msg->orientation, q);
  tf::Matrix3x3(q).getRPY(roll, pitch, yaw);

I get the Euler angle varying from [0,PI] and [-PI, 0]

I need rotation angles in the range of 0 to 360. Is it possible to get that directly?

Thanks in advance

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted
3

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

ahendrix gravatar image

You can't get angles in degrees directly from the available library calls, but it's pretty trivial to convert radians to degrees:

double yaw = ...; // however you want to get yaw.
double yaw_degrees = yaw * 180.0 / M_PI; // conversion to degrees
if( yaw_degrees < 0 ) yaw_degrees += 360.0; // convert negative to positive angles
edit flag offensive delete link more

Comments

nice very thanks

underwater gravatar image underwater  ( 2014-03-18 22:50:04 -0500 )edit

This answer was some time ago, but is this not incorrect?

PEP 103 specifies that yaw measured from the x-axis (i.e. in a geographic frame from East) and is positive CCW. Heading of course is measured from the y-axis, positive CW.

vschmidt gravatar image vschmidt  ( 2017-12-03 18:33:06 -0500 )edit
4

answered 2014-03-18 07:38:11 -0500

You can try the angles package which provides C++ api calls for angle normalization, conversions between radians and degrees, and finding minimum angular distance.

edit flag offensive delete link more

Comments

thanks for your answer, please can you tell me how to use the angles package? I am not succeed.

underwater gravatar image underwater  ( 2014-03-18 22:53:55 -0500 )edit

Without more info about how you are not succeeding, it's hard to help. You need to (1) include angles in your manifest.xml or package.xml (2) #include <angles angles.h=""> (3) Run code like "yaw = angles::to_degrees(angles::normalize_angle_positive(yaw));"

jarvisschultz gravatar image jarvisschultz  ( 2014-03-19 05:55:36 -0500 )edit

Sorry for the bad formatting of point (2).... not my fault. See [bug report](https://github.com/ros-infrastructure/answers.ros.org/issues/65)

jarvisschultz gravatar image jarvisschultz  ( 2014-03-19 05:57:18 -0500 )edit

very thanks

underwater gravatar image underwater  ( 2014-04-01 04:50:12 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2014-03-18 06:59:36 -0500

Seen: 19,739 times

Last updated: Mar 18 '14