[Dprglist] PID

Murray Altheim murray18 at altheim.com
Sat Sep 26 18:23:46 PDT 2020


Hi David,

I'm happy to say that I've managed to get my new PID controller working
(thanks to everyone for all the help!) and with my GamePad have been
running the robot around on the carpet for some preliminary testing. I
thought about going out onto the front deck but the gales are pretty
strong today (> 120km/hr gusts).

I've relegated the slew, acceleration and deceleration (as you suggested)
to upper level functions, so I've now got:

    motors.py     establishes connections with the Thunderborg controller
    motor.py      provides direct-power drive of a motor, with battery
                  voltage sensing and safety limiting
    pid.py        contains two classes:
        PID class:     a simple PID controller for a single motor (I=0.0)
        PIDController: provides system-level configuration, the 20Hz
                       loop thread, set_velocity() and optional slew
                       control over set_velocity()
    behaviours.py  where I'm putting upper-level behaviours, callable
                  from the GamePad (and eventually autonomous control)

I'm currently working on roam() and drive_one_meter() behaviours, the
latter with acceleration, cruise and deceleration to attempt to drive
in a straight line and stop at precisely one meter from the starting
point (with 2295 encoder steps per meter). Then eventually reverse and
come back to the same spot. No 180 degree turns quite yet...

As I think we've discussed, all of the coding and tuning contributes to
what we think of as the robot's 'behaviour': e.g., how tightly it hews
to motion commands, how abruptly it starts and stops, etc. The new PID
controllers are trickier to drive (manually, via the GamePad) but seem
much more accurate in terms of "feel". The robot also seems to drive
better at slower speeds, not surprisingly. I'm beginning to put together
a blog post and a video describing the overall effort.

I do have several questions.

I believe at this point I've found the best tuning in terms of the
overall balance, but the robot now has a new behaviour: when "at rest"
(velocity = 0) after having been in motion, it doesn't sit still but
hunts back and forth very slightly, maybe about a quarter of a wheel
revolution. This is clearly the PID oscillating around the zero mark.
Is this where I might dial in some I term, or adjust the P or D in a
different direction? I'm a bit loath to change P or D since the current
performance is, apart from this hunting behaviour, relatively good.

Using each joystick to directly control the motor is a bit trickier
than before so maybe it's time to learn how to steer properly.

Your robots use velocity and theta. I guess I'm getting close enough
to being able to consider that now, so I'm keen to understand (as
we've all discussed in the previous video conference) how to use the
integral between the two PID controllers for steering. What I'd be
doing is taking the GamePad's two joysticks (which each return from
0 to 255, or -127 to 127) and use the differential between those two
values as theta to steer the robot, with I suppose the average as the
overall velocity.  OTOH, I'm wondering if the result wouldn't in
effect be the same (i.e., left and right joysticks as direct motor
velocities vs. the difference between as theta and the average as
velocity).

I'll have to give that last paragraph some further thought, clearly,
as the answer to that isn't immediately clear to me, suggesting I
don't yet understand the problem correctly.

I currently blame the distractions of the howling wind...

Cheers,

Murray

On 25/09/20 8:40 am, David Anderson via DPRGlist wrote:
> Howdy DPRG,
> 
> As per our discussion at RBNO Tuesday evening on PID tuning, check out:
> 
> https://en.wikipedia.org/wiki/PID_controller
> 
> and particularly the cool animation of adjusting P,I,D values in the "Manual tuning" section about half way down.
> 
> There's also a useful "for dummies" page at:
> 
> https://www.csimn.com/CSI_pages/PIDforDummies.html

I've tried documenting my PID journey and have collected quite a few PID
links (maybe too many) at:

   https://service.robots.org.nz/wiki/Wiki.jsp?page=PIDController

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



More information about the DPRGlist mailing list