Hot answers tagged

11

The glaring issue I see at the moment is that you are forcing polarity on the I and D terms. In general, you are using a lot of sign checks, sign assignments, and conditional programming. None of that belongs in a PID controller. The entire controller should look like: pError = Input - Output; iError = iError + pError*dt; dError = (pError - previousError)/dt;...


11

Proportional term: this controls how quickly to turn the steering when the heading is not at the set value. A low P will lead to sluggish steering, reacting only slowly to set heading changes. It may never reach the commanded value. A higher P will give a snappier response, ideally with the steering turning rapidly and smoothly to follow commanded heading ...


10

It sounds like you've missed the core concept of a PID, so let's start from scratch. In mathematical terms, a PID controller decides how much force to apply in order to move a system in 1-dimensional space -- from an actual position to a desired position. Based on the error $(\text{error} = \text{position}_{desired} - \text{position}_{actual})$, it ...


10

The barometer carried on the pixhawk has an altitude resolution of 10 cm. If that isn't enough, you could write a kalman filter that uses the accelerometer data in the prediction step and the ultrasonic sensor and/or the barometer in the correction step. But I don't see this solving your problem. An accurate measurement of altitude at 20hz should be plenty ...


9

The paper Controlling of Quadrotor UAV Using a Fuzzy System for Tuning the PID Gains in Hovering Mode by E. Abbasi, M. J. Mahjoob explains how to tune PID gains with fuzzy logic. You can find many papers about singleton tuning but this paper shows totally fuzzy control find PID gains with ziegler-nichols (or another technique) Create a fuzzy PID gain ...


9

The first thing to realise is that this is not a control problem, this is a planning problem. If you conflate the two, you are making life much more complex than it needs to be. Solution - Motion planning The traditional way to achieve what you want is to have two loops. The outer planning/supervisory loop generates way-points for specific points in time, ...


9

Typically with a multiple input, multiple output (MIMO) system, a control engineer uses a state feedback controller. This style of controller leverages a state-space model of the system and generally takes the form: $$ \dot{x}=\mbox{A}x+\mbox{B}u \\ y = \mbox{C}x + \mbox{D}u \\ $$ where $x$ is a vector of states, $u$ is a vector of inputs, $y$ is a vector ...


8

You're trying to implement more PIDs than you have degrees of freedom. In a quadcopter, you have only 4: $(Z, \phi, \theta, \psi)$ i.e. (Altitude, Roll, Pitch, and Yaw). via (http://www.draganfly.com/uav-helicopter/draganflyer-x4/features/stability.php) Interestingly, from a PID perspective you definitely do have desired values for $\phi$ and $\theta$: ...


7

Even very small errors can bother the balancing. Small errors such as: Weight of the quadcopter is unbalanced. One motor is rotating faster/slower than others due to manufacturing or your power-source. Air resistance and wind. Unbalanced propellers due to manufacturing. Strong magnetic forces. You simple can not send the same motor speed to all motors ...


7

No, but you do need to calculate the P/I/D terms correctly. You have: I = I + previous_I; followed by: previous_I = I; With I = 0; previous_I = 0; declared at the start. So your I term will always be zero here. What it should be is: error = reference - feedback; P_error = error; I_error = I + (error*timeStep); D_error = (error - previous_error)/...


6

It looks like your proportional gain is too high. You seem to be constantly increasing RPM on one motor while locking in the other one to make the system rotate. This isn't a good control strategy as eventually those are going to both saturate and you will lose control. Also as time increases your ability to command the system decreases. So you need a ...


6

A quadcopter contains (among other things) two separate and independent algorithms: an attitude estimation algorithm, and a control algorithm. The attitude estimation algorithm computes information about the orientation of the quadcopter: the roll, pitch and yaw angles. The control algorithm is responsible for driving the motors so that the orientation of ...


6

You're correct that measurement and modeling is the right way to go about this. For your PID to work properly, you need to be able to make a somewhat linear conversion of error (desired roll vs actual roll) into corrective force (in this case, provided by the control surfaces -- the aileron angle, influenced by air speed and other factors). The $k_d$ term ...


6

By far, the most common solution to this problem is to use 2 separate controllers. The inner loop controller is what you already have: it tracks angle and height commands. The outer loop controller assumes that the angles are tracked perfectly and treats angles as inputs, rather than separate states. So it takes the position error and converts it to a ...


6

Increasing the sample rate probably isn't going to buy you much if you can't do something useful. That is, if you don't update the control signal (e.g., motor current) at the same high sample rate, then I don't think you're going to gain much. Similarly, if your IMU or other sensors don't update at the higher frequency, polling them at a higher frequency isn'...


