Author Topic: Measuring ship movement using Gyroscope, Accelerometer and Magnetometer  (Read 9191 times)

0 Members and 1 Guest are viewing this topic.

Offline SjoertdbTopic starter

  • Contributor
  • Posts: 31
  • Country: nl
Dear All :),

I have been assigned with the task to develop a system that detects the azimuth (pitch and roll) of a inland ship using a gyroscope, an accelerometer and a magnetometer.
The system to be build has its main function to tell the change in azimuth (
Since accelerometers and gyroscopes suffer from random walk, temperature influence and bias instability, there are a few options i've come up with. 
I have been doing research to this topic, and I've come to the following possible solutions for a possible design approach:

1. Using a (cheaper) MEMS 9 DoF,  consisting of a MEMS  3 Axis Accelerometer, 3 Axis gyroscope and 3 Axis magnetometer in one package like the Invensense MPU-9250,  with filtering options like Kalman or a complementary filter. (Like this one: http://eu.mouser.com/applications/sensor_solutions_mems/) I'll be using an Atmel SAMV71 micro for this.

2. Using a more expensive and more precise single axis gyroscope (And add two more for a 3-axis system), and seperate magnetometer and accelerometer for measuring position and velocity

3. Use 4 All-in-One 9 DoF sensors, and average all sensor outputs. (A thesis report here concludes that the noise levels reduce by 1 / sqrt(Amount of samples), so 16 sensors appearantly in 4 times better readings http://epublications.marquette.edu/cgi/viewcontent.cgi?article=1326&context=theses_open)

Note: There will be GPS onboard, maybe the NMEA data from the GPS can be used to correct the position over time? A small offset to be integrated in the accelerometer reading will result in a huge error over time. (because of the double integration of the acceleration)

Is this a good design approach, and wich one would you choose? Maybe there is a better approach?
Thanks in advance!  :-+

Kind regards,

Sjoert
Netherlands

 

Online Fungus

  • Super Contributor
  • ***
  • Posts: 16642
  • Country: 00
Re: Measuring ship movement using Gyroscope, Accelerometer and Magnetometer
« Reply #1 on: February 24, 2017, 10:15:24 am »
It's a tricky problem.  :popcorn:

I wouldn't rely too much on gyroscopes for anything. They sound good on paper but any method that relies on accumulating/integrating sensor values over time simply doesn't work reliably (in my experience).

Multiple magnetometers seems like a good bet but they'll need to be mounted outside the ship away from any metal structures and the earth's magnetic field varies as you sail around.

You can probably compensate for the varying magnetic field by recalibrating via. a long-term average of the accelerometers (eg. average over a minute).

 
The following users thanked this post: Sjoertdb

Offline daqq

  • Super Contributor
  • ***
  • Posts: 2302
  • Country: sk
    • My site
Re: Measuring ship movement using Gyroscope, Accelerometer and Magnetometer
« Reply #2 on: February 24, 2017, 10:28:36 am »
I don't suppose you could use two GPS receivers, one located on the stern and one located at the bow? You could get an orientation vector out of the difference of the two.

Believe it or not, pointy haired people do exist!
+++Divide By Cucumber Error. Please Reinstall Universe And Reboot +++
 
The following users thanked this post: Sjoertdb

Offline SjoertdbTopic starter

  • Contributor
  • Posts: 31
  • Country: nl
Re: Measuring ship movement using Gyroscope, Accelerometer and Magnetometer
« Reply #3 on: February 24, 2017, 10:38:00 am »
Quote
Multiple magnetometers seems like a good bet but they'll need to be mounted outside the ship away from any metal structures and the earth's magnetic field varies as you sail around.
First of all,
Many thanks for giving me a new vision on the design approah  :-+ :-+
Using multiple magnetometers sure is a good option! The pcb will be mounted in a plastic enclosure outside the ship, but I'm affraid things like AIS cause lots of noise for the magnetometers. Shielding like you would normally do on like an RF-modem doesnt work in this case.

Quote
You can probably compensate for the varying magnetic field by recalibrating via. a long-term average of the accelerometers (eg. average over a minute).

 :-+ :-+ That's an idea i'm going to do some research about.

I really appreciate your input
Thanks!
 

Offline SjoertdbTopic starter

  • Contributor
  • Posts: 31
  • Country: nl
Re: Measuring ship movement using Gyroscope, Accelerometer and Magnetometer
« Reply #4 on: February 24, 2017, 10:40:56 am »
Quote
I don't suppose you could use two GPS receivers, one located on the stern and one located at the bow? You could get an orientation vector out of the difference of the two.
:-+ Yeah, that might work as well! I'm using GALILEO GPS modules for this. GALILEO seems a precise measurement. 

[Update] I forgot to tell that the product I'm working on is a unit to be placed on a ship as a single unit. That means its impossible to place two GPS recievers at the stern and bow as it has to be inside one unit...
« Last Edit: February 24, 2017, 10:53:21 am by Sjoertdb »
 

Offline daqq

  • Super Contributor
  • ***
  • Posts: 2302
  • Country: sk
    • My site
Re: Measuring ship movement using Gyroscope, Accelerometer and Magnetometer
« Reply #5 on: February 24, 2017, 10:56:57 am »
Also, be wary of MEMS magnetomers - you REALLY need to calibrate them, or at least have some compensations. The individual axis have wildly different offsets and gains - you can get an error of 30deg when calculating the magnetic heading from a raw uncalibrated magnetomer, at least that was the case in LSM9DS0 which I used. Calibration/compensation is a relatively simple matter.
Believe it or not, pointy haired people do exist!
+++Divide By Cucumber Error. Please Reinstall Universe And Reboot +++
 
The following users thanked this post: Sjoertdb

Offline SjoertdbTopic starter

  • Contributor
  • Posts: 31
  • Country: nl
Re: Measuring ship movement using Gyroscope, Accelerometer and Magnetometer
« Reply #6 on: February 24, 2017, 11:08:57 am »
Quote
Also, be wary of MEMS magnetomers - you REALLY need to calibrate them, or at least have some compensations. The individual axis have wildly different offsets and gains - you can get an error of 30deg when calculating the magnetic heading from a raw uncalibrated magnetomer, at least that was the case in LSM9DS0 which I used. Calibration/compensation is a relatively simple matter.

An offset of 30 degrees with raw data is huge! Maybe i can fine tune it with a complementairy filter or a kalman implementation.
Calibration is needed, clear. Thanks daqq!  :-+ :-+
 

Offline daqq

  • Super Contributor
  • ***
  • Posts: 2302
  • Country: sk
    • My site
Re: Measuring ship movement using Gyroscope, Accelerometer and Magnetometer
« Reply #7 on: February 24, 2017, 11:12:28 am »
Quote
Maybe i can fine tune it with a complementairy filter or a kalman implementation.
You can't - this is not a time thing. The signal is relatively low noise, but has a significant offset and gain difference. This is a physical thing. But the compensation is relatively easy.

See:
https://github.com/kriswiner/MPU-6050/wiki/Simple-and-Effective-Magnetometer-Calibration
http://diydrones.com/profiles/blogs/advanced-hard-and-soft-iron-magnetometer-calibration-for-dummies
https://www.ecnmag.com/article/2014/12/magnetometer-2d-calibration-accurate-angle-computation

Edit: That said, you can (have to) do another compensation when you add, say, a magnetic metal screw somewhere near the magnetomers.
Believe it or not, pointy haired people do exist!
+++Divide By Cucumber Error. Please Reinstall Universe And Reboot +++
 
The following users thanked this post: Sjoertdb

Online Fungus

  • Super Contributor
  • ***
  • Posts: 16642
  • Country: 00
Re: Measuring ship movement using Gyroscope, Accelerometer and Magnetometer
« Reply #8 on: February 24, 2017, 11:21:30 am »
Also, be wary of MEMS magnetomers - you REALLY need to calibrate them, or at least have some compensations. The individual axis have wildly different offsets and gains - you can get an error of 30deg when calculating the magnetic heading from a raw uncalibrated magnetomer, at least that was the case in LSM9DS0 which I used. Calibration/compensation is a relatively simple matter.

Sure, but he's not trying to find where north is, he's trying to measure angles relative to vertical.

Once you establish 'vertical' (eg. by a median of accelerometer readings over a minute) then magentometers should be able to measure angles relative to that, no problem (assuming no interference).
« Last Edit: February 24, 2017, 11:26:18 am by Fungus »
 
The following users thanked this post: Sjoertdb

Offline SjoertdbTopic starter

  • Contributor
  • Posts: 31
  • Country: nl
Re: Measuring ship movement using Gyroscope, Accelerometer and Magnetometer
« Reply #9 on: February 24, 2017, 11:43:46 am »
Quote
You can't - this is not a time thing. The signal is relatively low noise, but has a significant offset and gain difference. This is a physical thing. But the compensation is relatively easy.
Quote
Once you establish 'vertical' (eg. by a median of accelerometer readings over a minute) then magentometers should be able to measure angles relative to that, no problem (assuming no interference).

 :-+ :-+ Thanks for your input guys! Thanks for the links. I'm glad to hear that magnetometer calibration is relatively easy to do in C.
Also, the accelerometer mean of a number of samples is perfect for finding 'Vertical' :-+ :-+
 

Online cgroen

  • Supporter
  • ****
  • Posts: 631
  • Country: dk
    • Carstens personal web
Re: Measuring ship movement using Gyroscope, Accelerometer and Magnetometer
« Reply #10 on: February 24, 2017, 11:50:05 am »
Sjoert,
if you go the 9DOF IMU way, please have a look at Bosch BNO055. I have used both MPU6050 and MPU9150 and found them to be, errr, "funny" to work with (lots and lots of code required on the host processor. The BNO055 has everything included oncjip (it has its own ARM Cortex M0 CPU), you talk with it using a UART or I2C (I use I2C in my projects) and it delivers Euler angles, Quaterions, acceleration, and what not.
Seems to do a really good job in my opinion (lots of eval boards you can get to test it out if needed).
 
The following users thanked this post: electr_peter, Sjoertdb

Online Fungus

  • Super Contributor
  • ***
  • Posts: 16642
  • Country: 00
Re: Measuring ship movement using Gyroscope, Accelerometer and Magnetometer
« Reply #11 on: February 24, 2017, 12:00:49 pm »
I'm glad to hear that magnetometer calibration is relatively easy to do in C.

I'm sure there's a lot of demons hiding in the math though.  :popcorn:

 
The following users thanked this post: Sjoertdb

Online Fungus

  • Super Contributor
  • ***
  • Posts: 16642
  • Country: 00
Re: Measuring ship movement using Gyroscope, Accelerometer and Magnetometer
« Reply #12 on: February 24, 2017, 12:03:37 pm »
Disclaimer: I don't know is how bad the changes in magnetic field can be when you're out at sea.

Will there be places on earth where it suddenly tells you you're listing at 60 degrees?  :popcorn:

 
The following users thanked this post: Sjoertdb

Offline tatus1969

  • Super Contributor
  • ***
  • Posts: 1273
  • Country: de
  • Resistance is futile - We Are The Watt.
    • keenlab
Re: Measuring ship movement using Gyroscope, Accelerometer and Magnetometer
« Reply #13 on: February 24, 2017, 12:35:41 pm »
I did exactly this three years ago, and it seems that we have the same target application (vessel load balancing). I used an Analog Devices 9DOF module, I think it was an ADIS16364. The final system achieved +-0.2° angular error, there was no way to get better at these levels of sensor output noise.
Is it only average azimuth and pitch that you need to measure? Or does your system need to capture realtime pitch/roll movements? If the latter would not be needed, it would be enough to use only a 3DOF accelerometer, and only measure and low-pass filter the gravitational force vector. That would completely eliminate the gyroscope and its random walk from the equation, and you could achieve much higher precision at lower cost.
« Last Edit: February 24, 2017, 12:40:06 pm by tatus1969 »
We Are The Watt - Resistance Is Futile!
 
The following users thanked this post: Sjoertdb

Offline SjoertdbTopic starter

  • Contributor
  • Posts: 31
  • Country: nl
Re: Measuring ship movement using Gyroscope, Accelerometer and Magnetometer
« Reply #14 on: February 24, 2017, 12:52:08 pm »
I am glad i hear the experiences of some chips out there. I've been considering using the MPU-9250 (lots of code required i think, just like the MPU-6050 and 9150)

Thanks for suggesting some good platforms to work with, i will have a look at the BOSCH sensor and the ADIS16364. thanks for suggesting, tatus1969 and cgroen :)  :-+ :-+ :-+ :-+

Quote
Is it only average azimuth and pitch that you need to measure? Or does your system need to capture realtime pitch/roll movements? If the latter would not be needed, it would be enough to use only a 3DOF accelerometer, and only measure and low-pass filter the gravitational force vector.
Yes, its for an antenna stabilization system (in case the signal gets lost). So, its average azimuth indeed. Its basically, what angle did the boat travel in order to get the signal back.

Lots of math indeed :P

Quote
The BNO055 has everything included oncjip (it has its own ARM Cortex M0 CPU), you talk with it using a UART or I2C (I use I2C in my projects) and it delivers Euler angles, Quaterions, acceleration, and what not.
  :-+ :-+ I'll have a look at it. Thanks!
 

Offline Conrad Hoffman

  • Super Contributor
  • ***
  • Posts: 1930
  • Country: us
    • The Messy Basement
Re: Measuring ship movement using Gyroscope, Accelerometer and Magnetometer
« Reply #15 on: February 24, 2017, 02:30:03 pm »
I know nothing about this, so take ideas with a grain of salt. 1) GPS usually has lousy altitude accuracy unless using differential surveying units, making it questionable for angle measurements without a huge baseline. 2) Could you make a damped pendulum sensor, maybe a mass hanging in an oil bath, with magnetic or photoelectric or capacitative position sensing? 3) Same thing, but with a spring rod holding the mass so the travel/degree is limited and the size can be reduced?
 
