IMU

An Inertial Measurement Unit (IMU) is a device that measures and reports a body's specific force, angular rate, and sometimes orientation. It typically consists of accelerometers and gyroscopes, and sometimes magnetometers. IMUs are essential for navigation, stabilization, and control in various applications like drones, robots, and vehicles.

To interact with IMU, you must use an I2C address. These addresses are 8-bit values ranging from 16 to 254 in decimal (10 to FE in hexadecimal) and must be even. By default, a Modern Robotics color sensor has an I2C address of 3C hexadecimal. This address is assumed by an op mode written with Blocks Programming unless otherwise specified.

If you change the address of a color sensor, you must inform the Blocks Programming environment of the new address. You can do this using the "Set i2cAddress7Bit" or "Set i2cAddres8Bit" block. If you use blocks that refer to "7Bit," only the high 7 of the 8 bits are used, and the numbers range from 8 to 7F in hexadecimal (8 to 127 in decimal). For example, if you have an 8-bit address of 22 hexadecimal (34 decimal), its 7-bit address would be half of these values: 11 hexadecimal (17 decimal).

You can use the blocks in this section to measure the acceleration, gravity, angular velocity, etc. If a block returns an object (e.g. Acceleration), you can use blocks under Utilities to process those projects.

Acceleration

Returns an Acceleration object representing the last observed acceleration of the sensor. Note that this does not communicate with the sensor, but rather returns the most recent value reported to the acceleration integration algorithm.

Key points:

  • Units: can be set to m/s^2 or milligals (mGal).

  • Values: returns an Acceleration object containing the x axis acceleration, y axis acceleration, z axis acceleration, and units in that order.

  • Usage: to help autonomously guide the robot.

Gravity

Returns an Acceleration object representing the direction of the force of gravity relative to the sensor.

Key points:

  • Units: can be set to g.

  • Values: returns a Gravity object containing the force of gravity.

  • Usage: to help autonomously guide the robot.

OverallAcceleration

Returns an Acceleration object representing the overall acceleration detected by the sensor. This is composed of a component due to the movement of the sensor and a component due to the force of gravity.

AngularOrientation

Returns an Orientation object representing the absolute orientation of the sensor as a set of three angles.

AngularOrientationAxes

Returns a List of the axes on which the sensor measures angular velocity. Some sensors measure angular velocity on all three axes (X, Y, & Z) while others measure on only a subset, typically the Z axis. This block allows you to determine what information is usefully returned through the get AngularVelocity block.

AngularVelocity

Returns an AngularVelocity object representing the rate of change of the absolute orientation of the sensor.

AngularVelocityAxes

Returns a List of the axes on which the sensor measures angular velocity. Some sensors measure angular velocity on all three axes (X, Y, & Z) while others measure on only a subset, typically the Z axis. This block allows you to determine what information is usefully returned through the get AngularVelocity block.

CalibrationStatus

Returns a text string giving the calibration status of the sensor.

Key points:

  • The returned string is in the format, “IMU Calibration Status : sx gx ax mx”, where s stands for system, g for gyro, a for accelerometer and m for magnetometer. The x values are 0, 1, 2 or 3, where 0 means uncalibrated, 3 means fully calibrated and 1 and 2 mean partially calibrated. For example, “IMU Calibration Status : s0 g3 a0 m1” the system is not calibrated, the gyro is fully calibrated, the accelerometer is not calibrated and the magnetometer is partially calibrated.

SystemError

If SystemStatus is “SYSTEM_ERROR”, returns more detail about the error. Otherwise, the value is undefined.

SystemStatus

Returns a text value representing the current status of the system.

SystemStatus.SYSTEM_ERROR

This indicates that there is a system error. You can use IMU.SystemError block to get the detailed error. Since we are running in a simulated environment, we should not expect SystemError.

set IMU.I2cAddress7Bit to

Sets the 7bit I2C address to the specified number.

Key points:

  • Purpose. Change the default 7 bit I2C address to differentiate sensors.

  • The address must be an even number from 8 to 127 included.

set IMU.I2cAddress8Bit to

Sets the 8 bit I2C address to the specified number.

Key points:

  • Purpose. Change the default 8 bit I2C address to differentiate sensors.

  • The address must be an even number from 16 to 254 included.

I2cAddress7Bit

Return the 7 bi I2C address of the IMU.

I2cAddress8Bit

Return the 8 bi I2C address of the IMU.

Position

Returns a Position object representing the current position of the sensor as calculated by doubly integrating the observed sensor accelerations.

Velocity

Returns a Velocity object representing the current velocity of the sensor as calculated by integrating the observed sensor accelerations.

getAngularOrientation

Returns an Orientation object representing the absolute orientation of the sensor as a set of three angles. Axes on which absolute orientation is not measured are reported as zero.

Key points:

  • axesReference: you can choose EXTRINSIC or INTRINSIC.

  • axesOrder: You can choose any of the 12 combinations.

  • angleUnit: You can choose DEGREES or RADIANS.

getAngularVelocity

Returns an AngularVelocity object representing the angular rotation rate across all the axes measured by the sensor. Axes on which angular velocity is not measured are reported as zero.

Key points:

  • angleUnit: You can choose DEGREES or RADIANS.

initialize

Initializes the IMU based on an IMU parameters object.

isAccelerometerCalibrated

Returns true if the Accelerometer has completed calibration; false otherwise.

isGyroCalibrated

Returns true if the gyroscope has completed calibration; false otherwise.

isMagnetomemterCalibrated

Returns true if the magnetometer has completed calibration; false otherwise.

isSystemCalibrated

Returns true if the system is fully calibrated. The system is fully calibrated if the gyro, accelerometer, and magnetometer are fully calibrated.

saveCalibrationData

Saves the current calibration information in the file specified by the given text. Such files usually end with the “json” extension.

startAccelerationIntegration

Starts (or re-start) polling, at the given interval, the current linear acceleration of the sensor and integrates it to provide velocity and position information.

Key points:

  • The poll interval must be set in milliseconds.

startAccelerationIntegration (initialPosition and initialVelocity)

Starts (or re-start) polling, at the given interval, the current linear acceleration of the sensor and integrates it to provide velocity and position information.

stopAccelerationIntegration

Stops the integration thread if it is currently running.