6

Generally, in a well-tuned PID, most of the job is done by the P term, which is responsible for driving PV to SP. Then, D and I serve as corrections: the D term regulates the profile as of how we reach for SP, whereas the I term kicks in essentially when we are already in the neighborhood of SP to attempt to get a 0 steady-state error. Bearing these basic ...


5

Are there any issues with this? The main issue with this is that while your proposed solution will instantaneously correct for a mismatch between the performance of the motors, it will not correct for accumulated error, let alone more complex errors in position such as Abbe error (see later). What is a better approach? There are several things you can ...


5

1) I would try find out how fast your ESCs can update and use that as the PID update rate. Your current rate is definitely too slow (need at least 50Hz for marginal performance). 2) Putting a threshold on the maximum change should only be used to handle emergency/unexpected situations. You should NOT expect it to be part of the normal operation, and if you ...


5

Actually, the caster wheel has ideally no effect on the kinematics of the vehicle. In reality there will be some resistance from the caster wheel that does impact the vehicle motion, but we can still ignore it for the sake of designing a control law. Based on the extended discussion in the comments, your sensor can be used to measure the lateral error of ...


5

In the case of MIMO systems (Multi-Input, Multi-Ouput), my warm suggestion is to go with State Space Control, which will give you enough freedom to move the closed-loop poles and thus achieve your control requirements. One viable solution, explored quite a lot in literature, is to employ a LQR controller coupled with a state observer, where here the state is ...


5

Welcome to Robotics, PaoloH! This is a fantastic question for Robotics - It has some Matlab/Simulink, some control theory, some spatial (quaternion) representations, etc. Robotics is the place to come when your question spans multiple fields! In looking at your question, the thing that I noticed is that your reference quaternion is $[0; 1; 0; 1]$. It is not ...


5

Proportional control amplifies equally across all frequencies. Integral action amplifies low frequencies more, and high frequencies less (in fact, its gain at DC is infinite, and at infinite frequency its gain is zero). Differential action amplifies low frequencies less, and high frequencies more (it has zero DC gain and unless its bandlimited, infinite gain ...


4

Since posting the question I tried to tune the 3 PID parameters a lot but I never reached any acceptable result. I didn't try to modify the error curve as I suggested in the question, but I found an alternative solution which works reasonably well. There might be other good solutions. I was using a PID as follows: process setpoint: angle process output: ...


4

Quadcopter is inherently unstable system. So you have to apply some feedback controller (eg. PID) to keep it airborne. Even if you apply some basic PID using angular rates and angles, you still have to provide manual correction for drift till PID gains are perfectly set. So using radio control for manual control is really helpful during initial development ...


4

I read the code but it looks like it is for the first attempt where you tried to hover "open loop" that can't work. So now you tried a PID control based straight off the raw IMU data. Tha't better but you are going to need one more step between the two. Will I say this assuming you are using a low-cost IMU, the kind that just breaks out the chip. ...


4

Defining the state of the quadcopter as $\bf{x} = \left[ \begin{matrix} \mathbf{p} & \mathbf{v} & \mathbf{r} & \mathbf{w} \end{matrix} \right]^T$ where $\mathbf{p}$, $\mathbf{v}$, $\mathbf{r}$, and $\mathbf{w}$ are the position, velocity, angular position, and angular velocity of the quadcopter respectively. A simplified transition model for a ...


4

You almost never see ID controllers because they generally don't do anything useful. Here is what they can do: 1) The D part will respond to changes in the system. It will try to correct and move the system back to 0, but once it reaches steady steady the D part is no longer active. Note that it does NOT matter where that steady state is; it could be 0 or ...


4

For a rough calculation of natural frequency, you could create an bode plot. Starting at low frequencies, command a sin wave and measure the amplitude of the output motion (which will be a phase-shifted sin wave). Plotting the output amplitude on a log-scale, if you're lucky the response will be flat for a while, turn relatively quickly, and then start ...


4

Both the solutions you proposed do suffer from unwanted interaction among the two PIDs. You're basically trying to assign two simultaneous goals - i.e. final relative position along with terminal non null speed - when the system has only one input variable, let's say the "thrust" driving the UAV dynamics. The correct scheme should be the one depicted below: ...


4

You are correct in claiming that both PID and LQR can be applied to the linearized form of the cart-pole problem. If you have a look at the answers to the related question Ugo linked to in the comments (specifically Ugo's own answer: https://robotics.stackexchange.com/a/5231/10414), you will see the high level differences between PID (and other classic ...


Only top voted, non community-wiki answers of a minimum length are eligible