<div dir="ltr">I'll double down on that recommendation. I had a robot run into the Gulf of Mexico because of a magnetic anomaly on the beach in South Padre.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Apr 15, 2020 at 5:35 PM Doug Paradis via DPRGlist <<a href="mailto:dprglist@lists.dprg.org">dprglist@lists.dprg.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Murray,<div>   Magnetometers readings are influenced by random magnetic fields. They can be tricky to calibrate and use in practice on small hobbyist robots. DPRG has an infamous video of Eric, the member I mentioned before, who was using a magnetometer to provide a true heading for a robot in a outdoor contest. His robot had performed very well in his first run just barely missing the end target, the orange ball seen in the video below. However on his next runs, he hit the "circle of death". It was place in the sidewalk that had a loop of rebar buried in the concrete. You can see the results at about 0:51 of this video <a href="https://www.youtube.com/watch?v=LryN6zd_n6I" target="_blank">https://www.youtube.com/watch?v=LryN6zd_n6I</a>. You should keep iron away from the sensor. You may be surprised to find your headers are magnetic, your screws and nuts are steel, etc... Motors can also cause issues, so the sensor should be away from them. It is a general good practice on motors to have a 0.1 uf capacitor between the motor leads, and from each lead to the case of the motor. This mostly for electrical noise, but can also influence your compass.  I have found magnetometers to be heavily influenced by environment, especially indoors. They may work in one room and not the next. In cement slab floor homes and buildings unpredictable things happen. For these reasons, I depend on the IMU's gyro reading for heading on my robots. Outdoors I would use GPS over an magnetometer, unless I was trying to not use GPS for contest reasons.</div><div><br></div><div>I hate to be such a Debbie downer, but so far in my limited experience these seem to be the results.</div><div><br></div><div>Regards,</div><div>Doug P. </div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Apr 15, 2020 at 4:50 PM Murray Altheim via DPRGlist <<a href="mailto:dprglist@lists.dprg.org" target="_blank">dprglist@lists.dprg.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi Doug,<br>
<br>
No, I hadn't seen it, and it's exactly the kind of thing that will be helpful,<br>
with a nice, to-the-point algorithm. Thanks! I've ported Arduino sketches to<br>
Python on a couple of occasions so having a bit of a model is great.<br>
<br>
BTW, an update on waht I posted yesterday: my various attempts in Python at<br>
converting a magnetometer produces output, but not the *right* output. I've<br>
now written my LSM9DS1 tests into the one I have for the BNO055 (which produces<br>
headings that make sense, 0-360 degrees), but I can't even figure out what the<br>
three or four test functions I've created are doing, there seems to be no<br>
relationship between the BNO055's output and the function outputs.<br>
<br>
So I'll continue to work on that, but later. Yesterday evening was magnetometer<br>
stuff, which kept me away from working on my PID controller. That's more of a<br>
priority.<br>
<br>
[And a 4 hour robot! Wow! I've yet to see how long my 3Ah Makita batteries last,<br>
where I actually have implemented a digital switch to shut down the more power-<br>
intensive sensors when in "standby" mode, hopefully to help with battery life.]<br>
<br>
Cheers,<br>
<br>
Murray<br>
<br>
On 16/04/20 2:26 AM, <a href="mailto:secretary@dprg.org" target="_blank">secretary@dprg.org</a> wrote:<br>
> Murray,<br>
>      In case you haven't found this tutorial by Brett Beauregard on PID, it is a really good one <a href="http://brettbeauregard.com/blog/2011/04/improving-the-beginners-pid-introduction/" rel="noreferrer" target="_blank">http://brettbeauregard.com/blog/2011/04/improving-the-beginners-pid-introduction/</a>.<br>
> <br>
> Regards,<br>
> Doug P.<br>
> <br>
> On Wed, Apr 15, 2020 at 9:17 AM <a href="mailto:secretary@dprg.org" target="_blank">secretary@dprg.org</a> <mailto:<a href="mailto:secretary@dprg.org" target="_blank">secretary@dprg.org</a>> <<a href="mailto:secretary@dprg.org" target="_blank">secretary@dprg.org</a> <mailto:<a href="mailto:secretary@dprg.org" target="_blank">secretary@dprg.org</a>>> wrote:<br>
> <br>
>     Murray,<br>
>          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.<br>
>     Regards,<br>
>     Doug P.<br>
> <br>
>     On Wed, Apr 15, 2020 at 12:58 AM Murray Altheim via DPRGlist <<a href="mailto:dprglist@lists.dprg.org" target="_blank">dprglist@lists.dprg.org</a> <mailto:<a href="mailto:dprglist@lists.dprg.org" target="_blank">dprglist@lists.dprg.org</a>>> wrote:<br>
> <br>
>         I'm going to contradict myself. Regarding orientation sensors, I dug<br>
>         around a bit and found:<br>
> <br>
>         <a href="https://blog.digilentinc.com/how-to-convert-magnetometer-data-into-compass-heading/" rel="noreferrer" target="_blank">https://blog.digilentinc.com/how-to-convert-magnetometer-data-into-compass-heading/</a><br>
> <br>
>         and am quite pleased to be getting a compass heading output from the<br>
>         magnetometer of an Adafruit LSM9DS1. I'm no mean Python programmer but<br>
>         in the interest of sharing, here goes:<br>
> <br>
>         ------------------------------------------------------------<br>
>         #!/usr/bin/env python3<br>
>         # -*- coding: utf-8 -*-<br>
>         #<br>
>         # reads an x,y,z value from the LSM9DS1 magnetometer and<br>
>         # displays a heading in degrees.<br>
> <br>
>         import time, board, busio, math, adafruit_lsm9ds1<br>
> <br>
>         LSB = 0.48828125 #mG<br>
> <br>
>         def convert_to_direction(mag_x, mag_y, mag_z):<br>
>               xGaussData = mag_x * LSB<br>
>               yGaussData = mag_y * LSB<br>
>               if xGaussData == 0.0:<br>
>                   return 90.0 if yGaussData < 0.0 else 0.0<br>
>               else:<br>
>                   direction = math.atan( yGaussData / xGaussData ) * ( 180.0 / math.pi )<br>
>               if direction > 360.0:<br>
>                   return direction - 360.0<br>
>               elif direction < 0.0:<br>
>                   return direction + 360.0<br>
>               else:<br>
>                   return direction<br>
> <br>
>         try:<br>
>               i2c = busio.I2C(board.SCL, board.SDA)<br>
>               sensor = adafruit_lsm9ds1.LSM9DS1_I2C(i2c)<br>
>               while True:<br>
>                   mag_x, mag_y, mag_z = sensor.magnetic<br>
>                   direction = convert_to_direction(mag_x, mag_y, mag_z)<br>
>                   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))<br>
>                   time.sleep(0.5)<br>
> <br>
>         except KeyboardInterrupt:<br>
>                   print('\nlsm9ds1   : Ctrl-C caught: keyboard interrupt.')<br>
> <br>
>         #EOF<br>
>         ------------------------------------------------------------<br>
> <br>
>         with output like:<br>
> <br>
>         lsm9ds1   : direction: 31.17°;  magnetometer(G): (0.349, 0.211, 0.077)<br>
>         lsm9ds1   : direction: 21.02°;  magnetometer(G): (0.413, 0.159, 0.095)<br>
>         lsm9ds1   : direction: 18.88°;  magnetometer(G): (0.438, 0.150, 0.078)<br>
>         lsm9ds1   : direction: 8.52°;   magnetometer(G): (0.356, 0.053, 0.105)<br>
>         lsm9ds1   : direction: 0.81°;   magnetometer(G): (0.285, 0.004, 0.130)<br>
>         lsm9ds1   : direction: 2.04°;   magnetometer(G): (0.248, 0.009, 0.114)<br>
>         lsm9ds1   : direction: 4.20°;   magnetometer(G): (0.242, 0.018, 0.128)<br>
>         lsm9ds1   : direction: 6.50°;   magnetometer(G): (0.232, 0.026, 0.128)<br>
>         lsm9ds1   : direction: 3.05°;   magnetometer(G): (0.303, 0.016, 0.121)<br>
>         lsm9ds1   : direction: 346.79°; magnetometer(G): (0.308, -0.072, 0.258)<br>
> <br>
>         On 15/04/20 3:50 PM, Murray Altheim via DPRGlist wrote:<br>
>          > [...] so the idea of taking a more "raw" output from a magnetometer and having to<br>
>          > process that for a value vs. an already-complete orientation value in radians or<br>
>          > degrees from the BNO055, well, that's pretty compelling. I'd both have to spend<br>
>          > a lot of time learning and debugging versus just getting a compass heading output<br>
>          > from the BNO055. While it might be somebody's cup of tea to work out that kind<br>
>          > of detail, it's not like there's not enough challenges in building a robot. And<br>
>          > time, hmm. Time.<br>
>         ...........................................................................<br>
>         Murray Altheim <murray18 at altheim dot com>                       = =  ===<br>
>         <a href="http://www.altheim.com/murray/" rel="noreferrer" target="_blank">http://www.altheim.com/murray/</a>                                     ===  ===<br>
>                                                                              = =  ===<br>
>               In the evening<br>
>               The rice leaves in the garden<br>
>               Rustle in the autumn wind<br>
>               That blows through my reed hut.<br>
>                      -- Minamoto no Tsunenobu<br>
> <br>
>         _______________________________________________<br>
>         DPRGlist mailing list<br>
>         <a href="mailto:DPRGlist@lists.dprg.org" target="_blank">DPRGlist@lists.dprg.org</a> <mailto:<a href="mailto:DPRGlist@lists.dprg.org" target="_blank">DPRGlist@lists.dprg.org</a>><br>
>         <a href="http://lists.dprg.org/listinfo.cgi/dprglist-dprg.org" rel="noreferrer" target="_blank">http://lists.dprg.org/listinfo.cgi/dprglist-dprg.org</a><br>
> <br>
<br>
-- <br>
<br>
...........................................................................<br>
Murray Altheim <murray18 at altheim dot com>                       = =  ===<br>
<a href="http://www.altheim.com/murray/" rel="noreferrer" target="_blank">http://www.altheim.com/murray/</a>                                     ===  ===<br>
                                                                    = =  ===<br>
     In the evening<br>
     The rice leaves in the garden<br>
     Rustle in the autumn wind<br>
     That blows through my reed hut.<br>
            -- Minamoto no Tsunenobu<br>
<br>
_______________________________________________<br>
DPRGlist mailing list<br>
<a href="mailto:DPRGlist@lists.dprg.org" target="_blank">DPRGlist@lists.dprg.org</a><br>
<a href="http://lists.dprg.org/listinfo.cgi/dprglist-dprg.org" rel="noreferrer" target="_blank">http://lists.dprg.org/listinfo.cgi/dprglist-dprg.org</a><br>
</blockquote></div>
_______________________________________________<br>
DPRGlist mailing list<br>
<a href="mailto:DPRGlist@lists.dprg.org" target="_blank">DPRGlist@lists.dprg.org</a><br>
<a href="http://lists.dprg.org/listinfo.cgi/dprglist-dprg.org" rel="noreferrer" target="_blank">http://lists.dprg.org/listinfo.cgi/dprglist-dprg.org</a><br>
</blockquote></div>