[Dprglist] Power vs Velocity for PID controllers

Dermot Tynan dtynan at kalopa.com
Tue Apr 21 05:21:11 PDT 2020


I might be missing something, but when someone says there isn't a direct 
link between power and velocity, what they mean is that you can't 
express it in the form:

     V = kP

(for some value of k). This is because your robot operates under 
differing conditions, like going up hills, down hills, lighter than 
usual, etc, etc.

This is an ideal use for a PID controller because there's a feedback 
loop. The PID controller will increase (or decrease) the power until the 
right velocity is achieved, as per the P, I and D terms.
                         - Der

On 21/04/2020 05:27, Murray Altheim via DPRGlist wrote:
> Hi all,
>
> Over the past week I've spent many an hour working on my Python-
> based PID controller, which is using a ThunderBorg motor controller
> under the hood to drive a quartet (left-right pairs) of OSEPP motors.
>
> I've kinda got something working, at least the PD part of it seems
> functional, but there's a big gaping hole where a certain part of
> the implementation is concerned: prior to PID I was "successfully"
> driving the robot based on an encoder-based velocity measurement,
> but there was no PID, and my recent attempts to create a PID
> controller using velocity have failed.
>
> I believe this is due to the fact that I was attempting to use the
> velocity measurement as the PID input to set the motor power. As I
> think David noted in his YouTube video, there isn't a direct relationship
> between motor power and velocity so this was bound to fail. I like
> fail as much as the next person, but success is nice too.
>
> So with that in mind I've gone back to a power-based PID controller,
> knowing I still have a certain mountain to climb.
>
> The question I now have is: how to add a velocity-based control to
> my robot? Do I come up with some mathematical relationship between
> velocity and motor power, or do I create a velocity-based PID
> controller **over top** of the power-based PID controller, i.e.,
> two layers of PID control?
>
> Much-simplified pseudo-code:
>
>   KP = some_constant
>   KI = some_constant
>   KD = some_constant
>
>   target_power = 0.5
>
>   while True:
>       current_power = motor.get_power()
>       error = target_power - current_power
>
>       k_diff = KP * error
>       i_diff = KI * sum_errors
>       d_diff = KD * last_error
>
>       output = k_diff + i_diff + d_diff
>       slewed_output = slew(output)
>       new_power = current_power + slewed_output
>       set_motor_power(new_power)
>
>       last_error = error
>       sum_errors += error
>
> So would I incorporate velocity into the above somehow, or build
> Yet Another PID controller for velocity (using roughly the same
> structure as above, but solely dealing with velocity) that calls
> the above power-based PID controller?
>
> I thought perhaps we could discuss this in tomorrow's Robot Builders
> Night Virtual get together... but an email discuss is also welcome,
> thanks!
>
> Cheers,
>
> Murray
>
> ........................................................................... 
>
> Murray Altheim <murray18 at altheim dot com>                       = 
> =  ===
> http://www.altheim.com/murray/ ===  ===
> = =  ===
>     In the evening
>     The rice leaves in the garden
>     Rustle in the autumn wind
>     That blows through my reed hut.
>            -- Minamoto no Tsunenobu
>
> _______________________________________________
> DPRGlist mailing list
> DPRGlist at lists.dprg.org
> http://lists.dprg.org/listinfo.cgi/dprglist-dprg.org


-- 
Dermot Tynan
dtynan at kalopa.com



More information about the DPRGlist mailing list