Get robot global orientation
Posted: Mon Jul 10, 2017 10:45 pm
by Elendurwen
I was wondering how I can get the rotation of the robot that is on the floor (footbot). E.g. if the robot is rotated north, I would get 0, if south, I would get 180, etc.
I have
Code: Select all
footBotEntity.GetEmbodiedEntity().GetOriginAnchor().Orientation
but that returns a Qaternion, that I don't know how to use to get a single number in radians.
Thanks!
Lenka
Re: Get robot global orientation
Posted: Tue Jul 11, 2017 12:45 pm
by Elendurwen
Ok to answer my question: Having one more look at the CQuaternion - I noticed this function:
Code: Select all
CRadians xAngle;
CRadians yAngle;
CRadians zAngle;
footBotEntity.GetEmbodiedEntity().GetOriginAnchor().Orientation.ToEulerAngles(xAngle, yAngle, zAngle);
The number I wanted was the xAngle.
Re: Get robot global orientation
Posted: Wed Jul 12, 2017 2:53 pm
by pincy
Correct! The function is actually CQuaternion::ToEulerAngles(zA,yA,xA), where zA is the rotation around Z (the vertical axis), and yA and xA are the rotations around Y and X respectively. This order is because rotations in ARGoS are actually executed this way: first z, then y, then x.