1
votes

I have a 3D point in space, and I need to know how to pitch/yaw/roll my current heading (in the form of a 3d unit vector) to face a point. I am familiar with quaternions and rotation matrices, and I know how to represent the total rotation necessary to get my desired answer.

However, I only have control over pitch, yaw, and roll velocities (I can 'instantaneously' set their respective angular velocities), and only occasional updates on my new orientation (once every second or so). The end goal is to have some sort of PID controller (or three separates ones, but I suspect it won't work like that) controlling my current orientation. the end effect would be a slow (and hopefully convergent) wobble towards a steady state in the direction of my destination.

I have no idea how to convert the current desired quaternion/rotation matrix into a set of pitch-yaw-roll angular velocities (some sort of quaternion derivative or something?). I'm not even sure what to search for. I'm also uncertain how to apply a PID controller to this system, because I suspect there will need to be one controller for the trio as opposed to treating them each independently (although intuitively I feel this should be possible). Can anyone offer any guidance?

As a side note, if there is a solution that just involves a duo (pitch/yaw, roll/pitch, etc), then that works just fine too. I should only need 2 rotational degrees of freedom for this, but that is further from a realm that I am familiar with so I was less confident forming the question around it.

1
The problem is that Euler angles can't be interpolated easily. You can transform the quaternion / rotation matrix to Euler angles, which will give you three rotations that - applied once to the current orientation - result in the target orientation. However, applying the halved angled twice does not result in the same orientation. Therefore, the correct angular velocity would depend on the update rate. That's why you really should not use Euler angles for that. Are you sure that you can't work around that limitation of your API?Nico Schertler
It's an in-game C# script for Space Engineers. All I'm allowed to do is pitch, yaw, and roll the ship. XD I'm hoping someone will have an approximate answer at least. I just need to get it turning roughly in the right direction, and I can use a dot product with my current heading to the desired heading and feed that into a PID controller. The controller should do the rest.Suedocode
Wait, but I also don't want to apply pitch, then yaw, then roll (classic transform matrix). I want a combination of all velocities simultaneously. I believe in this case that half of a time step will still stop at half of the rotation that I want. Applying two halves should still result in a full rotation.Suedocode
You can't apply two transforms simultaneously. There is always an order. And precisely this is the problem of Euler angles. If you want a rough estimate, the difference quaternion (divide target orientation by source orientation) converted to Euler angles will do the job.Nico Schertler
I guess you are trying to model some spacecraft engines that performs pitch/yaw/roll. You can combine instant angular forces from pitch/yaw/roll. You should convert your pitch/yaw/roll into corresponding torques en.wikipedia.org/wiki/Resultant_force The torque can be described as vector parallel with rotation axis and magnitude of applied force. 1. convert pitch/yaw/roll into 3 corresponding forces 2. combine it 3. apply and integrate in local body frame.minorlogic

1 Answers

0
votes

First take a look if your problem can be solved using quaternion SLERP [1], which can let you specify a scalar between 0 and 1 as the control to move from q1-->q2.

If you still need to control using the angular rotations then you can calculate the error quaternion as Nico Schertler suggested. From that error quaternion you can use the derivative property of the quaternion (Section 4 of http://www.ecsutton.ece.ufl.edu/ens/handouts/quaternions.pdf [2]) to work out the angular rates required.

I'm pretty sure that will work, but if it does not you can also look at using the SLERP derivative (eq. 23 of http://www.geometrictools.com/Documentation/Quaternions.pdf [3]) and equating that to the Right-Hand-Side of the equation in source [2] to again get angular rates. The disadvantage to this is that you need code implementations for the quaternion exponentiation and logarithm operations.