Files
YAGSL/swervelib/imu/PigeonSwerve.java

76 lines
1.3 KiB
Java
Raw Normal View History

2023-02-13 14:37:05 -06:00
package frc.robot.subsystems.swervedrive2.swervelib.imu;
import com.ctre.phoenix.sensors.WPI_PigeonIMU;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
/**
* SwerveIMU interface for the Pigeon.
*/
public class PigeonSwerve extends SwerveIMU
{
WPI_PigeonIMU imu;
/**
* Generate the SwerveIMU for pigeon.
*
* @param canid CAN ID for the pigeon, does not support CANBus.
*/
public PigeonSwerve(int canid)
{
imu = new WPI_PigeonIMU(canid);
SmartDashboard.putData(imu);
}
/**
* Reset IMU to factory default.
*/
@Override
public void factoryDefault()
{
imu.configFactoryDefault();
}
/**
* Clear sticky faults on IMU.
*/
@Override
public void clearStickyFaults()
{
imu.clearStickyFaults();
}
/**
* Set the yaw in degrees.
*
* @param yaw Angle in degrees.
*/
@Override
public void setYaw(double yaw)
{
imu.setYaw(yaw);
}
/**
* Fetch the yaw/pitch/roll from the IMU, inverts them all if SwerveIMU is inverted.
*
* @param yprArray Array which will be filled with {yaw, pitch, roll} in degrees.
*/
@Override
public void getYawPitchRoll(double[] yprArray)
{
imu.getYawPitchRoll(yprArray);
}
/**
* Get the instantiated IMU object.
*
* @return IMU object.
*/
@Override
public Object getIMU()
{
return imu;
}
}