Wiki

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
first:adis16470_imu_frc:java [26 Dec 2018 03:23] – add github link Kristen Chongfirst:adis16470_imu_frc:java [11 Jan 2020 04:40] – updated for 2020 and fixed incorrect MXP port references Kristen Chong
Line 7: Line 7:
 \\ \\
 ===== Installing the Library ===== ===== Installing the Library =====
-In order to use the IMU, you will need to download and install the appropriate library. There are two ways to do thisdepending on your team's programming environment setup+In order to use the IMU, you will need to download and install the appropriate library. The instructions below assume you are using VS Codethe official supported development environment for FRC. 
-==== Gradle Install ==== + 
-Since this library depends on the WPI library, **we strongly recommend any teams using Gradle to use [[https://github.com/Open-RIO/GradleRIO|GradleRIO]] for this install!** First, add [[https://jitpack.io/#juchong/ADIS16470-RoboRIO-Driver|JitPack]] to your repositories block like this: +==== Offline Install ==== 
-<code> +  - Download the latest release zip from [[https://github.com/juchong/ADIS16470-RoboRIO-Driver/releases|this page]]. The zip will be named adis16470_roborio-[releaseversion].zip
-maven { url 'https://jitpack.io' } +  Close all instances of FRC Visual Studio Code 
-</code> +  If using Windows, extract the zip you downloaded to C:\Users\Public\frc2019. If using Linux or Macextract the zip to ~/home/frc2019/. 
-Then, add the following code line to your dependencies block. This will always be the most recent version+  Open FRC Visual Studio Code 
-<code> +  Click the WPILib command pallete icon 
-compile 'com.github.juchong:ADIS16470-RoboRIO-Driver:master-SNAPSHOT' +  - Select "Manage Vendor Libraries" in the menu 
-</code> +  - Choose "Install New Libraries (Offline)" 
-[[https://github.com/juchong/ADIS16470-RoboRIO-Driver/blob/master/Java/build.gradle.example|Your GradleRIO file should look like this when it's done if you use GradleRIO]] +  - Check ADIS16470, then click "OK".
-\\ +
-\+
-==== Manual Install ==== +
-To install the driver manuallyjust add the com/analog/adis16470 package to your srcfolder. You can find the GitHub repository for Java [[https://github.com/juchong/ADIS16470-RoboRIO-Driver/tree/master/Java|here]].+
 \\ \\
 \\ \\
Line 28: 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:
 <code> <code>
 public static final ADIS16470_IMU imu = new ADIS16470_IMU(); public static final ADIS16470_IMU imu = new ADIS16470_IMU();
Line 34: Line 30:
 \\ \\
 ===== Sensor Initialization/Calibration with calibrate() ===== ===== Sensor Initialization/Calibration with calibrate() =====
-The IMU library will perform a calibration for you in its constructor, since this calibration **MUST** be performed in order for the IMU to function properly. If you wish to re-calibrate at some point in your code, you can call the calibrate() function. For more general information about offset calibration, please see the [[first:adis16470_imu_frc|general ADIS16470 IMU page]].+The IMU library will perform a calibration for you in its constructor, since this calibration MUST be performed in order for the IMU to function properly. The calibration inside of the constructor takes 4 seconds long by default, but you can change this by using the configCalTime() function. If you want to re-calibrate at some point in your code, you can call the calibrate() function. For more general information about offset calibration, please see the [[first:adis16470_imu_frc|general ADIS16470]] IMU page. 
 + 
 +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's current yaw heading, or more rarely by using the getRate() method to obtain the current rotation rate being measured should you happen to need it. The most common places to use these functions are inside of the autonomousPeriodic() and teleopPeriodic() methods. If you want a specific angle, you can also call that angle directly using getAngleX()getAngleY(), or getAngleZ(). You can do the same for rotation rates, using getRateX(), getRateY(), and getRateZ().+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's current yaw heading, or more rarely by using the getRate() method to obtain the current rotation rate being measured should you happen to need it. The most common places to use these functions are inside of the autonomousPeriodic() and teleopPeriodic() methods. By default, getAngle() returns the Y-axis angle, but you can change this by specifying a specific axis. If you know that your IMU will be mounted in such a way that the primary “yaw” axis is not the same as the IMU's Y axisyou can change the yaw axis by using setYawAxis().
 \\ \\
 \\ \\
first/adis16470_imu_frc/java.txt · Last modified: 31 Jan 2020 01:54 by Kristen Chong