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,7 +1,11 @@
|
||||
package swervelib.imu;
|
||||
|
||||
import static edu.wpi.first.units.Units.DegreesPerSecond;
|
||||
|
||||
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.AnalogGyro;
|
||||
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
|
||||
import java.util.Optional;
|
||||
@@ -15,15 +19,19 @@ public class AnalogGyroSwerve extends SwerveIMU
|
||||
/**
|
||||
* Gyroscope object.
|
||||
*/
|
||||
private final AnalogGyro imu;
|
||||
private final AnalogGyro imu;
|
||||
/**
|
||||
* Mutable {@link AngularVelocity} for readings.
|
||||
*/
|
||||
private final MutAngularVelocity yawVel = new MutAngularVelocity(0, 0, DegreesPerSecond);
|
||||
/**
|
||||
* Offset for the analog gyro.
|
||||
*/
|
||||
private Rotation3d offset = new Rotation3d();
|
||||
private Rotation3d offset = new Rotation3d();
|
||||
/**
|
||||
* Inversion for the gyro
|
||||
*/
|
||||
private boolean invertedIMU = false;
|
||||
private boolean invertedIMU = false;
|
||||
|
||||
/**
|
||||
* Analog port in which the gyroscope is connected. Can only be attached to analog ports 0 or 1.
|
||||
@@ -115,14 +123,10 @@ public class AnalogGyroSwerve extends SwerveIMU
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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