IMU

Python Library for ST LSM6DS33 IMU.

Python Library

Turta_IMU library is responsible for reading reading 3D gyro and acceleration data.

Initialization

Add the following statement to the top of your Python code.

from turta_rcdriverhat import Turta_IMU

Then, create an instance of the IMU class.

imu = Turta_IMU.IMU()

Now you're ready to access the library by calling its instance.

Basic Members

Read Accel X

Reads the X-axis acceleration.

read_accel_x()
  • Parameters

    • None

  • Returns

    • Int: X-axis acceleration.

Read Accel Y

Reads the Y-axis acceleration.

read_accel_y()
  • Parameters

    • None

  • Returns

    • Int: Y-axis acceleration.

Read Accel Z

Reads the Z-axis acceleration.

read_accel_z()
  • Parameters

    • None

  • Returns

    • Int: Z-axis acceleration.

Read Accel XYZ

Reads the accelerations of X, Y and Z-axes.

read_accel_xyz()
  • Parameters

    • None

  • Returns

    • Int[]: Acceleration of X, Y and Z-axes respectively.

Read Pitch

Reads the pitch on X-axis.

read_gyro_x_pitch()
  • Parameters

    • None

  • Returns

    • Int: Pitch.

Read Roll

Reads the roll on Y-axis.

read_gyro_y_roll()
  • Parameters

    • None

  • Returns

    • Int: Roll.

Read Yaw

Reads the yaw on Z-axis.

read_gyro_z_yaw()
  • Parameters

    • None

  • Returns

    • Int: Yaw.

Read Gyro XYZ

Reads the pitch, roll and yaw.

read_gyro_xyz()
  • Parameters

    • None

  • Returns

    • Int array: Pitch, roll and yaw values respectively.

Read Gyro Accel XYZ

Reads the accelerations of X, Y, Z-axes and pitch, roll, yaw values.

read_gyro_accel_xyz()
  • Parameters

    • None

  • Returns

    • Int[]: X accel, Y accel, Z accel, pitch, roll and yaw values respectively.

Read Internal Temperature

Reads the temperature of the IMU.

read_temp(fahrenheit)
  • Parameters

    • Bool fahrenheit: True for Fahrenheit output, False for Celcius output. (False is default.)

  • Returns

    • Float: Temperature of IMU.

Advanced Members

Test IMU

Sends Who_Am_I command to the IMU, checks if it responses correctly.

config(ch, pga, mode, dr, ts_mode)
  • Parameters

    • None

  • Returns

    • Bool: True if the device responses with 0x69, False if not.

Finalizer

When exiting from the program, the library turns off the IMU and then releases the SPI bus & interrupt pins.

Last updated