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.0Sat, 10 Oct 2020 23:35:16 -0500Quaternions in Gazebohttps://answers.ros.org/question/199372/quaternions-in-gazebo/Hi, I'm trying to run reinforcement learning experiments using the gazebo simulator. The simulator provides the orientation of the robot in the form of a quaternion (x,y,z,w). I know that each of those components is an element of real numbers. But is there a range of values that those components can take on? Since I need to know the range of values in order to discretize the state space.
ThanksFri, 12 Dec 2014 09:06:11 -0600https://answers.ros.org/question/199372/quaternions-in-gazebo/Answer by Mark Rose for <p>Hi, I'm trying to run reinforcement learning experiments using the gazebo simulator. The simulator provides the orientation of the robot in the form of a quaternion (x,y,z,w). I know that each of those components is an element of real numbers. But is there a range of values that those components can take on? Since I need to know the range of values in order to discretize the state space.</p>
<p>Thanks</p>
https://answers.ros.org/question/199372/quaternions-in-gazebo/?answer=363181#post-id-363181First be aware what a quaternion is, a fairly concise representation of an arbitrary rotation, using four components, *qx*, *qy*, *qx*, and *qw*. These represent two values: 1) an axis of rotation, as a vector <*x*, *y*, *z*>, and 2) an angle of rotation *theta* around that vector, in radians, using a right-hand rule. (Point your right thumb along the vector pointing away from the origin, and curl the fingers of your right hand. That direction is a positive rotation.) Those two values are encoded into four components like this:
qw = cos(theta/2)
qx = x * sin(theta/2)
qy = y * sin(theta/2)
qz = z * sin(theta/2)
Since the only thing that matters about the axis vector is its direction, it is usually normalized so that it has unit length. That means that each component of the quaternion can have a value from -1 to +1. I don't believe a quaternion you get from ROS is guaranteed to be normalized. There is a *normalize()* method in the *Quaternion* class to ensure this, however.Sat, 10 Oct 2020 23:35:16 -0500https://answers.ros.org/question/199372/quaternions-in-gazebo/?answer=363181#post-id-363181