mirror of
https://github.com/BroncBotz3481/YAGSL
synced 2026-07-02 07:21:39 +00:00
Upgrading to 2025.1.0.1
This commit is contained in:
@@ -8,7 +8,9 @@ import com.ctre.phoenix6.configs.Pigeon2Configurator;
|
||||
import com.ctre.phoenix6.hardware.Pigeon2;
|
||||
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.LinearAcceleration;
|
||||
import edu.wpi.first.units.measure.MutAngularVelocity;
|
||||
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Supplier;
|
||||
@@ -22,23 +24,28 @@ public class Pigeon2Swerve extends SwerveIMU
|
||||
/**
|
||||
* Wait time for status frames to show up.
|
||||
*/
|
||||
public static double STATUS_TIMEOUT_SECONDS = 0.04;
|
||||
public static double STATUS_TIMEOUT_SECONDS = 0.04;
|
||||
/**
|
||||
* {@link Pigeon2} IMU device.
|
||||
*/
|
||||
private final Pigeon2 imu;
|
||||
private final Pigeon2 imu;
|
||||
/**
|
||||
* Mutable {@link AngularVelocity} for readings.
|
||||
*/
|
||||
private final MutAngularVelocity yawVel = new MutAngularVelocity(0, 0, DegreesPerSecond);
|
||||
|
||||
/**
|
||||
* Offset for the {@link Pigeon2}.
|
||||
*/
|
||||
private Rotation3d offset = new Rotation3d();
|
||||
private Rotation3d offset = new Rotation3d();
|
||||
/**
|
||||
* Inversion for the gyro
|
||||
*/
|
||||
private boolean invertedIMU = false;
|
||||
private boolean invertedIMU = false;
|
||||
/**
|
||||
* {@link Pigeon2} configurator.
|
||||
*/
|
||||
private Pigeon2Configurator cfg;
|
||||
private Pigeon2Configurator cfg;
|
||||
|
||||
/**
|
||||
* X Acceleration supplier
|
||||
@@ -158,14 +165,10 @@ public class Pigeon2Swerve 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 Rotation rate in DegreesPerSecond.
|
||||
*/
|
||||
public double getRate()
|
||||
@Override
|
||||
public MutAngularVelocity getYawAngularVelocity()
|
||||
{
|
||||
return imu.getAngularVelocityZWorld().waitForUpdate(STATUS_TIMEOUT_SECONDS).getValue().in(DegreesPerSecond);
|
||||
return yawVel.mut_replace(imu.getAngularVelocityZWorld().waitForUpdate(STATUS_TIMEOUT_SECONDS).getValue());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user