Hot answers tagged

67

For small, low torque motors with little or no gearing, one procedure you can use to get a good baseline tune is to probe it's response to a disturbance. To tune a PID use the following steps: Set all gains to zero. Increase the P gain until the response to a disturbance is steady oscillation. Increase the D gain until the the oscillations go away (i.e. ...


18

Specifics Looking at the PID Basic Example I think that you just need to instantiate two copies of PID controller, one for each wheel, encoder and pwm: PID leftPID(&InputLeft, &OutputLeft, &SetpointLeft,2,5,1, DIRECT); PID rightPID(&InputRight, &OutputRight, &SetpointRight,2,5,1, DIRECT); Then, in your loop() equivalent, you just ...


16

The main purpose of the integral term is to eliminate the steady state error. In the normal case there is going to be a small steady state error and the integral is mainly used to eliminate this error. It's however true that when the error gets to 0 the integral will still be positive and will make you overshoot. Then after overshoot the integral will start ...


13

A similar experimental method to hauptmech's answer that I was taught in college: Set all gains to 0. Increase Kd until the system oscillates. Reduce Kd by a factor of 2-4. Set Kp to about 1% of Kd. Increase Kp until oscillations start. Decrease Kp by a factor of 2-4. Set Ki to about 1% of Kp. Increase Ki until oscillations start. Decrease Ki by a factor of ...


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);...


10

A co-worker and I once implemented a simplex algorithm for on-the-fly tuning of the PID parameters of a current control loop for a motor. Essentially the algorithm would modify one parameter at a time and then collect data on some feedback parameter that was our measure of goodness. Ours was percent deviation from a current target setpoint. Based on whether ...


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

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

When using a PID loop to steer using line following, then your set point will always be the same. You will always want the line to be in the same position with respect to the robot, for instance in the centre of your sensor. So if your line sensor outputs a value from -1 to 1 with 0 being the centre of the sensor, then you will want your set point to be ...


8

Imagine that you set up a PID controller on your own arm, so that you could hold a cup of coffee straight out in front of you. The proportional element would control your arm strength relative to your hand position being too high or too low. The derivative element would adjust that strength based on how quickly you were already moving, so that you don't ...


8

The function $T(\mathbf{x})$ that describes how ones input to a system maps to the output of the system is referred to as a transfer function. For linear systems the transfer function can be written as $N(\mathbf{x})/D(\mathbf{x})$ where $N$ and $D$ are polynomials, i.e. $$T(\mathbf{x}) = {N(\mathbf{x})\over D(\mathbf{x})}$$ The zeros of the system are the ...


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

Embedded.com has moved my article yet again, but here is where it is now. This shows you both how to write a PID loop (figuring out how to do it in something other than floating point is left as an exercise to the reader) and how to tune it. PID Without a PhD The best way depends a lot on your abilities. The way to get the best tuning, assuming you're an ...


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

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 ...


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

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, ...


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

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)/...


5

First, you haven't provided enough information. Your equation is nonlinear, which means that the behavior of the system as described depends not just on the coefficients of the difference equation, but on the range of values that $y$ can take on. From the looks of things, the closer that $y$ is restricted to 0, the more you can treat the whole thing like a ...


5

These polynomial transfer functions occur, when you perform a Laplace transform on some linear differential equation which either actually describes your robot or is the result of linearizing the robot's dynamics at some desired state. Think of it like a "Taylor expansion" around that state. The Laplace transform is the generalization of the Fourier ...


5

Sebastian Thrun presented a simple algorithm for tuning PID in his "How to Program a Robotic Car" class. It's called "twiddle", he describes it here. Twiddle is very prone to finding local minima--this means that you could come up with a set of three constants that are okay, but not optimal for the situation. The problem of tuning PID constants is a subset ...


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

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 ...


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