Skip to content

OSCP IMU Rust Library

oscp-imu is a Rust crate for communicating with OSCP MK2 IMU units. It decodes the operating frames emitted by the unit and encodes the command set for both supported transports: RS422 (byte stream) and CAN-FD (message based).

https://github.com/OSCPS/oscp-imu-rs


Build & install

The crate is distributed as a Git dependency. It is not yet published on crates.io.

Dependencies

Crate Source Role
oscp-imu https://github.com/OSCPS/oscp-imu-rs.git Library crate
cobs crates.io, resolved by Cargo COBS encoding and decoding
serde crates.io, resolved by Cargo, optional Serialize implementations for decoded types

Add it to your project

  1. Add the dependency to Cargo.toml:

    [dependencies]
    oscp-imu = { git = "https://github.com/OSCPS/oscp-imu-rs.git" }
    
  2. To derive serde::Serialize on frames and command responses, enable the serde feature:

    [dependencies]
    oscp-imu = { git = "https://github.com/OSCPS/oscp-imu-rs.git", features = ["serde"] }
    
  3. For reproducible builds, pin a commit with rev = "<commit>".

  4. Import items from the crate root:
use oscp_imu::{OscpParser, OscpFrame, OscpTransport};

Requirements

Rust 1.85 or later (edition 2024). Fields are decoded with from_le_bytes, so the crate is independent of host byte order.


Features

  • No dynamic allocation

    Parser state is held in a caller-owned OscpParser containing fixed-size arrays. The crate uses core only and does not allocate, so it is no_std-compatible.

  • Two transports, one frame type

    A byte-stream parser for RS422 and a stateless decode function for CAN-FD. Both return OscpFrame.

  • Frame coverage

    Raw, Euler, Quaternion, Rotation Matrix, GNSS, Debug 1/2 and Startup frames are decoded into typed structs.

  • Command set

    16 commands, encoded for either transport. Each argument is a typed enum.

  • Integrity checks

    CRC-16 on every frame. COBS framing on RS422.

  • Error handling

    Fallible functions return Result. The RS422 parser counts dropped frames in OscpStats.


Supported hardware

Model Description
MK2M2 OSCP Tactical-Grade MEMS IMU
MK2E2 OSCP Tactical-Grade MEMS + Optical Gyroscope IMU
MK2Z OSCP Navigation-Grade MEMS + Optical Gyroscope IMU

Documentation map


Revision

This documentation tracks oscp-imu v0.1.0.