1

I'm modeling a rocket with PID controllers for thrust vectoring.

The PID controllers take in attitude errors as input, then output engine gimbal actuator commands.

The attitude errors are individual roll, pitch, and yaw angles that I obtain from error rotation matrices coming from guidance calculations.

Everything in guidance is based on rotation matrices. The individual errors each feed into a separate PID controller---one for roll, one for pitch, one for yaw. Roll, pitch, and yaw are each defined in the rocket's main frame.

This all works great, but I'm bothered by my conversion from rotation matrix to roll/pitch/yaw. The conversion is approximate and works well up to ~10 deg errors. I got it from an old Apollo-era paper I found in the NASA repository, but which I've since lost track of.

I'm wondering: is there a way to pass the error rotation matrix directly to a single PID controller and have it output a vector of roll/pitch/yaw commands (in the rocket's axes)?

  • Why not use quaternions? – Paul May 06 '21 at 01:40
  • Because I committed to rotation matrices early in the model. I’m looking to streamline what I have (by using my error rotation matrix directly as input to my PID controllers), not change it to something else. In another life, maybe. This model’s been a hell of a lot of work. –  May 06 '21 at 02:08
  • 1
    If you want something better than what you are using now, step 1 is to post what you are using now. Use MathJax for equations. – uhoh May 06 '21 at 22:45
  • I’m not asking for feedback on my model. Nor am I asking for suggestions on how to improve it. My question is very specific: “Is there a way to pass the error rotation matrix directly to a single PID controller and have it output a vector of roll/pitch/yaw commands?” The answer should be independent of any modeling I might have done. –  May 06 '21 at 23:27
  • 1
    Can you add links / references to some literature that you are following ? Have you searched for literature with keywords "PID control on rotation matrices" or "PID control on SO(3)" ? – AJN May 08 '21 at 05:42
  • Error rotation matrix is not enough for PID. You generally need velocity information also as an input PID. Are you planning on numerically integrating the 9 elements ? From my experience, it is pain in the. – AJN May 08 '21 at 05:45

1 Answers1

1

Error rotation matrix can be transformed to a required "angular velocity" (in body frame) using the inverse of the exponential map (I think it would be called a log map then).

The exponential and log mentioned are matrix exponential and matrix logarithm. The matrix logarithm is a costly operation, so it needs to be approximated for real-time implementation.

This "angular velocity" is a vector. The proportional part of the PID control can then be driven from this vector (one component each for each axis).

An alternate way to think about this is to remember that you can extract the eigen vector from the error rotation matrix to get the axis of rotation required to bring it to the reference. An angular velocity about this axis (with the correct sign) will bring the body towards the reference. The angle to be rotated can be used as the magnitude of error for computing the proportional term.

AJN
  • 1,000
  • 1
  • 6
  • 12
  • 1
    Above answer mentions only a choice for the proportional term. 1 it may not be the best choice when a velocity error also exist. 2 ID part of the PID is not covered. The D part may be something as simple as directly using the angular velocity. 3 I part would be even more complicated, I think. – AJN May 08 '21 at 05:40
  • Ah! This is useful! I actually just found out that any rotation matrix Q can be expressed as the exponential of a skew matrix C, then approximated to first degree using the first two terms of a Taylor Series expansion---which gives exp(C) ~ I + C, where I is the identity matrix. The instantaneous attitude error is then ~(I + C) - I ~ C, which works for small errors (e.g., <10 deg). So the skew symmetric matrix C seems a path forward. –  May 08 '21 at 14:11
  • And as it turns out, the elements of the skew matrix C give the instantaneous errors about the x, y, and z axes---in the small-angle approximation assumed in the Taylor series expansion above. And those elements happen to be exactly what I've been using as errors all this time---just pulling them from my rotation matrix Q and feeding them separately to my roll, pitch, and PID controllers, a strategy I got from an Apollo-era navigation paper I've now lost track of, but which did just that, without mention of skew matrices, and probably because they were so computationally constrained. –  May 08 '21 at 14:18
  • This is so cool, because I can see the parallel between what I've been doing (which has worked very well) and what I would like to do (using rotation matrices directly). At a minimum, it sheds a new light on why this small-angle approximation that I picked up from that Apollo-era paper works. –  May 08 '21 at 14:19
  • But yeah, exact derivatives and integrals of an exp(C) matrix get convoluted fast, it seems, so the Taylor series approximation seems the only practical way to deal with them. And it seems that the derivative of a matrix Q is the matrix of element derivatives, dot(q_i), and that the integral of a matrix Q is the matrix of element integrals, int(q_i), which I guess explains why differentiating and integrating the elements of my approximate error vector [qx qy qz] has worked fine---because that vector is derived from the skew matrix which can be Taylor-expanded, then diff'd/int'd? –  May 08 '21 at 14:56
  • I wish I was a mathematician now. There are nuances to all of this, and I'll probably only find out about them over time. But at least I think I'm starting to understand intuitively a little of what's going on... I'd be happy enough if I could convert my rotation matrix Q to the skew symmetric matric C = log(Q) efficiently (instead of having to manually construct C from the off-diagonal elements of Q as I do now), and if I could do my derivatives/integrals directly on that skew matrix (instead of on the [qx qy qz] elements that you can extract from that skew matrix) –  May 08 '21 at 15:01
  • Search for the terms i mentioned in the comments to your question. People have already researched and figured out reasonable ways if IIRC. However, changing to quaternion will not take more time and effort than what you may have to spend on getting good pid laws from rotation matrices IMO. – AJN May 08 '21 at 15:16
  • Aside from the long pipeline of rotation transforms I already have in place to convert between various frames (ECI, ECEF, topocentric, pad frame, velocity frame, etc), the trouble is that... by now I can look at a rotation matrix and know intuitively what it means, and I can fairly quickly put together a rotation matrix where I need one, and do so in different ways (from rotation angles, from vectors, from other rotation matrices). It took me months to get all of this right, and for those first months my life was hell because I was getting it wrong half the time. I can't go back to that. –  May 08 '21 at 15:21
  • I do wish I started with quaternions, though. But now I'm committed to rotation matrices. –  May 08 '21 at 15:22