This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
IMU Not behaving correctly.
#1
Hi,

I have a MacArthur HAT with the recommended IMU ... so far, so good.  It is recognised by PyPilot and I can see the "calibration" stuff ... I did the "6 sides of a box" thing and the boat is "levelled".

I've been told to leave the compass calibration "unlocked" ... and I've tried sailing around in circles, but its not working right. sailing a circle I see heading between aroud 320 degrees through 0 to 60 degrees ... looking at the calibration screens (which mean very little to me)  I can see a green circle of dots, but it is vertical, not horizontal.

Photos attached, perhaps someone could shed some light?

I don't really nderstand the need for all this calibration complexity ... mobile phones seem to be able to manage this without difficulty straight out of the box. Is it not possible to just copy whatever algorithm Android uses?

   
Reply
#2
There may be something wrong with your sensors

mobile phones do not manage this. I am not sure what you refer to but you can hack in other algorithms, the point is, the phones do not calibrate in a way that gives better accuracy, you probably just have unusable sensors

Are pitch and roll really near zero under alignment? Could there be any potential magnetic distortions?
Reply
#3
IMU would know where magnetic north is and where
gravitational force is directed.
What it doesn’t know how you installed it
and oriented relative to boat body.
So you need to do calibration type ‘boat is leveled’
and you need to enter offset for heading
using regular compass (IMU doesn’t know where your bow is)

The way pypilot is written after doing it
you need to wait (was it couple minutes)
before restarting pypilot or pi
because pypilot saves calibration that infrequently.

You also need to check permissions on file system
that PyPilot actually can save calibration file and that it’s
not read-only for it.
Download BBN Marine OS for raspberry pi 

https://bareboat-necessities.github.io/m...at-os.html

Video of actual installation:

https://www.youtube.com/watch?v=3zMjUs2X3qU


Reply
#4
(2023-06-12, 07:43 AM)mgrouch Wrote: IMU would know where magnetic north is and where
gravitational force is directed.
What it doesn’t know how you installed it
and oriented relative to boat body.
So you need to do calibration type ‘boat is leveled’
and you need to enter offset for heading
using regular compass (IMU doesn’t know where your bow is)

The way pypilot is written after doing it
you need to wait (was it couple minutes)
before restarting pypilot or pi
because pypilot saves calibration that infrequently.

You also need to check permissions on file system
that PyPilot actually can save calibration file and that it’s
not read-only for it.

Yes, done all that.  The Boat levels fine, angles seem correct for pitch and roll.

Yes, I set the compass offset.

I assume PyPilot will issue some sort of warnig if it can't write the calibration data.   I've no idea where it stores it, but this is a standard OpenPlotter install, no fiddling, I assume that OpenPlotter has the directory structure and permissions set up correctly, I could check, but not sure where it stores the cal stuff, any clues?

(2023-06-12, 03:16 AM)seandepagnier Wrote: There may be something wrong with your sensors

mobile phones do not manage this.  I am not sure what you refer to but you can hack in other algorithms, the point is, the phones do not calibrate in a way that gives better accuracy, you probably just have unusable sensors

Are pitch and roll really near zero under alignment?  Could there be any potential magnetic distortions?

I don't think my sensors are faulty ... the pitch/roll seems to be correct.

The "green circle" appears to be correct in as much as it goes through 360 degrees when the boat is turned through a circle ... what seems to be wrong is that as the boat goes around the "green circle" the resolved vector is from the centre of the sphere to the point on the circle ... that would explain the restricted range.

My feeling is that green circle should be co-planar with the red circle, not at 90 degrees to it?   Is it normal for that green circle to display like that on the display?

I know on the MPU9250 sensor I have the following notes in some Arduinio code I have used before:

Quote:  // Sensors x (y)-axis of the accelerometer is aligned with the y (x)-axis of
  // the magnetometer; the magnetometer z-axis (+ down) is opposite to z-axis
  // (+ up) of accelerometer and gyro!


Is it possible the sensor used on this board has some other convention?  It looks to me as if the magentometer of this IMU is not aligned as expected with the accelerometers ...

The sensor I have is the ICM20948, which is recommended with the MacArthur HAT, is it possible this sensor has a different relationship between the axes of the magnetometer and accelerometers to the 9250 sensor?
Reply
#5
Right, I have bought another IMU, tested it on an Arduino and it works fine with some basic quaternion software ... it is an 9255 IMU, I installed it on my boat and the result is the same, this is now 3 IMU that display the same issue so I don't believe the "it is a faulty sensor" reason.

Again, I fitted the new sensor, selected calibration, cleared the Accel calibration, put the sensor on 6 sides each for a few seconds ... waited a few minutes then locked the calibration.

