public class BNO055
extends java.lang.Object
To use the sensor, wire up to it over I2C on the roboRIO. Creating an instance of this class will cause communications with the sensor to being.All communications with the sensor occur in a separate thread from your robot code to avoid blocking the main robot program execution.
Example: private static BNO055 imu;
public Robot() { imu = BNO055.getInstance(BNO055.opmode_t.OPERATION_MODE_IMUPLUS, BNO055.vector_type_t.VECTOR_EULER); }
You can check the status of the sensor by using the following methods: isSensorPresent(); //Checks if the code can talk to the sensor over I2C // If this returns false, check your wiring. isInitialized(); //Checks if the sensor initialization has completed. // Initialization takes about 3 seconds. You won't get // position data back from the sensor until its init'd. isCalibrated(); //The BNO055 will return position data after its init'd, // but the position data may be inaccurate until all // required sensors report they are calibrated. Some // Calibration sequences require you to move the BNO055 // around. See the method comments for more info.
Once the sensor calibration is complete , you can get position data by by using the getVector() method. See this method definiton for usage info.
This code was originally ported from arduino source developed by Adafruit. See the original comment header below.
Modifier and Type | Class and Description |
---|---|
class |
BNO055.CalData |
static class |
BNO055.opmode_t |
static class |
BNO055.powermode_t |
static class |
BNO055.reg_t |
class |
BNO055.RevInfo |
class |
BNO055.SystemStatus |
static class |
BNO055.vector_type_t |
Modifier and Type | Field and Description |
---|---|
static byte |
BNO055_ADDRESS_A |
static byte |
BNO055_ADDRESS_B |
static int |
BNO055_ID |
Modifier and Type | Method and Description |
---|---|
BNO055.CalData |
getCalibration()
Gets current calibration state.
|
double |
getHeading()
The heading of the sensor (x axis) in continuous format.
|
static BNO055 |
getInstance(BNO055.opmode_t mode,
BNO055.vector_type_t vectorType)
Get an instance of the IMU object plugged into the onboard I2C header.
|
static BNO055 |
getInstance(BNO055.opmode_t mode,
BNO055.vector_type_t vectorType,
edu.wpi.first.wpilibj.I2C.Port port,
byte address)
Get an instance of the IMU object.
|
BNO055.RevInfo |
getRevInfo()
Gets the chip revision numbers
|
BNO055.SystemStatus |
getSystemStatus()
Gets the latest system status info
|
int |
getTemp()
Get the sensors internal temperature.
|
double[] |
getVector()
Gets a vector representing the sensors position (heading, roll, pitch).
|
boolean |
isCalibrated()
Returns true if all required sensors (accelerometer, magnetometer,
gyroscope) have completed their respective calibration sequence.
|
boolean |
isInitialized()
After power is applied, the sensor needs to be configured for use.
|
boolean |
isSensorPresent()
Diagnostic method to determine if communications with the sensor are active.
|
void |
setMode(BNO055.opmode_t mode)
Puts the chip in the specified operating mode
|
public static final byte BNO055_ADDRESS_A
public static final byte BNO055_ADDRESS_B
public static final int BNO055_ID
public static BNO055 getInstance(BNO055.opmode_t mode, BNO055.vector_type_t vectorType, edu.wpi.first.wpilibj.I2C.Port port, byte address)
mode
- the operating mode to run the sensor in.port
- the physical port the sensor is plugged into on the roboRioaddress
- the address the sensor is at (0x28 or 0x29)public static BNO055 getInstance(BNO055.opmode_t mode, BNO055.vector_type_t vectorType)
mode
- the operating mode to run the sensor in.vectorType
- the format the position vector data should be returned
in (if you don't know use VECTOR_EULER).public void setMode(BNO055.opmode_t mode)
mode
- public BNO055.SystemStatus getSystemStatus()
public BNO055.RevInfo getRevInfo()
public boolean isSensorPresent()
public boolean isInitialized()
public BNO055.CalData getCalibration()
public boolean isCalibrated()
public int getTemp()
public double[] getVector()
For continuous rotation heading (doesn't roll over between 360/0) see the getHeading() method.
Maximum data output rates for Fusion modes - See 3.6.3
Operating Mode Data Output Rate IMU 100 Hz COMPASS 20 Hz M4G 50 Hz NDOF_FMC_OFF 100 Hz NDOF 100 Hz
public double getHeading()