[Dprglist] Assisting PID odometry with an IMU

markus markus at bibi.ca
Fri Jan 22 15:17:22 PST 2021

Hi Murray,

attached is the madgwick algorithm which I found to perform quite well
for these issues. There is an alternate approach published from
Brokking (of balancing robot fame) which you'll find on his website. In
my experiments the madgwick algorithm performed better and was easier
to tune. Also, it uses quaternions so there's the "cool" factor as well

Have fun,

On Sat, 23 Jan 2021 12:04:29 +1300
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 --------------
A non-text attachment was scrubbed...
Name: madgwick.h
Type: text/x-chdr
Size: 1206 bytes
Desc: not available
URL: <http://lists.dprg.org/pipermail/dprglist-dprg.org/attachments/20210122/c88d680c/attachment.h>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: madgwick.c
Type: text/x-c++src
Size: 3982 bytes
Desc: not available
URL: <http://lists.dprg.org/pipermail/dprglist-dprg.org/attachments/20210122/c88d680c/attachment.c>

More information about the DPRGlist mailing list