mirror of
https://github.com/BroncBotz3481/YAGSL
synced 2026-06-19 06:21:40 +00:00
Upgrading to 2025.1.0.1
This commit is contained in:
@@ -1,9 +1,13 @@
|
||||
package swervelib.imu;
|
||||
|
||||
import static edu.wpi.first.units.Units.DegreesPerSecond;
|
||||
|
||||
import com.studica.frc.AHRS;
|
||||
import com.studica.frc.AHRS.NavXComType;
|
||||
import edu.wpi.first.math.geometry.Rotation3d;
|
||||
import edu.wpi.first.math.geometry.Translation3d;
|
||||
import edu.wpi.first.units.measure.AngularVelocity;
|
||||
import edu.wpi.first.units.measure.MutAngularVelocity;
|
||||
import edu.wpi.first.wpilibj.Alert;
|
||||
import edu.wpi.first.wpilibj.Alert.AlertType;
|
||||
import java.util.Optional;
|
||||
@@ -14,22 +18,26 @@ import java.util.Optional;
|
||||
public class NavXSwerve extends SwerveIMU
|
||||
{
|
||||
|
||||
/**
|
||||
* Mutable {@link AngularVelocity} for readings.
|
||||
*/
|
||||
private final MutAngularVelocity yawVel = new MutAngularVelocity(0, 0, DegreesPerSecond);
|
||||
/**
|
||||
* NavX IMU.
|
||||
*/
|
||||
private AHRS imu;
|
||||
private AHRS imu;
|
||||
/**
|
||||
* Offset for the NavX.
|
||||
*/
|
||||
private Rotation3d offset = new Rotation3d();
|
||||
private Rotation3d offset = new Rotation3d();
|
||||
/**
|
||||
* Inversion for the gyro
|
||||
*/
|
||||
private boolean invertedIMU = false;
|
||||
private boolean invertedIMU = false;
|
||||
/**
|
||||
* An {@link Alert} for if there is an error instantiating the NavX.
|
||||
*/
|
||||
private Alert navXError;
|
||||
private Alert navXError;
|
||||
|
||||
/**
|
||||
* Constructor for the NavX({@link AHRS}) swerve.
|
||||
@@ -133,14 +141,10 @@ public class NavXSwerve extends SwerveIMU
|
||||
.times(9.81));
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the rotation rate from the IMU in degrees per second. If rotation rate isn't supported returns empty.
|
||||
*
|
||||
* @return {@link Double} of the rotation rate as an {@link Optional}.
|
||||
*/
|
||||
public double getRate()
|
||||
@Override
|
||||
public MutAngularVelocity getYawAngularVelocity()
|
||||
{
|
||||
return imu.getRate();
|
||||
return yawVel.mut_setMagnitude(imu.getRate());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user