[Dprglist] Odometry on Mecanum-wheeled robots?
Murray Altheim
murray18 at altheim.com
Wed Apr 15 14:50:10 PDT 2020
Hi Doug,
No, I hadn't seen it, and it's exactly the kind of thing that will be helpful,
with a nice, to-the-point algorithm. Thanks! I've ported Arduino sketches to
Python on a couple of occasions so having a bit of a model is great.
BTW, an update on waht I posted yesterday: my various attempts in Python at
converting a magnetometer produces output, but not the *right* output. I've
now written my LSM9DS1 tests into the one I have for the BNO055 (which produces
headings that make sense, 0-360 degrees), but I can't even figure out what the
three or four test functions I've created are doing, there seems to be no
relationship between the BNO055's output and the function outputs.
So I'll continue to work on that, but later. Yesterday evening was magnetometer
stuff, which kept me away from working on my PID controller. That's more of a
priority.
[And a 4 hour robot! Wow! I've yet to see how long my 3Ah Makita batteries last,
where I actually have implemented a digital switch to shut down the more power-
intensive sensors when in "standby" mode, hopefully to help with battery life.]
Cheers,
Murray
On 16/04/20 2:26 AM, secretary at dprg.org wrote:
> Murray,
> In case you haven't found this tutorial by Brett Beauregard on PID, it is a really good one http://brettbeauregard.com/blog/2011/04/improving-the-beginners-pid-introduction/.
>
> Regards,
> Doug P.
>
> On Wed, Apr 15, 2020 at 9:17 AM secretary at dprg.org <mailto:secretary at dprg.org> <secretary at dprg.org <mailto:secretary at dprg.org>> wrote:
>
> Murray,
> The rule of thumb with casters is that they can navigate bumps up to a maximum size of the radius of the wheel. The little ball casters usually have a really small radius.
> Regards,
> Doug P.
>
> On Wed, Apr 15, 2020 at 12:58 AM Murray Altheim via DPRGlist <dprglist at lists.dprg.org <mailto:dprglist at lists.dprg.org>> wrote:
>
> I'm going to contradict myself. Regarding orientation sensors, I dug
> around a bit and found:
>
> https://blog.digilentinc.com/how-to-convert-magnetometer-data-into-compass-heading/
>
> and am quite pleased to be getting a compass heading output from the
> magnetometer of an Adafruit LSM9DS1. I'm no mean Python programmer but
> in the interest of sharing, here goes:
>
> ------------------------------------------------------------
> #!/usr/bin/env python3
> # -*- coding: utf-8 -*-
> #
> # reads an x,y,z value from the LSM9DS1 magnetometer and
> # displays a heading in degrees.
>
> import time, board, busio, math, adafruit_lsm9ds1
>
> LSB = 0.48828125 #mG
>
> def convert_to_direction(mag_x, mag_y, mag_z):
> xGaussData = mag_x * LSB
> yGaussData = mag_y * LSB
> if xGaussData == 0.0:
> return 90.0 if yGaussData < 0.0 else 0.0
> else:
> direction = math.atan( yGaussData / xGaussData ) * ( 180.0 / math.pi )
> if direction > 360.0:
> return direction - 360.0
> elif direction < 0.0:
> return direction + 360.0
> else:
> return direction
>
> try:
> i2c = busio.I2C(board.SCL, board.SDA)
> sensor = adafruit_lsm9ds1.LSM9DS1_I2C(i2c)
> while True:
> mag_x, mag_y, mag_z = sensor.magnetic
> direction = convert_to_direction(mag_x, mag_y, mag_z)
> print('lsm9ds1 : direction: {0:0.2f}°;\tmagnetometer(G): ({1:0.3f}, {2:0.3f}, {3:0.3f})'.format(direction, mag_x, mag_y, mag_z))
> time.sleep(0.5)
>
> except KeyboardInterrupt:
> print('\nlsm9ds1 : Ctrl-C caught: keyboard interrupt.')
>
> #EOF
> ------------------------------------------------------------
>
> with output like:
>
> lsm9ds1 : direction: 31.17°; magnetometer(G): (0.349, 0.211, 0.077)
> lsm9ds1 : direction: 21.02°; magnetometer(G): (0.413, 0.159, 0.095)
> lsm9ds1 : direction: 18.88°; magnetometer(G): (0.438, 0.150, 0.078)
> lsm9ds1 : direction: 8.52°; magnetometer(G): (0.356, 0.053, 0.105)
> lsm9ds1 : direction: 0.81°; magnetometer(G): (0.285, 0.004, 0.130)
> lsm9ds1 : direction: 2.04°; magnetometer(G): (0.248, 0.009, 0.114)
> lsm9ds1 : direction: 4.20°; magnetometer(G): (0.242, 0.018, 0.128)
> lsm9ds1 : direction: 6.50°; magnetometer(G): (0.232, 0.026, 0.128)
> lsm9ds1 : direction: 3.05°; magnetometer(G): (0.303, 0.016, 0.121)
> lsm9ds1 : direction: 346.79°; magnetometer(G): (0.308, -0.072, 0.258)
>
> On 15/04/20 3:50 PM, Murray Altheim via DPRGlist wrote:
> > [...] so the idea of taking a more "raw" output from a magnetometer and having to
> > process that for a value vs. an already-complete orientation value in radians or
> > degrees from the BNO055, well, that's pretty compelling. I'd both have to spend
> > a lot of time learning and debugging versus just getting a compass heading output
> > from the BNO055. While it might be somebody's cup of tea to work out that kind
> > of detail, it's not like there's not enough challenges in building a robot. And
> > time, hmm. Time.
> ...........................................................................
> 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 <mailto:DPRGlist at lists.dprg.org>
> http://lists.dprg.org/listinfo.cgi/dprglist-dprg.org
>
--
...........................................................................
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