Yaw, pitch and roll help

Problems building or running the engine, queries about how to use features etc.
Post Reply
noj12345
Gnoblar
Posts: 2
Joined: Mon Jun 18, 2018 12:49 pm

Yaw, pitch and roll help

Post by noj12345 »

Ogre Version: :?:
Operating System: :?:
Render System: :?:

I am making a helicopter game that pitches / rolls / yaws by adding torque. The problem I have is that when I yaw over 90 degrees the getRoll() value jumps from 0 degrees to -180 degrees. I am using a PID controller to control the pitch and roll of the helicopter and the jump in roll throws off the control system causing the helicopter to crash.

Does anyone know anyway to fix this? Any help would be appreciated.

Code: Select all

Ogre.log (optional)
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5296
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1278
Contact:

Re: Yaw, pitch and roll help

Post by dark_sylinc »

I suggest you keep track of these 3 params externally.

Internally Ogre keeps the rotation as a quaternion. As such, getYaw/Roll/Pitch is extracted from the quaternion, and there are cases where there's multiple solutions available and one will be returned, which doesn't necessarily have to be the one you're expecting (such as Pitch = -90 Yaw = -90 being equivalent to Pitch = -90 Yaw = 270; You may notice 360 - 90 = 270).

While it may be possible to convert it to the scale you want, it's just easier and far less error prone to track them externally.
noj12345
Gnoblar
Posts: 2
Joined: Mon Jun 18, 2018 12:49 pm

Re: Yaw, pitch and roll help

Post by noj12345 »

Thanks for your reply.

So is it normal for the getRoll value to read 0 degrees when the helicopter is yaw'd between 0 - 89 degrees then when the helicopter reaches a yaw of 90 degrees the roll value starts reading -180? Keeping in mind that the roll position of the helicopter is the same.

Kind regards
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5296
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1278
Contact:

Re: Yaw, pitch and roll help

Post by dark_sylinc »

noj12345 wrote: Tue Jun 19, 2018 9:39 am So is it normal for the getRoll value to read 0 degrees when the helicopter is yaw'd between 0 - 89 degrees then when the helicopter reaches a yaw of 90 degrees the roll value starts reading -180? Keeping in mind that the roll position of the helicopter is the same.
Yes. These two monkeys in Blender are facing the same way, yet one has pitch = 0, yaw = 90, roll = -180; the other has pitch = -180, yaw = 90, roll = 0.



Like I said, there are multiple solutions that can result in the same orientation.
You can first yaw your head 90°, then pitch 90°; or you can first pitch 90° then roll 90°. The result will be the same yet the euler angles are different. Just like the squared root of 4 can be 2 or -2.
When the Euler information is converted to Quaternion, some information can be lost. So when you call getRoll, the result is technically correct, but it may not be what you expect.
Post Reply