[Dprglist] Assisting PID odometry with an IMU

secretary at dprg.org secretary at dprg.org
Fri Jan 22 22:17:08 PST 2021


Murray,

     One approach is to take the theta value from the IMU instead of
calculating it from the encoders, and then adding the heading error to the
summing node of the negative feedback loop.



Taking the theta value form the IMU:



/* accumulate total rotation around our center */

/*theta += (left_inches - right_inches) / WHEEL_BASE; */


/* replace theta value with IMU yaw value */

theta = read_IMU_yaw();  /* make sure that the units and orientation are
correct */


/* and clip the rotation to plus or minus 360 degrees */

theta -= (float)((int)(theta/TWOPI))*TWOPI;



Now the theta value is from the IMU and should show the impact of your
rug/floor disturbance.



The next part is to add the heading error (heading error = heading target –
theta) to the input summing node of your negative feedback loop. The
heading error is zero when you are going in the right direction, elsewise
it will have either a negative or positive value. It will be summed in with
your reference value (desired speed in this case) and the -feedback value
(PID error). If you view it in terms of your PID error, it is like you are
changing the reference value.



I hope this helps.



Regards,
Doug P






On Fri, Jan 22, 2021 at 5:04 PM Murray Altheim via DPRGlist <
dprglist at lists.dprg.org> wrote:

> Good afternoon,
>
> Part of building a second robot (named the KD01, with "D" for differential)
> using much of the same hardware and software as my original KR01 was to
> simplify development of the basic motor control, navigation and odometry.
>
> I just finished debugging the hardware and software of the OSEPP motor
> encoders (the oscilloscope worked wonders) and now I've got the KD01 able
> to drive in a PID-controlled straight line, velocity set by a
> potentiometer.
>
> Simple stuff.
>
> While taking it on a tour of my lounge its port side wheel goes from
> hardwood floor onto the big bump of a rug, the starboard wheel remaining
> on wood floor. Once on the rug the PID controllers keep it in a straight
> line (yay!) but that bump causes the robot to turn towards the
> wheel hitting the bump, so that its heading shifts by say, 30 degrees to
> port.
>
> What I'd like to do is have the IMU keep the robot on a straight line, or
> at least recover its heading once it has stabilised. I'm not looking for
> someone to hold my hand, but a gentle push in the right direction, maybe
> a link, an algorithm (or even C/C++/Python code, which I rewrite or port)
> would be enormously helpful.
>
> I'd not need or want to use absolute orientation (compass) for this as the
> robot is running indoors (and yes, that's a different subject altogether
> that we've discussed previously). My guess is to use either the gyroscope
> and/or the accelerometer, seems more likely the former than latter, dunno.
> I'm at a bit of a loss as to where to start... though David Anderson does
> have a very helpful page at:
>
>
> http://seattlerobotics.org/encoder/200610/Article3/IMU%20Odometry,%20by%20David%20Anderson.htm
>
> David outlines either using A. Magnetic Compass; B. Rate Gyro; C. Gyro-
> corrected Magnetic Compass; or D. 3-Axis Gyro-Corrected 3-Axis
> Magnetometer.
> Since we'll assume the magnetometer is not reliable indoors, the gyro or
> accelerometer will have to suffice. The paper referenced for B. (describing
> "gyrodometry) is a bit past my ability to understand with formulae like
>
>     μ′=m(u′) +K∗(u′,U)[K∗(U,U) +σ2∗I]−1(Z−m(U))
>
> and in essence doesn't sound quite like a solution anyway as it refers to
> use of "deep learning"; I don't think we'd need that for basic navigation.
> Basically I'm thinking there must be a way to take the (relatively simple)
> 3D coordinates coming from the gyro or accelerometer and use that to note
> the axis shift when the robot hits the edge of the rug. Or something like
> that.
>
> I'm guessing some of you guys eat this kind of thing for breakfast, but
> for me it's a bit indigestible.
>
> Thanks very much in advance,
>
> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.dprg.org/pipermail/dprglist-dprg.org/attachments/20210123/a906b956/attachment.html>


More information about the DPRGlist mailing list