ROS Answers: Open Source Q&A Forum - RSS feedhttps://answers.ros.org/questions/Open source question and answer forum written in Python and DjangoenROS Answers is licensed under Creative Commons Attribution 3.0Wed, 29 Aug 2018 12:13:46 -0500Angle between two orientationshttps://answers.ros.org/question/301988/angle-between-two-orientations/There are two orientations given, as intrinsic yaw-roll-pitch (rzyx).
How to calculate the angle between the "Z" axes of them?
Converting the orientations to quaternions or to anything else is allowed.okalachevWed, 29 Aug 2018 12:13:46 -0500https://answers.ros.org/question/301988/A problem about the conversion from Euler angle to quaternionhttps://answers.ros.org/question/249058/a-problem-about-the-conversion-from-euler-angle-to-quaternion/Hi, all. we are trying to construct a 3D scanning system to implement 3D mapping algorithm. Its hardware system is showed in following figure : ![image description](/upfiles/14804590479821701.png).
A Hokuyo laser(UTM-30LX) is mounted on a plate which is rotated by a Dynamixel([MX-28R](http://support.robotis.com/beta/en/product/dynamixel/mx_series/mx-28.htm)). The Dynamixel works in back_and_ forth way. Its rotation angles' range is between -1.57 and 1.57, i.e. [-90° 90°] .
The tf tree is showed in following figure : ![image description](/upfiles/14804597194694478.png).
The frame_id "Laser" is the local scanning coordinate of Hokuyo laser. The frame_id "HN07_N101" is the local rotating(in back_and_forth way) coordinate of MX-28R. The frame_id "BaseLink" is the base_link coordinate of the system. The joint between "Laser" and "HN07_N101" is fixed. But there is a revolute joint between "HN07_N101" and "BaseLink".
The frame “HN07_N101” is rotated around its own "z" axis which is the blue axis in above figure. In the coordinate of "BaseLink", the origin of "HN07_N101" is (0.22375, 0, 0.1367), the initial orientation is (0.5, 0.5, 0.5, 0.5), as the left part of above figure shows.
As the Dynamixel rotating the Hokuyo laser, it is necessary to compute the coordinate transform between parent frame "BaseLink" and child frame "HN07_N101". The dynamixel motor sends [JointState](https://github.com/arebgun/dynamixel_motor/blob/master/dynamixel_msgs/msg/JointState.msg) message which contain the current rotating angle around "Z" axis in radians.
However, when I run my project, the transform between pararent "BaseLink" and "HN07_N101" is ***
**not smooth.**
***. Although there is no jump in the value of Dynamixel's msg, both the frame "HN07_N101"(including its child frame "Laser") and the 3D models of Hokuyo and Dynamixel alway flicking. The so called "flicking" is, while the frame "HN07_N101" is rotating, the green "y" axis and the red "x" axis suddenly switch positions with each other and recover.
I think the flicking 3D models displayed in rviz means that there is problem in the transfrom between "BaseLink" and "HN07_N101". But I don't know where the problem is.
Is the problem at the conversion from Euler angle (the current_pos in Dynamixel's msg) to the quaternion ( the variable "q" in above code) ?
Looking forwards any valuable advices. Thank you very much!scopusTue, 29 Nov 2016 17:30:09 -0600https://answers.ros.org/question/249058/How should RPY converted from an IMU look like?https://answers.ros.org/question/212100/how-should-rpy-converted-from-an-imu-look-like/What angles should be there?
0°-360° ?
-180° - 0° - 180° ?
Or something else?
I am for example using this code and I am getting weired results...
void cb_imu(const sensor_msgs::Imu::ConstPtr &msg)
{
double roll, pitch, yaw;
tf::Quaternion q;
tf::quaternionMsgToTF(msg->orientation, q);
tf::Matrix3x3(q).getRPY(roll, pitch, yaw);
}
ROS_INFO_STREAM("RPY: "<<roll*180.0/M_PI<<" "<<pitch*180.0/M_PI<<" "<<yaw*180.0/M_PI);
My Results of YAW show two times zero, for one half of the circle the values are negative (go up to -40°) and for the other half the same for positive values.
Regards,
Christiancyborg-x1Thu, 25 Jun 2015 04:18:30 -0500https://answers.ros.org/question/212100/How to correct the "yaw" behavior of a quadrotor when crossing the angles' limits?!?!https://answers.ros.org/question/199989/how-to-correct-the-yaw-behavior-of-a-quadrotor-when-crossing-the-angles-limits/Hi guys,
My quadrotor has a strange behavior ([video](https://www.youtube.com/watch?v=Y6Trr7d4iro)) when it turns around 180° (the returned value of atan2()). After investigating for hours I 'm pretty sure I found what the problem.
Referring to this [tutorial](http://wiki.ros.org/urdf/Tutorials/Using%20urdf%20with%20robot_state_publisher) as a reference I realized that the angle around the vertical axis (which in my quadrotor is exactly the same structure, see my code [here](http://pastebin.com/dzRp42m3) from line 34) , in the tutorial expressed as *angle* :
tf::createQuaternionMsgFromYaw(angle+M_PI/2);
is simply added by a small quantity calculated at each pass and doesn't take care of the fact that for angles bigger than 180° (or smaller than -180°) the corresponding quaternion has the same value 8or the same orientation if you prefer). In other words, the method `tf::createQuaternionMsgFromYaw` is going to calculate the correct value even if the angles is crossing those *limits*.
The nagle in my application jumps about the Z-axis from the positive sector to the negative (and viceversa) because the returned value from atan2() is outputting *right* values but with the *wrong* interpretation. As you can see, in the following output (all values are in degree for simplify):
...
Yaw: -164.3665
Yaw: -174.0903
Goal reached
Moving to the 3 waypoint
Yaw: 172.8751
Yaw: 161.7627
Yaw: 153.9304
Yaw: 148.2633
Yaw: 144.0085
...
is clear that the quadrotor must move its nose from -174° to + 172°. But instead of to take the shortest way to to that, it turns counterclockwise along the longest path.
I think that this is the normal behavior of `tf::createQuaternionMsgFromYaw()` which doesn't consider the shortest way to reach the next angle, but it output the corresponding quaternion to that value 8could I have a confirmation about that?)
**Now:** one could say: "get rid of an absolut coordinate system for your quadrotor and calculate the angle about the Z-axis as a variable, which is going to be changed by small increments every time your code runs a loop...exact like in the tutorial you mentioned!!!"
That's what I thought at the beginning, but I have the problem that all the position and attitude controller for quadrotor are using a fixed coordinate system for their calculation:
![image description](/upfiles/1419358451960307.png)
Resume:
I want to correct the behavior of my quadrotor about the Z-axis.
To do that I could:
- Rewrite all my controllers for attitude and position to use a body coordinate system and treating the yaw a variable which increments by small changes in orientation without taking care about the limits I said above -> I ve really no idea how to rewrite my code to use such a *variable change* and I think it would lead to new problems;
- Use two "yaws": one absolut for the controllers and the other one "locally" which is going to be passed to the method `tf::createQuaternionMsgFromYaw()`. As above...I ve no idea how to implement it in my code;
What would you do guys? Could you me point to the right direction or give my the most used solution?
PS: Even mapping the output of atan2() to 0-360° doesn't change anything. It *moves* simply the problem between 0 and 360°
I hope my question is clear. If not tell me please and I'll update the question.
Merry Christmas !!
RegardsAndromedaTue, 23 Dec 2014 12:24:52 -0600https://answers.ros.org/question/199989/How do I get the angle in radians (0 to 2pi) from a quaternion?https://answers.ros.org/question/41392/how-do-i-get-the-angle-in-radians-0-to-2pi-from-a-quaternion/I'm trying to get the angle of a position model in Stage in radians from the Odometry message published to the "odom" topic.
This is how I've done it:
theta = 2 * asin(msg.pose.pose.orientation.z);
This sort of works in getting the angle in radians, but whenever the angle is below the x axis it gives me a negative angle.
Is there anyway of getting the angle in radians going from 0 to 2pi, starting from the positive x axis going anti-clockwise?
Thanks.ClefairyTue, 14 Aug 2012 07:55:17 -0500https://answers.ros.org/question/41392/Getting Turtlebot Headinghttps://answers.ros.org/question/30926/getting-turtlebot-heading/We are trying to get the heading of our turtlebot. We can get the Quaternion data about the robot's pose but want to convert to a simple euler angle. Is there C++ ROS code that is already available that supports this?zlalanneSat, 31 Mar 2012 09:56:35 -0500https://answers.ros.org/question/30926/