Next I pressed "BOAT IS LEVEL" and the boat image became level.

Finally I switched to compass, motored slowly in 2 circles ... I saw a green circle of dots (but on the y-z plane) I saw no "calibration points" in light blue, I saw no "sigma points" in yellow.

Pypilot is writing to the config file, I can see the date changing, but the config data that is written for the compass is [[0.0,0.0,0.0,80.0,0.0],[1.0,1.0],0.0] which is the default data, I have never seen anything else written. I have never seen anything in the text box at the bottom left.

I don't think this is a sensor problem (3 sensors now, Moitessier hat and 2 i2c sensors), I don't think this is a file permissions problem.

This is a Pi4, latest OpenPlotter, MacArthur HAT ... I am on the boat tonight and tomorrow, then gone for 2 weeks (sailing another boat) ... I would really like to have this working for my trip to Scotland.

If I run ps -ef | grep imu I can see 4 instances of /usr/local/bin/pypilot_boatimu -q running ... as well as the openplotter pypilot stuff, calibration etc, is that correct?

I can also see that /usr/local/bin/pypilot_boatimu -q is running, is that correct?
Reply
#6
There are several processes so it is normal to see more than one instance.

You said you locked the calibration? Could this be the issue? There should be a calibration log.

The screenshots of the calibration you posted do not look normal. With 3 sensors it is unlikely they are all bad. It is most likely they are mounted in a bad location with magnetic distortions.

Try stopping pypilot:
sudo service pypilot stop

Now run pypilot directly and post the output here:
pypilot
...

It is also possible to access the pypilot log through journalctl but I prefer this way for some reason.
Reply
#7
I locked the accel calibration, I did not lock the compass cal.

I can uderstand if this was steel boat, but this is a normal GRP boat, they are mounted in a normal place near my nav station ...  when I had the Moitessier Hat it was in a different location, same problems.


OK, EDIT!   on Openplotter it seems the correct command is service pypilot_boatimu stop .... openplotter runs the boatimu service not the pypilot service so the errors in my earlier post were from 2 processes trying to talk to the IMU

when I run pypilot from the command line for more than 10 seconds, the entire pi crashes and reboots, but, here is what I get if I kill it before it does.

pi@openplotter:~ $ sudo service pypilot_boatimu stop
pi@openplotter:~ $ sudo pypilot
autopilot start 82.734137119
world magnetic model not available
ERROR loading wind.py cannot import name 'HeadingOffset' from partially initialized module 'pypilot.autopilot' (most likely due to a circular import) (/usr/local/lib/python3.9/dist-packages/pypilot/autopilot.py)  cannot import name 'HeadingOffset' from partially initialized module 'pypilot.autopilot' (most likely due to a circular import) (/usr/local/lib/python3.9/dist-packages/pypilot/autopilot.py)
imu process 1593
nmea process 1597
listening on port 20220 for nmea connections
loading servo calibration /root/.pypilot/servocalibration
gps process 1600
WARNING: using default servo calibration!!
Available Pilots: ['absolute', 'basic']
made imu process realtime
Using settings file RTIMULib.ini
Settings file RTIMULib.ini loaded
Detected MPU9250/MPU9255 at standard address
Using fusion algorithm Kalman STATE4
IMU Name: MPU-925x
min/max compass calibration not in use
Using ellipsoid compass calibration
Using accel calibration
pypilotServer process 1605
failed to load pypilot.conf [Errno 2] No such file or directory: '/root/.pypilot/pypilot.conf'
backup data failed as well [Errno 2] No such file or directory: '/root/.pypilot/pypilot.conf.bak'
server setup has 6 pipes
autopilot init complete 83.011899728
server add socket ('127.0.0.1', 40646)
autopilot iteration running too slow 0.08015876300000002
zeroconf addresses ['192.168.43.150', '127.0.0.1'] 2
autopilot iteration running too slow 0.07356268600000249
gps filter process 1601
MPU-925x init complete
autopilot iteration running too slow 0.0914683889999992
read imu running too _slowly_ 0.04118313499999715 0.05
autopilot iteration running too slow 0.06362938600000234
imu rate set to rate 20
read imu running too _slowly_ 0.06626253900000734 0.05
autopilot iteration running too slow 0.07731938799999227
gpsd connected
GPSD devices []
^CTraceback (most recent call last):
  File "/usr/local/bin/pypilot", line 33, in <module>
    sys.exit(load_entry_point('pypilot==0.36', 'console_scripts', 'pypilot')())
  File "/usr/local/lib/python3.9/dist-packages/pypilot/autopilot.py", line 453, in main
  File "/usr/local/lib/python3.9/dist-packages/pypilot/autopilot.py", line 445, in iteration
    time.sleep(dt)
  File "/usr/local/lib/python3.9/dist-packages/pypilot/autopilot.py", line 186, in cleanup
    raise KeyboardInterrupt # to get backtrace on all processes
