maix.ext_dev.imu
maix.ext_dev.imu module
You can use
maix.ext_dev.imu
to access this module with MaixPy
This module is generated from MaixPy and MaixCDK
Module
No module
Enum
Mode
imu mode
item | describe |
---|---|
values | ACC_ONLY: GYRO_ONLY: DUAL: |
C++ defination code:
enum class Mode { ACC_ONLY = 0, GYRO_ONLY, DUAL }
AccScale
imu acc scale
item | describe |
---|---|
values | ACC_SCALE_2G: ACC_SCALE_4G: ACC_SCALE_8G: ACC_SCALE_16G: |
C++ defination code:
enum class AccScale { ACC_SCALE_2G = 0, ACC_SCALE_4G, ACC_SCALE_8G, ACC_SCALE_16G }
AccOdr
imu acc output data rate
item | describe |
---|---|
values | ACC_ODR_8000: Accelerometer ODR set to 8000 Hz. ACC_ODR_4000: Accelerometer ODR set to 4000 Hz. ACC_ODR_2000: Accelerometer ODR set to 2000 Hz. ACC_ODR_1000: Accelerometer ODR set to 1000 Hz. ACC_ODR_500: Accelerometer ODR set to 500 Hz. ACC_ODR_250: Accelerometer ODR set to 250 Hz. ACC_ODR_125: Accelerometer ODR set to 125 Hz. ACC_ODR_62_5: Accelerometer ODR set to 62.5 Hz. ACC_ODR_31_25: Accelerometer ODR set to 31.25 Hz. ACC_ODR_128: Accelerometer ODR set to 128 Hz. ACC_ODR_21: Accelerometer ODR set to 21 Hz. ACC_ODR_11: Accelerometer ODR set to 11 Hz. ACC_ODR_3: Accelerometer ODR set to 3 Hz. |
C++ defination code:
enum class AccOdr { ACC_ODR_8000, // Accelerometer ODR set to 8000 Hz. ACC_ODR_4000, // Accelerometer ODR set to 4000 Hz. ACC_ODR_2000, // Accelerometer ODR set to 2000 Hz. ACC_ODR_1000, // Accelerometer ODR set to 1000 Hz. ACC_ODR_500, // Accelerometer ODR set to 500 Hz. ACC_ODR_250, // Accelerometer ODR set to 250 Hz. ACC_ODR_125, // Accelerometer ODR set to 125 Hz. ACC_ODR_62_5, // Accelerometer ODR set to 62.5 Hz. ACC_ODR_31_25, // Accelerometer ODR set to 31.25 Hz. ACC_ODR_128 = 12, // Accelerometer ODR set to 128 Hz. ACC_ODR_21, // Accelerometer ODR set to 21 Hz. ACC_ODR_11, // Accelerometer ODR set to 11 Hz. ACC_ODR_3, // Accelerometer ODR set to 3 Hz. }
GyroScale
imu gyro scale
item | describe |
---|---|
values | GYRO_SCALE_16DPS: Gyroscope scale set to ±16 degrees per second. GYRO_SCALE_32DPS: Gyroscope scale set to ±32 degrees per second. GYRO_SCALE_64DPS: Gyroscope scale set to ±64 degrees per second. GYRO_SCALE_128DPS: Gyroscope scale set to ±128 degrees per second. GYRO_SCALE_256DPS: Gyroscope scale set to ±256 degrees per second. GYRO_SCALE_512DPS: Gyroscope scale set to ±512 degrees per second. GYRO_SCALE_1024DPS: Gyroscope scale set to ±1024 degrees per second. GYRO_SCALE_2048DPS: Gyroscope scale set to ±2048 degrees per second. |
C++ defination code:
enum class GyroScale { GYRO_SCALE_16DPS = 0, // Gyroscope scale set to ±16 degrees per second. GYRO_SCALE_32DPS, // Gyroscope scale set to ±32 degrees per second. GYRO_SCALE_64DPS, // Gyroscope scale set to ±64 degrees per second. GYRO_SCALE_128DPS, // Gyroscope scale set to ±128 degrees per second. GYRO_SCALE_256DPS, // Gyroscope scale set to ±256 degrees per second. GYRO_SCALE_512DPS, // Gyroscope scale set to ±512 degrees per second. GYRO_SCALE_1024DPS, // Gyroscope scale set to ±1024 degrees per second. GYRO_SCALE_2048DPS, // Gyroscope scale set to ±2048 degrees per second. }
GyroOdr
imu gyro output data rate
item | describe |
---|---|
values | GYRO_ODR_8000: Gyroscope ODR set to 8000 Hz. GYRO_ODR_4000: Gyroscope ODR set to 4000 Hz. GYRO_ODR_2000: Gyroscope ODR set to 2000 Hz. GYRO_ODR_1000: Gyroscope ODR set to 1000 Hz. GYRO_ODR_500: Gyroscope ODR set to 500 Hz. GYRO_ODR_250: Gyroscope ODR set to 250 Hz. GYRO_ODR_125: Gyroscope ODR set to 125 Hz. GYRO_ODR_62_5: Gyroscope ODR set to 62.5 Hz. GYRO_ODR_31_25: Gyroscope ODR set to 31.25 Hz. |
C++ defination code:
enum class GyroOdr { GYRO_ODR_8000, // Gyroscope ODR set to 8000 Hz. GYRO_ODR_4000, // Gyroscope ODR set to 4000 Hz. GYRO_ODR_2000, // Gyroscope ODR set to 2000 Hz. GYRO_ODR_1000, // Gyroscope ODR set to 1000 Hz. GYRO_ODR_500, // Gyroscope ODR set to 500 Hz. GYRO_ODR_250, // Gyroscope ODR set to 250 Hz. GYRO_ODR_125, // Gyroscope ODR set to 125 Hz. GYRO_ODR_62_5, // Gyroscope ODR set to 62.5 Hz. GYRO_ODR_31_25, // Gyroscope ODR set to 31.25 Hz. }
Variable
Function
get_imu_info
def get_imu_info() -> list[IMUInfo]
Get all IMU info on board(not include external IMU).
item | description |
---|---|
return | std::vectorimu::IMUInfo type, all IMU info. |
C++ defination code:
std::vector<ext_dev::imu::IMUInfo> get_imu_info()
Class
IMUData
IMU data type.
C++ defination code:
class IMUData
acc
accelerometer data
item | description |
---|---|
type | var |
static | False |
readonly | False |
C++ defination code:
maix::Vector3f acc
gyro
gyroscope data
item | description |
---|---|
type | var |
static | False |
readonly | False |
C++ defination code:
maix::Vector3f gyro
mag
magnetometer data
item | description |
---|---|
type | var |
static | False |
readonly | False |
C++ defination code:
maix::Vector3f mag
temp
temperature data
item | description |
---|---|
type | var |
static | False |
readonly | False |
C++ defination code:
float temp
IMUInfo
IMU info
C++ defination code:
class IMUInfo
name
IMU name
item | description |
---|---|
type | var |
static | False |
readonly | False |
C++ defination code:
std::string name
driver
IMU driver name
item | description |
---|---|
type | var |
static | False |
readonly | False |
C++ defination code:
std::string driver
i2c_bus
IMU i2c bus number
item | description |
---|---|
type | var |
static | False |
readonly | False |
C++ defination code:
int i2c_bus
addr
IMU i2c address
item | description |
---|---|
type | var |
static | False |
readonly | False |
C++ defination code:
int addr
have_mag
IMU have magnetometer or not
item | description |
---|---|
type | var |
static | False |
readonly | False |
C++ defination code:
bool have_mag
IMU
QMI8656 driver class
C++ defination code:
class IMU
__init__
def __init__(self, driver: str, i2c_bus: int = -1, addr: int = 107, freq: int = 400000, mode: Mode = ..., acc_scale: AccScale = ..., acc_odr: AccOdr = ..., gyro_scale: GyroScale = ..., gyro_odr: GyroOdr = ..., block: bool = True) -> None
Construct a new IMU object, will open IMU
item | description |
---|---|
type | func |
param | driver: driver name, only support "qmi8656" i2c_bus: i2c bus number. Automatically selects the on-board imu when -1 is passed in. addr: IMU i2c addr. freq: IMU freq mode: IMU Mode: ACC_ONLY/GYRO_ONLY/DUAL acc_scale: acc scale, see @imu::AccScale acc_odr: acc output data rate, see @imu::AccOdr gyro_scale: gyro scale, see @imu::GyroScale gyro_odr: gyro output data rate, see @imu::GyroOdr block: block or non-block, defalut is true |
static | False |
C++ defination code:
IMU(std::string driver, int i2c_bus=-1, int addr=0x6B, int freq=400000, maix::ext_dev::imu::Mode mode=maix::ext_dev::imu::Mode::DUAL, maix::ext_dev::imu::AccScale acc_scale=maix::ext_dev::imu::AccScale::ACC_SCALE_2G, maix::ext_dev::imu::AccOdr acc_odr=maix::ext_dev::imu::AccOdr::ACC_ODR_1000, maix::ext_dev::imu::GyroScale gyro_scale=maix::ext_dev::imu::GyroScale::GYRO_SCALE_256DPS, maix::ext_dev::imu::GyroOdr gyro_odr=maix::ext_dev::imu::GyroOdr::GYRO_ODR_8000, bool block=true)
read
def read(self) -> list[float]
Read raw data from IMU, no calibration, recommend use read_all instead.
item | description |
---|---|
type | func |
return | list type. If only one of the outputs is initialized, only [x,y,z] of that output will be returned. If all outputs are initialized, [acc_x, acc_y, acc_z, gyro_x, gyro_y, gyro_z] is returned. And the last one is temperature Unit acc: g/s Unit gyro: degree/s Unit temperate: degree |
static | False |
C++ defination code:
std::vector<float> read()
read_all
def read_all(self, calib_gryo: bool = True, radian: bool = False) -> IMUData
read imu data from IMU.
item | description |
---|---|
type | func |
param | calib_gryo: calibrate gyro data based on calib_gyro_data, you should load_calib_gyro first to load calib_gyro_data. radian: gyro unit use rad/s instead of degree/s, default false(use degree/s). |
return | maix.ext_dev.imu.IMUData type. Unit acc: g/s Unit gyro: degree/s Unit temperate: degree |
static | False |
C++ defination code:
ext_dev::imu::IMUData read_all(bool calib_gryo = true, bool radian = false)
calib_gyro
def calib_gyro(self, time_ms: int, interval_ms: int = -1, save_id: str = 'default') -> ...
Calibrate gryo for time_ms long, get gryo bias.
item | description |
---|---|
type | func |
param | time_ms: total time to collect data, unit is ms. interval_ms: minimum read raw data interval, -1 means continues, 10ms mean >= 10ms. save_id: Save calibration data to file or not, you can load by load_calib_gyro. Empty string means not save. By default value is "default", means save calibration as id "default". |
static | False |
C++ defination code:
Vector3f calib_gyro(uint64_t time_ms, int interval_ms = -1, const std::string &save_id = "default")
calib_gyro_exists
def calib_gyro_exists(self, save_id: str = 'default') -> bool
Load Gyro calibration from file, if not found all value will be 0.
item | description |
---|---|
type | func |
param | save_id: saved id from valib_gyro, default is "default". |
return | If exist gyro calibration info return True else False. |
static | False |
C++ defination code:
bool calib_gyro_exists(const std::string &save_id = "default")
load_calib_gyro
def load_calib_gyro(self, save_id: str = 'default') -> ...
Load Gyro calibration from file, if not found all value will be 0.
item | description |
---|---|
type | func |
param | save_id: saved id from valib_gyro, default is "default". |
static | False |
C++ defination code:
Vector3f load_calib_gyro(const std::string &save_id = "default")
save_calib_gyro
def save_calib_gyro(self, calib: ..., save_id: str = 'default') -> maix.err.Err
Save Gyro calibration to file.
item | description |
---|---|
type | func |
param | calib: the calibration data you want to save. save_id: saved id from valib_gyro, default is "default". |
static | False |
C++ defination code:
err::Err save_calib_gyro(const Vector3f &calib, const std::string &save_id = "default")
calculate_calibration
def calculate_calibration(self, time_ms: int = 30000) -> maix.err.Err
!!!Depracated!!!\nCaculate calibration, save calibration data to /maixapp/share/misc/imu_calibration
item | description |
---|---|
type | func |
param | time_ms: caculate max time, unit:ms |
return | err::Err |
static | False |
C++ defination code:
err::Err calculate_calibration(uint64_t time_ms = 30 * 1000)
get_calibration
def get_calibration(self) -> list[float]
!!!Depracated!!!\nGet calibration data
item | description |
---|---|
type | func |
return | return an array, format is [acc_x_bias, acc_y_bias, acc_z_bias, gyro_x_bias, gyro_y_bias, gyro_z_bias] If the calibration file cannot be found, an empty array will be returned. |
static | False |
C++ defination code:
std::vector<double> get_calibration()
Gcsv
Gcsv class
C++ defination code:
class Gcsv
__init__
def __init__(self) -> None
Construct a new IMU object
item | description |
---|---|
type | func |
static | False |
C++ defination code:
Gcsv()
open
def open(self, path: str, tscale: float = 0.001, gscale: float = 1, ascale: float = 1, mscale: float = 1, version: str = '1.3', id: str = 'imu', orientation: str = 'YxZ') -> maix.err.Err
Open a file
item | description |
---|---|
type | func |
param | path: the path where data will be saved tscale: time scale, default is 0.001 gscale: gyroscope scale factor, default is 1, unit:g ascale: accelerometer scale factor, default is 1, unit:radians/second mscale: magnetometer scale factor, default is 1(unused) version: version number, default is "1.3" id: identifier for the IMU, default is "imu" orientation: sensor orientation, default is "YxZ" |
return | error code |
static | False |
C++ defination code:
err::Err open(std::string path, double tscale = 0.001, double gscale = 1, double ascale = 1, double mscale = 1, std::string version = "1.3", std::string id = "imu", std::string orientation = "YxZ")
close
def close(self) -> maix.err.Err
Close file
item | description |
---|---|
type | func |
return | error code |
static | False |
C++ defination code:
err::Err close()
is_opened
def is_opened(self) -> bool
Check if the object is already open
item | description |
---|---|
type | func |
return | true, opened; false, not opened |
static | False |
C++ defination code:
bool is_opened()
write
def write(self, timestamp: float, gyro: list[float], acc: list[float], mag: list[float] = []) -> maix.err.Err
Write imu data to gcsv file
item | description |
---|---|
type | func |
param | t: Timestamp of the current data. The actual value is equal to t * tscale. unit:s gyro: Gyroscope data must be an array consisting of x, y, and z-axis data. The actual value is equal to gyro * gscale. unit:g acc: Acceleration data must be an array consisting of x, y, and z-axis data. The actual value is equal to acc * ascale.unit:radians/second mag: Magnetic data must be an array consisting of x, y, and z-axis data. Currently not supported. |
static | False |
C++ defination code:
err::Err write(double timestamp, std::vector<double> gyro, std::vector<double> acc, std::vector<double> mag = std::vector<double>())