API Reference

class witmotion.IMU(path: str = '/dev/ttyUSB0', baudrate: int = 9600)

Main IMU interface. Instantiate to connect to a device.

Can be used via a polling interface or a streaming callback-based interface.

close() None

Close IMU connection and stop background monitoring thread..

get_acceleration() Optional[Tuple[float, float, float]]

Get the last acceleration vector received from the device. If no acceleration messages have been received, will return None.

get_angle() Optional[Tuple[float, float, float]]

Get the last angle state received from the device. If no angle messages have been received, will return None.

get_angular_velocity() Optional[Tuple[float, float, float]]

Get the last angular velocity state received from the device. If no angular velocity messages have been received, will return None.

get_magnetic_vector() Optional[Tuple[float, float, float]]

Get the last magnetic vector received from the device. If no magnetic messages have been received, will return None.

get_quaternion() Optional[Tuple[float, float, float, float]]

Get the last quaternion received from the device. If no quaternion messages have been received, will return None.

get_timestamp() Optional[float]

Get the last timestamp received from the device. If no timestamp messages have been received, will return None.

save_configuration() None

Save the currently running configuration to the device’s nonvolatile memory.

send_command(cmd: ConfigCommand) None

Send a command instance to the device. This should generally not be used directly: instead, use higher-level configuration methods.

send_config_command(cmd: ConfigCommand)

Send a configuration command instance to the device, proceeded by a special configuration sequence. This should generally not be used directly: instead, use higher-level configuration methods.

set_acceleration_bias(values: Tuple[int, int, int]) None

Set the internal acceleration bias values.

set_algorithm_dof(n: int) None

Set the currently active sensing algorithm in use on the device: either 6-DoF or 9-DoF.

set_angular_velocity_bias(values: Tuple[int, int, int]) None

Set the internal angular velocity bias values.

set_baudrate(rate: int) None

Set the serial baud rate used by the device.

set_calibration_mode(mode: CalibrationMode) None

Set the current calibration mode.

set_default_configuration() None

Restore the device to factory default configuration.

set_gyro_automatic_calibration(enabled: bool = True) None

Set the current gyro automatic calibration mode: either enabled or disabled.

set_installation_direction(direction: InstallationDirection) None

Set the current installation direction.

set_magnetic_bias(values: Tuple[int, int, int]) None

Set the internal magnetic bias values.

set_messages_enabled(classes: Set[Type[ReceiveMessage]]) None

Set the output message types enabled on the device. Pass in a set of ReceiveMessage subclasses.

set_update_rate(rate: Optional[Union[str, float]]) None

Set the update rate emitted by the device.

subscribe(callback: Callable[[ReceiveMessage], None], cls: Optional[Type[ReceiveMessage]] = None) None

Subscribe to update messages from the IMU.

toggle_sleep() None

Toggle device sleep mode. If the device is currently active, it will go to sleep. If the device is current asleep, it will become active.

class witmotion.CalibrationMode(value)

Available sensor calibration modes.

gyro_accel = 1

Enable gyroscope and accelerometer calibration.

magnetic = 2

Enable magnetic calibration.

none = 0

No calibration mode enabled.

class witmotion.InstallationDirection(value)

Available installation directions.

horizontal = 0

Device installed horizontally (default).

vertical = 1

Device installed vertically.