KeyboardInterrupt
closing autopilot
close watchdog
Reply
#8
And if I run the pypilot_boatimu service and look at the journalctl output:

Jun 23 12:47:57 openplotter systemd[1]: Started pypilot boatimu.
Jun 23 12:47:57 openplotter sudo[2482]: pi : PWD=/home/pi/.pypilot ; USER=root ; COMMAND=/usr/bin/chrt -po>
Jun 23 12:47:57 openplotter sudo[2482]: pam_unix(sudoConfusedession): session opened for user root(uid=0) by (uid=1000)
Jun 23 12:47:57 openplotter sudo[2482]: pam_unix(sudoConfusedession): session closed for user root
Jun 23 12:47:57 openplotter sudo[2485]: pi : PWD=/home/pi/.pypilot ; USER=root ; COMMAND=/usr/bin/chrt -pf>
Jun 23 12:47:57 openplotter sudo[2485]: pam_unix(sudoConfusedession): session opened for user root(uid=0) by (uid=1000)
Jun 23 12:47:57 openplotter sudo[2485]: pam_unix(sudoConfusedession): session closed for user root
Jun 23 12:47:57 openplotter pypilot_boatimu[2481]: Settings file RTIMULib.ini loaded
Jun 23 12:47:57 openplotter pypilot_boatimu[2481]: Detected MPU9250/MPU9255 at standard address
Jun 23 12:47:57 openplotter pypilot_boatimu[2481]: Using fusion algorithm Kalman STATE4
Jun 23 12:47:57 openplotter pypilot_boatimu[2481]: min/max compass calibration not in use
Jun 23 12:47:57 openplotter pypilot_boatimu[2481]: Using ellipsoid compass calibration
Jun 23 12:47:57 openplotter pypilot_boatimu[2481]: Using accel calibration
Jun 23 12:47:57 openplotter sudo[2489]: pi : PWD=/home/pi/.pypilot ; USER=root ; COMMAND=/usr/bin/chrt -pi>
Jun 23 12:47:57 openplotter sudo[2489]: pam_unix(sudoConfusedession): session opened for user root(uid=0) by (uid=1000)
Jun 23 12:47:57 openplotter sudo[2489]: pam_unix(sudoConfusedession): session closed for user root
Jun 23 12:47:57 openplotter pypilot_boatimu[2481]: MPU-925x init complete

And ... if I stop pypilot_boatimu service and run pypilot_boatimu directly ...

pi@openplotter:~ $ /usr/local/bin/pypilot_boatimu
pypilotServer process 2988
imu process 2986
server setup has 3 pipes
made imu process realtime
Using settings file RTIMULib.ini
Settings file RTIMULib.ini loaded
Detected MPU9250/MPU9255 at standard address
Using fusion algorithm Kalman STATE4
IMU Name: MPU-925x
min/max compass calibration not in use
Using ellipsoid compass calibration
Using accel calibration
zeroconf addresses ['192.168.43.150', '127.0.0.1'] 2
server add socket ('192.168.43.150', 55498)
MPU-925x init complete
imu rate set to rate 203 roll 0.13364886139519022 heading 335.5622884859749
setting initial gyro bias [0.524, -0.423, -0.708]
calibration loaded, starting 2984697906765890996 heading 334.7116209768078 987
pitch -0.00040764365217966115 roll -0.016823704577647522 heading 337.07637926711
Reply
#9
And the behaviour when I do a 360 circle in the boat ...

[Image: 20230622_170044.jpg]

[Image: 20230622_170228.jpg]

[Image: 20230622_170302.jpg]
Reply
#10
if you run pypilot as root the pi may reboot.    Thanks for mentioning this again.  When it is run as a service it is not run as root.

I did find a bug in the unstable branch of pypilot preventing calibration when running pypilot_boatimu, but I am assuming you are using master branch?

Could you try running the pypilot service (not pypilot_boatimu) as a regular user?  There should be debugging output in the console on the lower left every 30 seconds or so, your screenshots do not show this.

As for the screenshots, these indicate the sensors are not leveled or the sensors are different from most.  The red cone with white line should be parallel yours seem perpendicular which may indicate as you suggest that the driver needs to swap some axes.  It is strange because these chips are 9 axis parts and I have never seen alternate sensor orientations unless it is a different board.

Can you post a picture of the exact sensor you are using?  Where did you get it?


Attached Files Image(s)
       
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)