If your Expansion Hub was purchased BEFORE December 2021, it already has an internal IMU installed and you do not need to follow these steps.
There are a few options that will work for giving your Expansion Hub Gyro/IMU function.
Integrating Gyro with our Logic Level Converter and Sensor Cable Adapter - This is directly supported in the FTC Programing environment but is just a single-axis gyro, not a full IMU.
navX2 Sensor Bundle - Also supported in the FTC programming environment. Code examples are listed on AndyMark's page, and this product includes the correct cables to use within FTC.
Adafruit 9-DOF Absolute Orientation IMU - This is the same IMU as in the Control Hub, but will require you to either create an adapter cable or solder a cut sensor cable to the board. Plugging this in and configuring the IMU on I2C port zero will allow you to use and program the same as an internal IMU.
I2C is a common electronic communication standard that allows a host (the Hub) to communicate with multiple devices on the same I2C bus. Each I2C port on a Hub is its own I2C bus. Every I2C device has a unique address, a number that is normally fixed by the manufacturer. All of the devices on an individual I2C bus must have a unique address so that the host can communicate with one device at a time. If two devices have the same address, such as when using two of the same kind of sensors, they must be used on different I2C buses otherwise the communication channels conflict.
While I2C is technically a digital communication protocol, it is more advanced than the simple on/off style of basic digital sensors. I2C sensors require software drivers for the information from a follower (sensor) to be interpreted by the leader (hub).
There are three I2C sensors within the REV system: the Inertial Measurement Unit (IMU), Color Sensor (REV-31-1557), and 2m Distance Sensor (REV-31-1505). The IMU is built into the Control Hub (REV-31-1595) and Expansion Hub (REV-31-1153) and is connected to I2C bus 0.
Logic Level represents the voltage difference between the signal and ground of the Control and Expansion Hub's sensor ports. Both Hubs and REV Sensors operate on a 3.3V logic level. This means the digital sensor needs an operating voltage of 3.3V for use with the Hub. If you are looking to use a 5V I2C sensor you will need a Logic Level Converter. See Using 5V Sensors for more information.
I2C sensors connect to the Control Hub (REV-31-1595), or Expansion Hub (REV-31-1153), via a JST PH 4-Pin Sensor Cable and the I2C buses, shown in the image above. The color-coding of the I2C buses in the image corresponds with each wire in the JST PH 4-Pin Sensor Cable. As a convention, the black wire is ground and the red wire is power. The blue (SCLn) wire and white (SDAn) wire are the communication signals for each I2C bus on the Hubs.
Sensor feedback to the Hub works differently for the I2C sensor than it does for Analog or Digital sensors. With the Analog and Digital Sensors, only one communication channel needs to be used by an individual sensor. In contrast, an I2C sensor sends different kinds of information over the SDA (white) and SCL (blue) wires. Since the I2C is transferring more complex data to the Hub then Analog or Digital sensors, there has to be a component of harmonization, or consistency, as the data moves from the sensor to the Hub. The SCL (Serial Clock) channel provides consistency by acting as a clock line and time-stamping the data provided by the SDA (Serial Data) channel.
While it is possible to host more than one I2C sensor on the same bus, there are a couple of factors to take into account. The Hub keeps track of the information from different sensors by considering the sensor's address in relation to the data being sent. When two sensors have the same address, like the REV Color Sensor V3 and the 2m Distance Sensor, they cannot be hosted on the same bus. Check the sensor datasheets for all I2C sensors to determine what sensors can and cannot be hosted on the same bus.
Currently, REV Robotics does not produce a cable or breakout board to connect two sensors to one I2C port on the Hub. A custom cable will need to be made in order to wire more than one I2C to the Hub.
The internal IMU is hosted on I2C bus 0. See the configuration section below to learn more about configuring a secondary sensor on bus 0.
Before a sensor can be programmed it must be added to the Robot Configuration. The configuration file stores all configured devices in the Control Hub's "hardwareMap," which can be called to in the code to establish the line of communication between devices.
In order to function, all FTC legal I2C devices have drivers installed into the SDK. With regards to configuration, this means that the device has to be set to the drop-down menu item that corresponds with its drivers. Visit the datasheet for the sensor you are trying to configure to see how to configure it.
The steps below shows a basic configuration for I2C devices. The I2C Bus 0 hosts the internal IMU sensor within the Hubs. In this example, the Color Sensor V3 is being added to Bus 0 as well.
While in the configuration select the I2C Bus 0 option. This will open a screen that shows the IMU.
Press the Add button to add the Color Sensor to this bus. Select "REV Color Sensor V3" from the drop-down menu and name the device.
When you have finished configuring the sensor hit Done. The app will return to the previous screen.
How do I2C sensors help a robot navigate the world around it? The answer to this question is a bit more diverse than it was for Analog or Digital sensors.
All three Color Sensors (V1-V3) sense color within a 2cm distance from the sensor. When mounted on the robot this can help in autonomous period tasks where robots have to decide between several different colored objects. Relic Recovery, Rover Ruckus, and Skystone all had autonomous tasks where the Color Sensor helped robots choose between randomized jewels, minerals, and stones!
While the Color Sensors have some proximity sensing capabilities, the 2m Distance Sensor is able to detect proximity with higher accuracy and reliability. When combined with odometry, the 2m Distance Sensor can help the robot navigate obstacles on the field during autonomous!
The IMU has a built-in accelerometer, gyroscope, and magnetometer. There are a multitude of applications for the IMU within autonomous op modes:
Use the Gyroscope to drive in the straight lines and turn during autonomous
Use the Accelerometer in conjunction with the gyroscope to avoid drift and give an approximation of position/travel
Use the IMU with motor encoders to track and determine robot placement on a field
For more information on the I2C sensor specifications, coding examples, and more; click one of the links below to head to the sensor datasheets
Expansion Hubs shipped AFTER December 1st, 2021 no longer include an internal IMU
The data used by the IMU to track the orientation includes the rotation along each axis, and the forces of acceleration along each axis. Using the acceleration forces allows the IMU to detect the direction of gravity, preventing drift in the pitch and roll readings. Only the heading will drift slowly, as small inaccuracies build up over time.
I2C Address: 0x28
Port: 0
Originally, Control Hubs and Expansion Hubs came with the Bosch BNO055 IMU. Control Hubs containing the alternative Bosch BHI260AP IMU started shipping in September 2022. To see which IMU your Control Hub has, go to the Manage page within the Program & Manage web interface, either from the Driver Station, the REV Hardware Client, or at http://192.168.43.1:8080
in a web browser on a laptop connected to the Control Hub's Wi-Fi network.
When you create a new configuration file, the correct IMU type will be automatically detected, and added to the configuration.
Version 8.1 of the FTC Robot Controller app adds a new universal IMU
interface for Blocks and Java programming, which supports both the BNO055 IMU and the BHI260AP IMU. The BNO055 IMU can also be used from the legacy BNO055IMU
interface.
IMU
interfaceThe new universal IMU
interface added in version 8.1 of the FTC Robot Controller app provides robot-centric orientation and angular velocity values. You can specify the exact orientation of the Control or Expansion Hub on your robot, and the interface will convert the raw values from the IMU into robot-centric values. This simplifies how you use the IMU's values, and prevents problems when the hub is not mounted with the REV Robotics logo facing upwards.
All values from theIMU
interface are in the Robot Coordinate System, in which the origin is inside your robot, the Z axis points towards the ceiling, the Y axis points straight ahead through the front of your robot (whatever you define the front to be), and the X axis points out the right side of your robot. This coordinate system is right-handed, which means that if you point a typical right thumb in the same direction as the axis, rotation in the same direction that the fingers curl is considered positive.
The IMU.getRobotYawPItchRollAngles()
method on the IMU
interface provides the robot's orientation in a simplified format of yaw, pitch, and roll angles. Most teams should use this method to get the robot's orientation.
Yaw (also known as heading) is the measure of rotation along the robot's Z axis, or the side-to-side lateral rotation of the robot.
Pitch is the measure of rotation along the robot's X axis, or the front-to-back rotation of the robot.
Roll is the measure along the robot's Y axis, or the side-to-side tilt of the robot.
BNO055IMU
interfaceThe BNO055IMU
interface has several disavantages compared to the universal IMU
interface.
It can only be used with Control Hubs and Expansion Hubs that contain the original BNO055 IMU.
It only works reliably when the Hub is mounted flat, with the REV Robotics logo pointed upwards.
The values it provides are relative to the Hub, not the Robot.
You have to manually specify the axes order for the orientation angles (ZXY is recommended for typical use cases).
The coordinate system used for the BNO055IMU
interface is defined like this:
The X axis runs from the bottom of the hub, near the servo ports, to the top of the hub, where the USB ports are.
The Y axis runs from the sensor ports on the right to the motor ports on the left.
The Z axis points upwards through the REV Robotics logo.
There are a multitude of applications for the IMU within autonomous op modes:
Use the heading to drive in straight lines and turn during autonomous
Use the IMU with motor encoders to track and determine robot placement on a field
Each REV Robotics Control Hub (), and Expansion Hubs () purchased before December 2021, has a built in IMU, or inertial measurement unit. The IMU combines measurements from multiple internal sensors to compute its current orientation. It can also provide the angular velocity (how fast the IMU is rotating along each axis).
To learn more on how to configure the IMU check out theintroduction page.