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:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pypilot compass calibration getting lost
#1
Hi,  I have just updated my system to OpenCPN 5.6.2 with Pypilot Plugin 0.34.4.0 and the latest Pypilot version from Github.  All seems to be working fine but every time I re-start Pypilot I have to re-calibrate the compass as all the previous data shown on the plugin calibration page is zero.  Pypilot is definitely reading data from pypilot.conf; I can stop pypilot, edit pypilot.conf eg by changing imu.compass.calibration from false to true, then restart pypilot and the true box is ticked on the plugin calibration page.  However if I untick the locked box, then stop pypilot and look at the .conf file, the imu.compass.calibration is still set to true.  So it would appear that the .conf file is not being updated when changes are made using the plugin.  
All the other data in the .conf file (gains etc) seem to be updated OK. 
One other quick question: pypilot, pypilot.boayimu and pypilot.web are set up as services but pypilot_hat is not.  I have added a new file in /.config/autostart to run it at startup, but would it be better to run it as a service?
Many thanks
David
Reply
#2
Hi.

I am not sure why it is unable to store the calibration. If you see the calibration update it may take a minute or two to write to the config file. Otherwise maybe it doesn't have permission to write to the config file?

You can't just change the calibration to "true" since this the imu.compass.calibration normally contains the calibration coefficients.

keep in mind that pypilot should run or pypilot.boatimu but not both. Maybe you were running both?? Normally the pypilot hat service is managed similarly to the others as a service, but it may need more permissions.
Reply
#3
[attachment=1846 Wrote:seandepagnier pid='23300' dateline='1658707839']Hi.

I am not sure why it is unable to store the calibration.    If you see the calibration update it may take a minute or two to write to the config file.   Otherwise maybe it doesn't have permission to write to the config file?

You can't just change the calibration to "true" since this the imu.compass.calibration normally contains the calibration coefficients.

keep in mind that pypilot should run or pypilot.boatimu but not both.  Maybe you were running both??      Normally the pypilot hat service is managed similarly to the others as a service, but it may need more permissions.

Hi, many thanks for your reply.  I checked the permissions on the config file and it looks ok:
pi@openplotter:~/.pypilot $ ls -l pypilot*
-rw-r--r-- 1 pi root   34 Jul 23 18:38 pypilot_client.conf
-rw-r--r-- 1 pi pi   3075 Jul 25 11:45 pypilot.conf
-rw-r--r-- 1 pi pi   3075 Jul 24 21:54 pypilot.conf.bak
-rw-r--r-- 1 pi pi   3065 Jul 23 16:46 pypilot.conf.save

I also checked which services are running and it seems only pypilot     is:
pi@openplotter:~ $ systemctl status pypilot        
* pypilot.service - pypilot
   Loaded: loaded (/etc/systemd/system/pypilot.service; enabled; vendor preset: enabled)
   Active: active (running) since Thu 2019-02-14 10:11:59 GMT; 3 years 5 months 
 Main PID: 102 (pypilot)
    Tasks: 11 (limit: 2063)
 

pi@openplotter:~/.pypilot $ systemctl status pypilot_boatimu
* pypilot_boatimu.service - pypilot_boatimu
   Loaded: loaded (/etc/systemd/system/pypilot_boatimu.service; disabled; vendor preset: enabled)
   Active: inactive (dead)

pi@openplotter:~/.pypilot $ systemctl status pypilot_web
* pypilot_web.service - pypilot_web
   Loaded: loaded (/etc/systemd/system/pypilot_web.service; disabled; vendor preset: enabled)
   Active: inactive (dead)

I tried to set up pypilot_hat as a service (instead of using autostart), but get the same result as above:
pi@openplotter:~/.pypilot $ systemctl status pypilot_hat
* pypilot_hat.service - pypilot_hat
   Loaded: loaded (/etc/systemd/system/pypilot_hat.service; disabled; vendor preset: enabled)
   Active: inactive (dead)

and I am getting no response to gpio inputs or the virtual LCD screen.  This is not a problem as I can just go back to the autostart method of running it.
However, having to recalibrate the compass at the start of every trip is a bit of a pain.  I tried re-calibrating the compass using pypilot_control, but with the same result:  I got the compass working OK, then clicked on calibration locked, then rebooted and all calibration data was lost (see screenshot attached).  The compass was giving random readings.

