Get robot global orientation

Requests regarding how to set up experiments in ARGoS.
Elendurwen
Posts: 41
Joined: Sat Aug 24, 2013 5:08 pm
Contact:

Get robot global orientation

Postby Elendurwen » Mon Jul 10, 2017 10:45 pm

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

Elendurwen
Posts: 41
Joined: Sat Aug 24, 2013 5:08 pm
Contact:

Re: Get robot global orientation

Postby Elendurwen » Tue Jul 11, 2017 12:45 pm

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.

pincy
Site Admin
Posts: 632
Joined: Thu Mar 08, 2012 8:04 pm
Location: Boston, MA
Contact:

Re: Get robot global orientation

Postby pincy » Wed Jul 12, 2017 2:53 pm

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.
I made ARGoS.


Return to “How to... ?”