This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | Last revisionBoth sides next revision | ||
first:adis16470_imu_frc:java [04 Jan 2020 07:47] – add 2020 construction warning Kristen Chong | first:adis16470_imu_frc:java [11 Jan 2020 04:40] – updated for 2020 and fixed incorrect MXP port references Kristen Chong | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | <note warning> | ||
====== Using the ADIS16470 IMU Board for FRC in Java ====== | ====== Using the ADIS16470 IMU Board for FRC in Java ====== | ||
This guide will walk you through the various features of the Analog Devices library for the ADIS16470 FRC IMU Board and how to use it in your robot code. If you're looking for a guide in another language, [[first: | This guide will walk you through the various features of the Analog Devices library for the ADIS16470 FRC IMU Board and how to use it in your robot code. If you're looking for a guide in another language, [[first: | ||
Line 8: | Line 7: | ||
\\ | \\ | ||
===== Installing the Library ===== | ===== Installing the Library ===== | ||
- | In order to use the IMU, you will need to download and install the appropriate library. You can either do an online install or an offline install. The instructions below assume you are using VS Code, the official supported development environment for FRC. | + | In order to use the IMU, you will need to download and install the appropriate library. The instructions below assume you are using VS Code, the official supported development environment for FRC. |
- | ==== Online Install ==== | + | |
- | - Open FRC Visual Studio Code | + | |
- | - Click the WPILib command pallete icon | + | |
- | - Select " | + | |
- | - Choose " | + | |
- | - Paste the following link: http:// | + | |
==== Offline Install ==== | ==== Offline Install ==== | ||
- Download the latest release zip from [[https:// | - Download the latest release zip from [[https:// | ||
Line 30: | Line 24: | ||
\\ | \\ | ||
\\ | \\ | ||
- | Because the IMU plugs directly into the MXP port, the library will pre-define your SPI port for you. IMU is a 3-axis sensor, so you will need to tell it which axis is the yaw axis. By default, this will be the Z axis if you don't define anything (this would be with the RoboRIO and the sensor sitting flat on or in the robot, facing up). Don't worry about defining an algorithm argument, the library will take care of this for you. A typical definition and instantiation will look like this: | + | Because the IMU plugs directly into the SPI port, the library will pre-define your SPI port for you. IMU is a 3-axis sensor, so you will need to tell it which axis is the yaw axis. By default, this will be the Z axis if you don't define anything (this would be with the RoboRIO and the sensor sitting flat on or in the robot, facing up). Don't worry about defining an algorithm argument, the library will take care of this for you. A typical definition and instantiation will look like this: |
< | < | ||
public static final ADIS16470_IMU imu = new ADIS16470_IMU(); | public static final ADIS16470_IMU imu = new ADIS16470_IMU(); | ||
Line 36: | Line 30: | ||
\\ | \\ | ||
===== Sensor Initialization/ | ===== Sensor Initialization/ | ||
- | The IMU library will perform a calibration for you in its constructor, | + | The IMU library will perform a calibration for you in its constructor, |
+ | |||
+ | New for 2020, the calibrate() function now happens immediately when called. The ADIS16470 has an internal accumulation measurement which is applied as the new offset calibration value when calibrate() is called. Because of this, you should never run this command after the robot has started to move and should never be called during match play! This function is ideal for situations where the robot was powered on while moving during the initial calibration or if your robot has been sitting for a long time waiting for a match to start. | ||
\\ | \\ | ||
\\ | \\ | ||
===== Using getAngle() and getRate() ===== | ===== Using getAngle() and getRate() ===== | ||
- | Now that your gyro is calibrated when the robot turns on, you can access data from the robot in your code. You can do this using the getAngle() method to obtain the robot' | + | Now that your gyro is calibrated when the robot turns on, you can access data from the robot in your code. You can do this using the getAngle() method to obtain the robot' |
\\ | \\ | ||
\\ | \\ |