Many thanks, as always, for you help.
Regards
David
Reply
#4
Yes, you need pypilot_hat for the gpio or lcd.

You are rebooting too fast. Wait 5 minutes and check the config file. It should update the file every few minutes. You shouldnt need to lock the calibration.

Perhaps it could be improved but consider it is writing to an sd card with (eventually) limited cycles, and some values update all the time, it should not constantly be rewriting those, so it would need to be aware of a significant calibration update.
Reply
#5
Hi Sean, I have done some more testing and have now disabled pypilot_boatimu and pypilot_web services and have pypilot_hat running from the autostart directory.  So now the only service running is pypilot.  If I stop pypilot and run it from the prompt I get:

pi@openplotter:~ $ pypilot        
autopilot start 965.860352699
world magnetic model not available
ERROR loading wind.py cannot import name 'HeadingOffset' from 'pypilot.autopilot' (/usr/local/lib/python3.7/dist-packages/pypilot/autopilot.py)   cannot import name 'HeadingOffset' from 'pypilot.autopilot' (/usr/local/lib/python3.7/dist-packages/pypilot/autopilot.py)
imu process 3592
nmea process 3596
listening on port 20220 for nmea connections
gps process 3599
loading servo calibration /home/pi/.pypilot/servocalibration
WARNING: using default servo calibration!!
Available Pilots: ['basic', 'basic2', 'basic3', 'absolute', 'simple']
warning: failed to open special file /dev/watchdog0 for writing cannot stroke the watchdog
made imu process realtime
Using settings file RTIMULib.ini
Settings file RTIMULib.ini loaded
Detected MPU9250/MPU9255 at standard address
pypilotServer process 3602
Using fusion algorithm Kalman STATE4
IMU Name: MPU-925x
min/max compass calibration not in use
Using ellipsoid compass calibration
Using accel calibration
server setup has 5 pipes
autopilot init complete 966.437365636
serialprobe removing gps device /dev/serial/by-id/usb-u-blox_AG_-_www.u-blox.com_u-blox_7_-_GPS_GNSS_Receiver-if00
autopilot iteration running too slow 0.08152242500000284
autopilot iteration running too slow 0.07350128900009167
server add socket ('127.0.0.1', 51894)
MPU-925x init complete
server add socket ('127.0.0.1', 51896)
autopilot iteration running too slow 0.1496633499999689
setting initial gyro bias [2.014, -3.165, -1.164]
imu rate set to rate 10
server add socket ('127.0.0.1', 51898)
gpsd connected
calibration loaded, starting 3590
GPSD devices ['/dev/ttyACM0']
servo probe ('/dev/ttyOP_arduino', 38400) 971.516375292
failed to open servo on: ('/dev/ttyOP_arduino', 38400) [Errno 2] could not open port /dev/ttyOP_arduino: [Errno 2] No such file or directory: '/dev/ttyOP_arduino'
server/client is running too _slowly_ 0.12416198199991868
autopilot iteration running too slow 0.1258177939999996
signalk process 3598
signalkread token eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkZXZpY2UiOiJweXBpbG90LTQwMTAxNTA5MTcwIiwiaWF0IjoxNjQ4NjQwNzQ4fQ.rPAKkNnYTQoD0UI-CKNPwdj7O_t9q46Nf_GLvSdVHwk
signalk zeroconf service add openplotter._http._tcp.local. _http._tcp.local.
signalk server found 192.168.1.117:3000
signalk zeroconf service add myrouter._http._tcp.local. _http._tcp.local.
signalk zeroconf service add WiserHeat034D42._http._tcp.local. _http._tcp.local.
signalk zeroconf service add Linksys03851._http._tcp.local. _http._tcp.local.
signalk probe... 192.168.1.117:3000
signalk found ws://192.168.1.117:3000/signalk/v1/stream?subscribe=none
signalk connected to ws://192.168.1.117:3000/signalk/v1/stream?subscribe=none
sensor found gps signalk GPsignalk
nmea probe ('/dev/ttyOP_arduino', 38400)
failed to open ('/dev/ttyOP_arduino', 38400) for nmea data [Errno 2] could not open port /dev/ttyOP_arduino: [Errno 2] No such file or directory: '/dev/ttyOP_arduino'
nmea probe ('/dev/ttyOP_arduino', 4800)
failed to open ('/dev/ttyOP_arduino', 4800) for nmea data [Errno 2] could not open port /dev/ttyOP_arduino: [Errno 2] No such file or directory: '/dev/ttyOP_arduino'
Exception converting signalk->pypilot unsupported operand type(s) for /: 'NoneType' and 'float' {'pypilot': {}, 'GP': {'navigation.position': {'longitude': -4.051491166666667, 'latitude': 50.316603}, 'navigation.courseOverGroundTrue': None, 'navigation.speedOverGround': 0.09877335835591701}}
Exception converting signalk->pypilot unsupported operand type(s) for /: 'NoneType' and 'float' {'pypilot': {}, 'GP': {'navigation.position': {'longitude': -4.051491166666667, 'latitude': 50.316603}, 

All looks OK (I don't have an arduino connected at the moment) except for the SignalK error, which I have not seem before. The Calibration Loaded message seems to indicate the config file has been loaded OK.

I then calibrated the Accelerometer and then the compass (see screenshot attached) and left the system running for a while.  The compass was reading correctly all the time.  I checked the pypilot.conf file and the compass calibration reading had been updated:

imu.gyrobias=[2.170, -3.104, -1.021]
imu.accel.calibration.locked=false
imu.accel.calibration.points=[[-1.477, -0.626, -0.342], [-1.490, -0.631, -0.256], [-1.511, -0.652, -0.135], [-1.162, -1.646, -1.325], [-1.520, -1.446, 0.644], [-0.289, -1.290, -0.154], [-1.197, -0.597, -0.341], [-0.800, -1.673, -1.230], [-1.284, -2.000, -0.395], [-1.189, -1.545, 0.699], [-2.000, -1.648, -0.360], [-0.230, -1.667, -0.276]]
imu.compass.calibration.locked=false
imu.compass.calibration.points=[[22.565, -26.972, -12.068], [0.357, -20.012, -21.695], [20.611, -49.877, -18.364], [12.677, -45.714, -19.003], [11.747, -32.099, -16.014], [13.487, -24.927, -14.874], [42.104, -30.923, -13.414], [5.981, -10.747, -21.193], [36.552, -51.640, -18.912], [10.365, -20.223, -16.448], [18.705, -40.635, -14.600], [24.066, -22.528, -12.068], [38.554, -24.056, -12.707], [45.774, -38.989, -15.125], [34.193, -15.944, -13.893], [48.943, -49.759, -98.025], [20.135, 1.035, -22.402], [40.436, -46.114, -16.562], [11.342, -35.861, -16.539], [5.576, -29.559, -18.569], [35.552, -10.441, -15.992], [29.785, -3.339, -18.569], [49.658, -41.776, -101.744], [23.256, -53.122, -19.938], [34.050, -45.479, -15.398], [35.432, -52.463, -19.505], [18.300, -12.252, -15.809], [36.934, -48.865, -102.177]]

I then re-booted the pi and the compass was not working at all and calibration values lost (see screenshot).  The OpenCPN Pypilot plugin is working fine, although I do have to click on the config button and then OK to get it to connect to pypilot.

As always, any help much appreciated!
Regards
David


Attached Files Image(s)
       
Reply
#6
(2022-07-31, 06:36 PM)drbarritt Wrote: Hi Sean, I have done
Exception converting signalk->pypilot unsupported operand type(s) for /: 'NoneType' and 'float' {'pypilot': {}, 'GP': {'navigation.position': {'longitude': -4.051491166666667, 'latitude': 50.316603}, 'navigation.courseOverGroundTrue': None, 'navigation.speedOverGround': 0.09877335835591701}}
Exception converting signalk->pypilot unsupported operand type(s) for /: 'NoneType' and 'float' {'pypilot': {}, 'GP': {'navigation.position': {'longitude': -4.051491166666667, 'latitude': 50.316603}, 
It is safe to ignore, it cant convert 'None' for course. I updated pypilot to handle None.

Quote:All looks OK (I don't have an arduino connected at the moment) except for the SignalK error, which I have not seem before. The Calibration Loaded message seems to indicate the config file has been loaded OK.

I then calibrated the Accelerometer and then the compass (see screenshot attached) and left the system running for a while.  The compass was reading correctly all the time.  I checked the pypilot.conf file and the compass calibration reading had been updated:

imu.gyrobias=[2.170, -3.104, -1.021]
imu.accel.calibration.locked=false
imu.accel.calibration.points=[[-1.477, -0.626, -0.342], [-1.490, -0.631, -0.256], [-1.511, -0.652, -0.135], [-1.162, -1.646, -1.325], [-1.520, -1.446, 0.644], [-0.289, -1.290, -0.154], [-1.197, -0.597, -0.341], [-0.800, -1.673, -1.230], [-1.284, -2.000, -0.395], [-1.189, -1.545, 0.699], [-2.000, -1.648, -0.360], [-0.230, -1.667, -0.276]]
imu.compass.calibration.locked=false
imu.compass.calibration.points=[[22.565, -26.972, -12.068], [0.357, -20.012, -21.695], [20.611, -49.877, -18.364], [12.677, -45.714, -19.003], [11.747, -32.099, -16.014], [13.487, -24.927, -14.874], [42.104, -30.923, -13.414], [5.981, -10.747, -21.193], [36.552, -51.640, -18.912], [10.365, -20.223, -16.448], [18.705, -40.635, -14.600], [24.066, -22.528, -12.068], [38.554, -24.056, -12.707], [45.774, -38.989, -15.125], [34.193, -15.944, -13.893], [48.943, -49.759, -98.025], [20.135, 1.035, -22.402], [40.436, -46.114, -16.562], [11.342, -35.861, -16.539], [5.576, -29.559, -18.569], [35.552, -10.441, -15.992], [29.785, -3.339, -18.569], [49.658, -41.776, -101.744], [23.256, -53.122, -19.938], [34.050, -45.479, -15.398], [35.432, -52.463, -19.505], [18.300, -12.252, -15.809], [36.934, -48.865, -102.177]]

I then re-booted the pi and the compass was not working at all and calibration values lost (see screenshot).  The OpenCPN Pypilot plugin is working fine, although I do have to click on the config button and then OK to get it to connect to pypilot.

As always, any help much appreciated!lo
Regards
David

What pypilot plugin version?


Can you try running as you had, then stop pypilot. Check the config file. Make sure the calibration is correct. Backup the pypilot.conf file. Now start pypilot again, make sure it works and doesnt reset calibration. Now reboot. Check the contents of the config file. It must be getting rewritten somewhere? If the config file has the correct file when you run pypilot it is ok?

You are the first to report this issue.
Reply
#7
Sean, my pypilot_plugin is v 0.34.4.0. I tried re-calibrating the compass, waiting for the pypilot.conf file to update, then made a copy of it. I then stopped pypilot (systemctl stop pypilot) restored the .conf file from the copy and re-started pypilot (systemctl start pypilot). However the compass calibration was still lost. What is the relationship between the calibration figures you see on the plugin calibration page and the values saved in the .conf file? They seem very different.
Thanks for sorting the SignalK error. I will uodate my pypilot from github.
Regards
David
Reply
#8
They are the same values. Wait until pypilot.conf updates with the values. Or check the file stamp etc..

no one has reported this as a problem so I am wondering maybe your permissions are wrong or?
Reply
#9
Hi Sean, I think I may have found the problem. I stopped pypilot and ran pypilot_boatimu. I got error messages about module 'scipy' not loaded. So I did a full update on my Pi and then installed scipy. I now get a different message when I run boatimu:
pi@openplotter:~ $ pypilot_boatimu
imu process 1244
pypilotServer process 1246
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
MPU-925x init complete
imu rate set to rate 10 roll -47.91751056758631 heading 32.21248148983579
setting initial gyro bias [1.96, -3.095, -1.064]
server add socket ('127.0.0.1', 38702)
failed import calibration fit libf77blas.so.3: cannot open shared object file: No such file or directory

What is lib77blas.so.3? The calibration process does not seem to work at all now.

Regards
David
Reply
#10
now you have broken dependencies. You would need blas.

If you run "python3"
then "import scipy" and get this error... it is not a pypilot issue anymore.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)