Hysen Labs
Open-source project
bareboat-necessities/ocean-imu avatar
bareboat-necessities

ocean-imu

Collection of algorithms for IMU data processing in marine environment. Boat heave, wave direction, wave height, attitude (yaw, roll, pitch), tilt compensated compass, ship MRU, GPS fusion, NMEA sensors with IMU, marine AHRS/INS, marine Kalman filters, Arduino/MCU code for marine IMU. Aimed for quality

30 stars4 forksC++MIT
DEEP OPEN-SOURCE ANALYSIS

Ocean-imu processes marine sensor data in C++

A library of inertial and wave algorithms for ships, built to fuse IMU signals into attitude, heave, and wave direction estimates.

Why marine IMU needs different filters

Ocean-imu is a collection of marine IMU and wave processing algorithms written in modern C++. The README states the code targets sensor fusion, sea state estimation, and simulation driven validation, and it is designed for a ship Motion Reference Unit, a Marine Inertial Navigation System, and an Attitude and Heading Reference System. The motivation section explains that a marine AHRS cannot simply reuse the popular drone and aerospace IMU filters without change.

The reason is physical. In aerospace, motion is often modeled as rotation about the center of mass, as with a satellite, and drones usually initialize while sitting still before takeoff, so the accelerometer reads a clean gravity direction. On a ship, the device may start while already moving through waves and wind, with heave, roll, pitch, and translational accelerations all mixed into the sensor signals. A filter built for a calm takeoff therefore fails at sea because it would trust wave distorted acceleration as if it were pure gravity. The README says a ship AHRS or INS instead needs wave aware initialization, motion compensation, and tuning that adapts to different sea states on the fly. This section frames the whole library as a response to that mismatch, and it tells the reader why the usual filters are not enough rather than just listing features.

What the algorithms compute

The README describes a set of outputs the algorithms produce. Beyond a tilt compensated compass and basic roll, pitch, and rate of turn sensors, the library adds corrections for wave induced motion. It reconstructs the three dimensional displacement of a vessel in real time, noting that heave is strongly observable while surge and sway are only weakly observable, and it estimates the apparent wave direction relative to the vessel doing the observing. These are practical quantities for anyone operating or studying a ship, because heave and wave direction feed into comfort, safety, and operational decisions.

The description also mentions GPS fusion and NMEA sensors used together with the IMU, and it names marine Kalman filters as part of the collection. The compass calibration shipped in the library can run directly on the microcontroller unit, which matters for embedded deployments where compute is limited. Because surge and sway are weakly observable, the README is honest that not every axis is equally reliable, and a user should weight those estimates accordingly. The combination of attitude, heave, wave direction, and calibration covers the core needs of a marine reference system, and the library presents them as one coordinated set of algorithms rather than disconnected snippets. A reader building a boat sensor node would draw on exactly these functions.

Running on hardware and validation

The filter code is written in C++ and the README says it can run on a microcontroller such as an esp32 or on a regular computer. That portability is important because a marine installation may put the processor near the sensors on a small board, yet the same algorithms can also be developed and tested on a desktop. The compass calibration in particular is called out as runnable on the microcontroller itself, so the device can self calibrate in place.

For validation, the library includes a testing framework that uses Stokes and Airy waves with Pierson-Moskowitz or JONSWAP spectra, and a selectable directional spread model that defaults to cosine. These are standard ocean wave models, so the tests exercise the filters against realistic sea states rather than synthetic noise. The README points to articles describing the math behind the methods, with INS filters such as a 3D Wave Kalman with Ornstein-Uhlenbeck process named in the excerpt. A user evaluating ocean-imu can therefore check both the code and the underlying theory, and can reproduce behavior by feeding the same wave spectra into the test harness. The split between embedded runtime and simulation driven validation is the project's way of proving the filters work before they ship on a moving vessel.

Editorial conclusion

Ocean-imu is written in modern C++ under the MIT license and runs on a microcontroller such as an esp32 or on a regular computer. Its testing framework models Stokes and Airy waves with Pierson-Moskowitz or JONSWAP spectra and a default cosine directional spread.

DEEP OPEN-SOURCE ANALYSIS

Official sources

Community notes

Community notes