IMUs

This package lets you interact with the IMUs used at K-Scale

pip install kscale-imu  # Install the Python package
cargo install imu  # Install the Rust crate

You can install the pure-Rust implementation of this package from here.

Supported devices:

Getting Started

Hexmove IMU

To use the Hexmove IMU, you’ll first need to set up the CAN interface with a buad rate of 500000. On Linux, you can do this with:

sudo ip link set can0 up type can bitrate 500000

It’s important to note that Hexmove IMUs have model IDs as well as CAN IDs

Example usage

from imu import HexmoveImuReader
 
# Initialize the IMU reader for the 'can0' interface and imu with CAN ID 1 and model 1
imu_reader = HexmoveImuReader("can0", 1, 1)
 
while True:
    # Get the current IMU data
    data = imu_reader.get_data()
    print(
        f"Angular Position: X={data.x_angle}°, Y={data.y_angle}°, Z={data.z_angle}° | "
        f"Angular Velocity: X={data.x_velocity}°/s, Y={data.y_velocity}°/s, Z={data.z_velocity}°/s"
    )
 
    # Sleep for a short duration to avoid spamming the console
    time.sleep(0.1)