The following users thanked this post: Sjoertdb

Offline vealmike

  • Regular Contributor
  • *
  • Posts: 192
  • Country: gb
Re: Measuring ship movement using Gyroscope, Accelerometer and Magnetometer
« Reply #16 on: February 24, 2017, 02:42:06 pm »
Do some reading on the Kalman filter.
Basically it combines two sources of the same data & predicts the next data point.
The further away from the prediction that the next measurement is, the more filtering is applied.

 The filter can be tuned to take into physical constraints, eg. mass and therefore inertia.
HTH
 
The following users thanked this post: Sjoertdb

Offline daqq

  • Super Contributor
  • ***
  • Posts: 2302
  • Country: sk
    • My site
Re: Measuring ship movement using Gyroscope, Accelerometer and Magnetometer
« Reply #17 on: February 24, 2017, 03:11:53 pm »
Do they make MEMS (or reasonably small) gyrocompasses? Seems like if you mounted a gyrocompass onto the antenna being positioned you should be able to point it where it's supposed to be regardless of the ship?
Believe it or not, pointy haired people do exist!
+++Divide By Cucumber Error. Please Reinstall Universe And Reboot +++
 
The following users thanked this post: Sjoertdb

Offline mubes

  • Regular Contributor
  • *
  • Posts: 237
  • Country: gb
  • Do Not Boil
