Considering that the STorM32 gimbal controller project is now many years old, this is something I really should have written up long ago. But I didn’t. I recently came back to the topic while working on some stuff and constantly required it as a reference. So, here it is. 🙂
This article will start with presenting a model which may look perfectly reasonable, and which indeed provides valuable insight. However, it is fundamentally flawed and hence does not qualify as „simplest and reasonable“ model. The improved model is the main topic of the article, and will be presented in the subsequent chapters.
It is important to properly state what the goal of using a gimbal is. Obviously, the goal is to stabilize the orientation (attitude) of a camera, and to do so in the presence of disturbances. All clear, right. There are however different sources of disturbances, and we have to distinguish them properly. One type of disturbance are forces/torques acting on the camera or gimbal structure in general, such as wind, and so on. Another type is a motion of the gimbal base. In fact, that’s what we do mostly with a gimbal, namely to move around the gimbal base and yet having a steady camera. So, the immediate conclusion is:
The primary goal of a gimbal is disturbance rejection, and the rejection of movements of the gimbal base in particular.
Sure, we also may want to change the camera’s orientation through some controls such as joysticks or serial commands. But this is not the primary reason why we use a gimbal; we use it to have a stabilized camera in the wake of gimbal-base movements. As simple as it is, this is a most crucial insight when we want to talk about gimbal performance. I want to add that depending on the application also the torque disturbances can be very relevant, such as in planes.
We will consider only a 1-axis gimbal, because only then the model is really simple. For 2- and more so 3-axis gimbals the dynamical equations are so complicated even in simple approximations that any analytical treatment becomes cumbersome (see link). Even worse, as I just stressed, we need to also include the dynamics of the gimbal base if we want to understand disturbance rejection, which would add 3 more „axes“ and we would face a 6-axis robot system! The general problem is then really just intractable analytically (at least for mortals like me). I could not find any literature on gimbals which would consider the „moving base“ situation or provide approximations one could deal with, and I myself for sure was also not able to come up with approximate model equations. Hence, 1-axis gimbal only. All we can do is to hope that some conclusions may somehow be applicable to a 3-axis gimbal.
2. Simplest, but flawed, Gimbal Model
2.1. Dynamics, 2.2. Control Law, 2.3. Why the model is flawed
3. Simplest Reasonable Gimbal Model
3.1. Dynamics, 3.2. Check if the model makes sense
4.1. Control Law, 4.2. P Controller, 4.3. D Controller, 4.4. PD Controller, 4.5. Effect of an I Term, 4.6. Torque Disturbances
5. Concluding Words
Before we start, let’s write down some general results.
Thanks to the simple geometry of the gimbal, we easily come up with this geometrical relationship which describes the gimbal:
: tilt of the gimbal camera arm and camera
: tilt of the gimbal base
: angle of the motor at the joint
We also will need a model for the motor. Here we have to differentiate how the motor is driven, we consider full FOC, simple FOC, and sinusoidal drive, which are described by these motor models:
: motor control input
: motor constant
: motor friction
The equations were written here such as to make the look as equally as possible; the and constants can be quite different for the different drives however. For the details please see Field Oriented Control: To FOC or not to FOC. For instance, for full FOC we would have , , and .
It is interesting to note that for the simplified FOC and sinusoidal drives , i.e., these drive schemes produce a „flux friction“, which appears in addition to any mechanical friction.
The additional term for the sinusoidal drive makes this drive very different, and is the origin of all the difficulties with it. You can find a couple of articles discussing this on my pages.
2. Simplest, but flawed, Gimbal Model
Besides the gimbal equation and the motor model we need a model for the gimbal dynamics, which should include the motor torque, mechanical friction in the joint, and so. The obvious model is
: inertia of the camera gimbal arm including the camera
: viscous friction coefficient
: torque produced by the motor
: torque disturbance acting on the camera
We can combine this with the motor equation to define the process transfer function:
Please note the fundamental difference between these two transfer functions.
1.2. Control Law
All we need to do now is to write down our control law, and close the feedback loop:
: control input, setpoint
This is a pretty ordinary control law. However, it also clearly shows us what makes discussing a gimbal different to essentially all other systems we typically deal with, such as flight controllers, servo controllers, and so on. In the latter cases the primary objective is the response with respect to the control input , i.e., the tracking behavior. In the case of a gimbal the primary objective is the response with respect to the gimbal base , i.e., the output disturbance rejection! Given that the widely known tuning rules are targeted at optimizing the tracking, we also realize that these won’t directly apply here. Lastly, we learn that torque disturbances enter as input disturbances.
So, this simple model has given us two important insights:
• Tuning a gimbal means tuning the controller for best (output) disturbance rejection, not tracking.
• The widely known tuning rules do not obviously apply to the case of a gimbal.
2.3. Why the model is flawed
You may now be surprised to hear that the above model is fundamentally flawed. I will demonstrate this by a simple Gedanken experiment. We will learn that the above model is in fact only valid if is constant, i.e., when the gimbal base is not moving (or very slowly moving). But wasn’t this exactly what we wanted to study, a moving gimbal base?
In order to see the flaw, let’s consider a gimbal which is connected at the joint only through a bearing, i.e., there is no motor and no motor torque. Clearly, if the friction in the bearing is exactly zero, then the camera should not move at all when we move (tilt) the gimbal base. This is so because the camera has inertia, . In this situation, since there are no torques acting on the camera, the equation of motion for the camera would be
Now let’s assume that there is some friction in the bearing. Clearly, now we expect that we can tilt the camera by tilting the gimbal base. However, we also expect that this depends on how fast we tilt the gimbal base. If we would tilt the gimbal base very fast, we expect that the camera should not move (or not move much), that is
In contrast, if we would tilt the gimbal base very slowly then the camera should nicely follow, that is
Let’s see if the above model can describe that. We set and arrive at
However we also have and thus
That is, the model predicts that the camera is following the gimbal base when it is tilted! According to our Gedanken experiment this corresponds to the case when the gimbal base is tilting only very slowly. This will be shown strictly below. We may also get an idea of what the problem is, namely that there is and not on the left-hand-side of the equations. We can double-check by also allowing friction:
which implies and which is equally faulty.
3. Simplest Reasonable Gimbal Model
There are various ways to derive the correct dynamic equations. For instance, we could open a robotics text book and look up the results for a „two-link planar elbow manipulator“, and adapt them to our case. This may give us a certain level of satisfaction and confidence in the result, but let’s try to derive it more straight forwardly (it will of course agree with that obtained from using the robotics theory machinery).
Let’s first note that we are not interested in the dynamics of the gimbal base (or gimbal arm connecting gimbal base and motor), but only in the dynamics of the camera. That is, the appropriate starting point is Newton’s equation for the camera:
where are all torques acting on the gimbal. Friction in the joint is clearly related to the relative motion of the two gimbal arms, and thus adds a term . Note that this produces a coupling between camera and gimbal base. Disturbance torques which act on the camera are obviously incorporated by adding a term . Accounting for the effect of the motor might be more confusing, as it exerts torques on both gimbal arms. However, we can apply Newton’s „actio = reactio“ here to find that the motor torque acts on the camera with and on the gimbal base with (Newton’s 3rd law applies since there are no other forces/torques in our scenario). Thus, there will be a torque on the gimbal base due to the motor, but this is not what we are interested in. So, all we need to do is to add a term to the torque acting on the camera. Thus:
3.2. Check if the model makes sense
Let’s check if this result can describe our above Gedanken experiment. First, we again assume zero friction in the joint, i.e., set . We obtain
This is exactly what we were expecting. The camera does not tilt irrespective of the tilting of the gimbal base. Perfect. Let’s also check the case with friction in the joint. Now we obtain
which we rewrite as
This makes perfect sense. When we tilt the gimbal base slowly, which corresponds to , we obtain , i.e., the camera follows the gimbal base, as we expect it. When we tilt the gimbal base very fast, which corresponds to , we obtain , i.e., the camera does not tilt but stays steady due to its inertia, also as expected. Perfect.
Moreover, we see that the behavior corresponds to that of a low-pass filter of 1st order, with a characteristic frequency . Also this makes perfect sense: For a larger friction we expect that the gimbal base needs to be moved more abruptly in order keep the camera steady or that the camera will follow better at slow gimbal base movements. Vice versa, for a larger inertia of the camera we expect the opposite trend. In other words, it is the ratio which matters, and it should be as small as possible for this simple mechanical (non-motorized) gimbal. Which makes perfect sense.
4.1. Control Law
Again, all we need to do is to use the control law and close the feedback loop:
Let us write it more compactly as
: tracking response
: gimbal-base motion rejection
: torque disturbance rejection
The process transfer functions for the various drives are defined as before.
This is interesting: The tracking behavior as well as the input disturbance rejection of is the same as for the simple flawed model. However, the output disturbance, i.e., response to , is now additionally low-pass filtered.
Also noteworthy, the friction term enters now, and not only as for the motor-less gimbal. That is, FOC control has some advantage here over the simplified FOC and sinusoidal drives (recall, the friction should be as small as possible, and full FOC does not add „flux“ friction).
4.2. P Controller
Let us understand the behavior with a P controller:
For the gimbal-base motion rejection, assuming a FOC scheme, we obtain
This can be nicely rewritten by using the characteristic frequency , which we found before, and the resonance frequency , and normalizing frequencies to :
For or open-loop we get the behavior of a motor-less gimbal with just a joint and friction, i.e., the situation which we considered in the above. It is described by a 1st-order low-pass behavior with a characteristic frequency , i.e., gimbal-base motions are rejected only at frequencies above .
For , the transfer function corresponds to that of a 2nd-order band pass, with the properties
That is, thanks to the motor and controller, gimbal-base motions are now indeed rejected at low frequencies, which is exactly what we want. We can push this range up by increasing the control gain . However, we cannot push it up too high, of course, since the control loop would become unstable. Also note that the maximum amplitude of the transfer function is always one. There is thus always a frequency range, around the resonance frequency, where there is no disturbance rejection at all, which is certainly undesired. One further can note that the band width is constant and that the quality factor thus increases with , i.e., the transfer function becomes sharper and sharper.
At high frequencies, above the resonance frequency, the roll-off is , similar as for the non-motorized gimbal. That is, at these frequencies the motor and controller are not helping in any way and gimbal-base motion rejection is provided only by the ratio of friction vs camera inertia, .
4.3. D Controller
We now choose a D controller:
You may find this surprising, since D controllers are not usually used, and indeed, the fact that we consider it should not be taken as indication that it is suggested to be used.
The gimbal-base motion rejection, again assuming a FOC scheme, now becomes
This is a 1st-order low pass, like for the gimbal with no motor. However, the amplitude is reduced by a factor , which means improved gimbal-base motion rejection. Unfortunately, this comes at a cost, namely the characteristic frequency is increased to . That is, the D controller actually worsens the gimbal-base motion rejection at higher frequencies.
At this point, lets emphasize again that we consider here the response concerning gimbal-base motions or . The controller stability is however given by the response with respect to the setpoint or tracking response function , respectively. We should not forget that we always have to also investigate this response function, before we get too excited about what we can achieve.
4.4. PD Controller
Now we choose a PD controller:
For the gimbal-base motion rejection, again assuming a FOC scheme, we obtain
This is also a 2nd-order band-pass as for the P controller. That is, adding the D-term has not fundamentally changed the transfer function as compared to that of a pure P controller. The bandwidth is somewhat affected, but the resonance frequency in fact not. The most important effect is that the resonance amplitude is reduced:
That is, the main effect of the D-term is to suppresses the resonance amplitude, which allows us to improve the gimbal-base motion rejection at all frequencies. This is similar to what we have found for the D controller. Fortunately, in contrast to the D controller, the behavior at higher frequencies is however not negatively affected, but rather improved. Indeed, the resonance frequency is not affected, , and still is determined by only. Furthermore, the band width increases to , i.e., the quality factor becomes smaller and the transfer function less sharp. This also helps us when pushing the tuning towards higher frequencies.
4.5. Effect of an I Term in the Controller
As always, we can now also add an I-term to the controller, i.e., a term of the form . For as long as the I-term does not become too large, its effect is easy to understand: It simply adds an additional roll-off of at low frequencies, which further improves the behavior at low frequencies. We certainly want to benefit from that, and thus would always opt to add an I-term to the controller.
However, in the case of the FOC drives, it does not really affect the controller stability (if is not too high of course), and adding an I-term would not allow us to achieve e.g. significantly higher values. That is, in order to obtain good disturbance rejection at medium to high frequencies the key controller terms are and .
4.6. Torque Disturbances
So far we have looked at the gimbal-base motion rejection or transfer function , for reasons discussed in the introduction. However, let us also briefly inspect the torque disturbance rejection. Torque disturbance rejection can in fact be equally or maybe even more important in certain applications, such as e.g. on planes. Planes usually do not shake as much as copters do, while wind disturbances are massively stronger due to the overall higher flying speeds.
Let us first discuss a gimbal without motor. The transfer function with respect to torque disturbances is
That is, the effect of a torque acting on the camera becomes infinitely large at low frequencies. This makes perfectly sense. Let’s assume again the situation of zero friction. Then one obviously can move the camera „freely“ as there is no counter action of any sort which would prevent camera motion (the camera inertia only determines how „quickly“ the camera would react, but would not prevent the motion). Hence, this gimbal does not provide effective torque disturbance rejection.
For a P controller and a FOC motor drive we obtain
This again can be tidied-up using the same conventions as before, which yields
The transfer function corresponds to that of a 2nd-order low pass. At high frequencies, above the resonance frequency, there is a roll-off similar to the non-motorized gimbal. That is, here torque disturbance rejection is only provided by the inertia of the camera. At low frequencies, the response is flat with amplitude , and torque disturbance rejection is achieved. The rejection is the better the larger the controller gain is.
Interestingly, or sadly, torque disturbance rejection is not improved by a D-term. It would be however by an I-term.
5. Concluding Words
From the discussion it is clear: The most important factor to achieve a good disturbance rejection is a high controller gain.
This is, in fact, a well-known rule of thumb which is generally observed for disturbance rejection. 🙂
Concerning controller stability, which as said before determines or limits the range of values for and , one finds that for the FOC drive schemes a PD controller is in fact fully appropriate and allows achieving high (for FOC drives the P- and D-terms in the controller are most important, the I-term is of much less relevance).
It is recalled that the full FOC scheme has an advantage over the simplified FOC scheme, since it doesn’t add „flux“ friction, that is the value of is smaller. This is may not be of so much relevance for the controller tuning, but as we have seen here is the key characteristic determining gimbal-base motion rejection. A lower is thus always an advantage, which cannot be compensated for by whatever controller.
The sinusoidal motor drive was not discussed here. The very different motor transfer function, which is that of a 2nd-order low pass, i.e., characterized by a constant frequency response below the resonance frequency and not a behavior as for the FOC drives, makes the sinusoidal motor drive more complicated to discuss, and also much less favorable. The interested reader should have no difficulty to work it out following the above procedures. For the sinusoidal drive one needs to resort to additional „tricks“ in order to achieve comparable rejection performance, especially feed-forward of the gimbal-base motion (known in STorM32 parlance as „2nd IMU“).