# How do I find the transfer function for my quadcopter altitude system?

This is not so much of a how but if I am right so far. I am looking at the z-axis now only. The linearized equation of motion for the thrust in the z-direction is:

$$T=m\cdot \ddot{z}+mg,$$

where $$m$$ is the mass, $$\ddot{z}$$ is the acceleration in the z-direction and $$g$$ is gravity acceleration and $$T$$ is the thrust. I will now Laplace transform it so it can be put in the frequency domain. I will first solve for the acceleration.

$$\ddot{z} = T/m - mg$$

I will now Laplace transform and this gives:

$$T(s)/m - 1/(mg) = Z(s)s^2$$

After some computations, I end with:

$$Z=T(s)/(ms^2) -1/(mgs^2)$$

I have ignored the last term because I have seen that usually plants in the control system it should "multipy-able" i.e one term. I am not sure if that is an error. What should I put in the drone plant then? See below for the figure.

This is put into my control system. I have made a PD controller and the control law (I made this myself, I have seen other papers using other inputs but I did not see the intuition) is sent which is:

$$T = T_d + K_p \cdot e + K_d \cdot \dot{e}$$

Where $$T$$ is the total thrust sent and $$T_d$$ is the desired thrust and $$K_p$$ and $$K_d$$ are the gains for derivative and position error.

All this is put into this control system. (the green part is technicality but it is to be ignored).

Will I be able to find the transfer function (by simplifying the blocks using block diagram reduction) and then send a step response to it so I can check what $$K_p$$ and $$K_d$$ values I need?

You cannot simply neglect the weight.

The total thrust $$T$$ is normally provided by a combination of a feed-forward term $$T_{FF}$$ and a feedback term $$T_{FB}$$:

$$T = T_{FF} + T_{FB}.$$

Ideally, the feed-forward contribution should be designed such that it delivers the effort required to drive the plant toward the target:

$$T_{FF} = mg + m\ddot{z_d}.$$

If we replace the expression of $$T$$ into the dynamical equation of the system, we get:

$$T_{FB} + m\ddot{z_d} = m\ddot{z}.$$

The weight is canceled out from the equation (not really, as there is an offset – read below) and if $$T_{FB} = 0$$, we obtain $$\ddot{z}=\ddot{z_d}$$ and therefore $$z=z_d$$.

In reality, we don't know exactly the weight $$mg$$, thus the feedback $$T_{FB}$$ needs to compensate for these uncertainties and all the unmodelled quantities. For example, we generally don't have a perfect calibration of the thrust system; hence, the equation that states how to generate $$T_{FF}$$ from the forces at stake is certainly affected by errors.

The term $$T_{FB}$$ can be thus chosen to be a PID over the position error. You need the D part for stability reasons because the plant is actually a double integrator, but you need also the I part as there exists a fixed offset between the real weight and its estimate. The integral part I serves right to account for this offset.

Also, notice how $$z_d$$ cannot be made independent from $$\ddot{z_d}$$ as it is shown in your control architecture. To make things work properly, we need to enforce that $$z_d$$ is the output of a double integrator acting on $$\ddot{z_d}$$. In essence, $$z_d$$ shouldn't undergo stepwise transitions but rather needs to be shaped correctly.

Finally, you cannot neglect the drag force, which can be usually modeled as a term that depends linearly on the velocity $$\dot{z}$$.

A somewhat related resource is https://robotics.stackexchange.com/a/19658/6941.

To elaborate more on the part of the gravity, let's refer to the following equation that highlights all the contributions:

$$m\ddot{z} = -mg + \hat{m}\hat{g} + \hat{m}\ddot{z_d} + T_{FB},$$

where the terms under hat are estimates.

It's visible how the dynamics is fully decoupled between the double integrator and the remaining terms (there's no drag), namely (1) the weight $$-mg$$, (2) the counter-weight $$\hat{m}\hat{g}$$, (3) the desired effort $$\hat{m}\ddot{z_d}$$, and (3) the feedback $$T_{FB}$$, which in turn can be considered all as independent inputs.

The system is linear, thus you can leverage the superposition principle to compute the whole response as a summation of the responses to the single inputs.

Thereby, you'll end up considering for your study the mere equation:

$$m\ddot{z} = u,$$

where $$u$$ accounts for a generic input.

The corresponding Laplace transform is:

$$\frac{z}{u} = \frac{1}{m s^2}$$

At this point, you ought to study all the dynamic properties of this system and come up with a controller responsible for delivering $$T_{FB}$$. To this end, you may want to read up this nice review: Naive Control of Double Integrator. The PD approach is one of the proposed solutions that works quite well, actually.

Once you know everything about it, you're simply done as the system will respond equally to your thrust and to the effect of gravity.

Now, if you want to add up feed-forward terms, the effect of gravity will be compensated (not canceled out exactly) beforehand thanks to your estimates $$\hat{m}$$ and $$\hat{g}$$. Since estimates cannot be perfect, you need to introduce an integral part as well and transform the PD into a PID.

• But how do i find the transfer function? I want to send a step response to the system so I can find the correct values for kp,kd and ki. Nov 3, 2021 at 21:26
• The transfer function in a very rough approximation is the double integrator $z/T = 1 / ms^2$ as the weight can be disregarded for the sake of the study of the dynamical evolution thanks to the feed-forward and for the superposition effect of linear systems (the weight acts as a second input). In reality, it won't be a perfect double integrator so if you inject a stepwise input thrust you can think of identifying the real model based on the system response. Once the model is known, you can use this information to tune up the PID gains. Nov 3, 2021 at 22:41
• Can you explain how the gravity is canceled? Nov 17, 2021 at 7:42
• In my comment I didn't say "canceled", rather "disregarded". I tried to be more specific on this by extending my answer. Check it out. Nov 18, 2021 at 12:20

That weight is indeed a problem for you to get the transfer function, since it will prevent you from separating the input and output.

For the controller design part, one method that is usable is to consider the weight of the vehicle as a constant disturbance, and using a feed-forward element to compensate for this disturbance.

You neglect the weight at first, that way you have a Laplace domain representation which you can use to get the transfer function of the system. When you have the transfer function, you can use a method of your choice to design your controller. As it is apparent from the transfer function, it is not possible for a P Controller to stabilise the system, therefore you need a derivative action to stabilise it. After you designed the controller, you can send a step signal to see how it performs, when the weight is neglected.

However, your real system has the weight term, which effects the behaviour. Therefore, for your system's real performance (when the weight is considered) to be close to what you got when you had sent the step signal, you need to eliminate the effect of the weight with a structure apart from the PD Controller itself. If you just use the PD Controller you designed, on your system model (which includes the weight), you will notice that the system performance will deviate from what you had calculated during the design process of the PD Controller. The reason for that is you will not be compensating the disturbance efficiently enough.

We considered the weight as a constant disturbance, and feed-forward control is a commonly used method to eliminate the effects of identifiable disturbances on the system. By introducing this feed-forward term, we aim to make the response of the system, as close as the results we got from the PD Controller design process.

So, to sum it up:

1. Ignore the weight at first. Then you will be able to have your transfer function.

2. By using this transfer function, design your PD Controller by considering your design criteria.

3. To compensate the effect of the ignored weight, use a Feed-forward term. You can search the internet on how you can find the feed-forward coefficient.

For the simulation part, you use the equation that includes the weight as your plant. Because all the assumptions we make while designing the controller is to ease up the design process for ourselves. If it is needed, we simplify the system equations and design our controller(s) based on those equations. However to see how they perform, we use the actual plant models. That way we are able to see if our assumptions hold true, and the real performance is close to what we had assumed/predicted.

• In control engineering, the terms disturbances and feed-forward do not get along well together. A disturbance is by definition unknown, whereas feed-forward accounts for known terms by definition. So, in this context, the feed-forward contribution can be used to compensate for what we know in advance about the weight, but the compensation cannot be perfect. The use of a feedback term (the integral) is thus mandatory. Nov 3, 2021 at 22:34
• Thanks for the heads up! You are definitely right, I remember the altitude response of one of my quadcopters - which I had designed on Simulink - was converging very very slowly when the error was around 8-10 centimeters, without an integral action. I definitely forgot about that. Nov 5, 2021 at 17:55