Inertial Measurement Unit
Last updated
Was this helpful?
Last updated
Was this helpful?
The Inertial Measurement Unit of a REV Expansion Hub is an electronic device that measures the following physical attributes:
Absolute Orientation
Angular Velocity
Linear Acceleration
Magnetic Field Strength
Gravity
Temperature
Although the IMU is capable of measuring linear acceleration, it is not optimal for measuring displacement due to inaccuracies. Consider a scenario where a robot stays at rest. The measured linear acceleration is supposed to be 0, but it may fluctuate around 0 due to signal noise, causing minor changes in velocity that in turn causes the calculated displacement to deviate from the resting position at a steady rate. When the robot accelerates, inaccuracies like these add up over time, reducing the usefulness of the displacement measurements. Do not rely on linear acceleration measurements from the IMU for displacement feedback.
The IMU is for rotation feedback, so you can use its angular orientation measurements to help your robot execute perfect turns during autonomous. You can also use the IMU to enable field-centric movement control during TeleOp, which may reduce driver cognitive workload for certain applications and improve scoring performance.
The following video from FIRST demonstrates how each rotational axis (heading, roll, and pitch) corresponds to the physical dimensions of the REV Expansion Hub.
Before beginning to read angles from the IMU, you need to determine the rotational axis to which the robot's heading corresponds. According to the video above, the robot's heading corresponds to the Z-axis if the hub is mounted with the words "EXPANSION HUB" facing up, and it corresponds to the X-axis if the hub is mounted with the words facing horizontally.
To read angular orientation measurements from the IMU, we use the getAngularOrientation
method. It is possible to call this method with no parameters, but to make your code less ambiguous, we recommend supplying the three parameters.
The first parameter should be AxesReference.INTRINSIC
, as found in the official usage example.
The second parameter depends on the rotational axis to be read. If you intend to read the Z-axis, use AxesOrder.ZYX
. If you intend to read the X-axis, use AxesOrder.XYZ
.
The third parameter depends on how you intend to use the retrieved values. If you will use trigonometric functions with them, it is a good idea to use AngleUnit.RADIANS
. Otherwise, it might be more intuitive to use AngleUnit.DEGREES
.
Once you have retrieved the angular orientation data in an Orientation
object, you can access the heading of the robot with the firstAngle
field. The range of values for this field is for degrees and for radians. The initial orientation of the hub will take on a value of 0, and the positive direction corresponds to counter-clockwise rotation. Examine the video above for more intuition.
Since the angle output is constrained to or , the reading will wrap around the possible range when crossing an extremum. For example, if you were to keep track of the angle reading when the robot performs a full clockwise rotation, the reading would reach -180 degrees and immediately jump to 180 degrees. It is very possible that the robot might cross this heading when executing autonomous turns, so it is important to take the wraparound into consideration when programming.
For a complete reference of the BNO055IMU
class, check out the following source file from OpenFTC. Since the class is technically not part of the official org.firstinspires
packages, you cannot find it in the official JavaDocs. Instead, you can read the inline JavaDoc source located in its extracted source file below:
What IMU measurement is the most useful in FTC? How could you use this measurement to improve performance?
If you are currently working on a robot, which axis (X, Y, or Z) of the Expansion Hub corresponds to the robot's heading?
Given an initialized BNO055IMU
instance assigned to a field named imu
, retrieve the X-axis angular orientation reading in degrees and normalize it to the range .
The IMU behaves slightly differently compared to other sensors—you need to explicitly initialize it in addition to retrieving the object from hardwareMap
before reading measurements. Check out this from ARC Lightning 2019-2020, where we call imu.initialize(parameters)
to prepare it for normal operation. For reference, here is a more comprehensive example of how to initialize your IMU. Ideally, you should do it when getting all hardware devices from hardwareMap
.