Re: Measuring ship movement using Gyroscope, Accelerometer and Magnetometer
« Reply #18 on: February 25, 2017, 10:58:06 pm »
Sjoert,

If you only require Roll and Pitch and you can fix the unit in a known orientation then I don't think you need a Magnetometer, which helps remove a whole load of complexity from the situation.... Having a Gyrometer in conjunction with an Accelerometer means you will get a faster response to impulses and the additional sensor helps remove noise from the system.  You can easily get 500Hz response even with a low end sensor and 4KHz sampling is supported by something like a MPU-9250.

Edit: actually, I'm not sure what you gain via a magnetometer since the movements you want are related to the transverse and longitudinal axes of the vessel, not the earth, so the fixing is the important thing unless you want to be doing some interesting math on the sample data afterwards.

Lookup Mahony and Sedgwick Quaternions (e.g. http://x-io.co.uk/open-source-imu-and-ahrs-algorithms/)....you can use them in '9D' (Gryo, Acc, Magno) or '6D' (Gyro, Acc) mode.  Beware though that there appears to be a calculation error in the code on that site and you will need to replace the Gradient Descent calcuation in the Sedgwick code to make it fly properly.

I have small boards (35x50mm) with a STM32L151 on them that can do exactly this. Since you're in NL I could possibly help if you are looking for a leg up with a (semi-)commercial solution so I will send you a PM with further information. I don't want to be plying for work or advertising on the forum.

Regards
DAVE
« Last Edit: February 25, 2017, 11:55:58 pm by mubes »
 
The following users thanked this post: 3db, Sjoertdb

Online Kleinstein

  • Super Contributor
  • ***
  • Posts: 14172
  • Country: de
Re: Measuring ship movement using Gyroscope, Accelerometer and Magnetometer
« Reply #19 on: February 26, 2017, 10:07:05 am »
The normal gyro and accelerometer should be enough. The gyro for the faster movements and the accelerometer to give the low frequency / long time direction and correct drift of the gyros. With a ship, I don't think fast sampling is an issue - it is more that the typical frequencies are rather low for the gyro. So the quality (stability of drift rate, LF noise) of the gyro could be an issue.
I don't think a magnetic compass would help very much, as it usually is rather noisy and would not work in all directions anyway. It is only the heading of the ship where an compass would be needed as the accelerometer can measure that and a gyro only system would drift, unless super high quality.

At night is is more like a camera to watch the stars would be an option if super low noise is needed.
 
The following users thanked this post: Sjoertdb

Offline mubes

  • Regular Contributor
  • *
  • Posts: 237
  • Country: gb
  • Do Not Boil
Re: Measuring ship movement using Gyroscope, Accelerometer and Magnetometer
« Reply #20 on: February 26, 2017, 12:29:42 pm »
The fast sampling rate allows you to reduce the sensor noise. Chips like the 9250 have a LPF built in which helps remove things like vibration. I would be a bit surprised if you needed anything more complex than that.

Dave
 
The following users thanked this post: Sjoertdb

Offline SjoertdbTopic starter

  • Contributor
  • Posts: 31
  • Country: nl
Re: Measuring ship movement using Gyroscope, Accelerometer and Magnetometer
« Reply #21 on: February 26, 2017, 08:23:56 pm »
Dear all,

I appreciate your input! Many thanks from this side!  :-+ :-+ :-+
 

Offline radar_macgyver

  • Frequent Contributor
  • **
  • Posts: 697
  • Country: us
Re: Measuring ship movement using Gyroscope, Accelerometer and Magnetometer
« Reply #22 on: February 26, 2017, 08:54:38 pm »
I'm working on a similar system (antenna stabilization) but with a commercial sensor module from Kongsberg Norway. The sensor module contains three gyros and a three-axis accelerometer, all three gyros are low-drift, high precision (mechanical) units. Ship's heading is sensed using two GPS receivers that are lined up bow-to-stern. Since it's a commercial system, I don't know much about the internal algorithms used, but the documentation does reference using an EKF to fuse data from the various sensors. Stated accuracy is 0.01 degrees for pitch and roll. Yaw is worse, about 0.1 degree.

It should be possible to get better than 0.1 degrees with modern MEMS accelerometers alone, but if you want to dynamically compute the roll, pitch and yaw, I'd strongly recommend using an EKF to combine gyro data with the accelerometers and GPS. Consider using one of the Trimble carrier phase tracking GPS receivers with decent antennas to block multipath reception.
 
The following users thanked this post: Sjoertdb

Offline SjoertdbTopic starter

  • Contributor
  • Posts: 31
  • Country: nl
Re: Measuring ship movement using Gyroscope, Accelerometer and Magnetometer
« Reply #23 on: February 27, 2017, 08:40:25 am »
Quote
The sensor module contains three gyros and a three-axis accelerometer, all three gyros are low-drift, high precision (mechanical) units.
Thanks for the reply  :-+ I have to use MEMS sensors for this job, because a commercial unit is too expensive. I'll have a look at how such an EKF works.
Many thanks radar_macgyver!
 

Offline 3db

  • Frequent Contributor
  • **
  • Posts: 331
  • Country: gb
Re: Measuring ship movement using Gyroscope, Accelerometer and Magnetometer
« Reply #24 on: February 27, 2017, 09:20:34 am »
Gyros can be pretty stable.
I have experience of a vertical gyro used to stabilise an echo sounder transducer against the roll and pitch of the vessel.
 
That system worked very well.
There are also some gyro compasses  that when you rotate the compass enclosure quickly  it's as if the compass card was fixed to the deck.

3db



 
The following users thanked this post: Sjoertdb


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf