46 CharMode::MODE_OPTIONS selectedTest;
57 void SimulationPeriodic()
override;
64 frc::Pose2d getCalculatedPose();
66 void setupGyro(
int,
const char*, units::degree_t, units::degree_t, units::degree_t);
68 frc::Rotation2d getGyro();
98 void updateAngularPosition();
109 void drive(units::velocity::meters_per_second_t
vx_mps, units::velocity::meters_per_second_t
vy_mps,
129 double getSkiddingRatio();
130 bool isRobotSkidding();
132 frc::Pose2d cachedRawPose;
133 frc::Pose2d cachedCalculatedPose;
134 frc::Pose2d cachedPredictedPose;
136 frc::ChassisSpeeds cachedChassisFieldSpeed;
137 frc::ChassisSpeeds cachedRobotRelativeSpeed;
144 units::angular_acceleration::radians_per_second_squared_t getSmoothedAngularAcceleration();
145 double rotationLerping(
double);
146 void followTrajectory(
const choreo::SwerveSample&
sample);
148 units::meter_t getDriveBaseRadius() {
return driveBaseRadius; };
155 frc::ChassisSpeeds commandedSpeeds;
157 units::meters_per_second_t maxDriveSpeed;
158 units::radians_per_second_t maxRotationSpeed;
160 std::unique_ptr<ctre::phoenix6::hardware::Pigeon2> pigeon;
161 std::unique_ptr<frc::SwerveDriveKinematics<MODULE_COUNT>> kinematics;
169 frc::ChassisSpeeds vectorLockedSpeeds(
const frc::ChassisSpeeds
speeds,
const frc::Rotation2d
heading);
171 frc::ChassisSpeeds getRobotRelativeSpeeds();
172 frc::ChassisSpeeds getFieldRelativeSpeeds();
175 units::radian_t angularPosition = 0
_rad;
177 wpi::array<frc::SwerveModuleState, MODULE_COUNT> testModeDesiredStates{wpi::empty_array};
179 std::vector<valor::SwerveModule*> swerveModules;
181 void startOdomThread(units::hertz_t
freq);
182 void updateOdometry();
184 static frc::ChassisSpeeds reflectDriveSpeeds(
const frc::ChassisSpeeds
unreflectedSpeeds) {
185 if (frc::DriverStation::GetAlliance().
value_or(frc::DriverStation::Alliance::kBlue) == frc::DriverStation::Alliance::kRed) {
191 frc::Timer resetOdom;
194 std::deque<units::angular_acceleration::radians_per_second_squared_t> yawRateBuffer;
196 static constexpr size_t ACCEL_BUFFER_SIZE = 10;
197 units::angular_velocity::radians_per_second_t lastYawRate = 0
_rad_per_s;
199 units::angular_acceleration::radians_per_second_squared_t angularAcceleration = 0
_rad_per_s_sq;
201 double _drivetrain_accel;
204 double carpetGrainMultiplier;
205 bool roughTowardsRed;
206 void calculateCarpetPose();
213 units::meter_t driveBaseRadius;
216 units::degree_t cachedGyroPitch{0
_deg};
217 units::degree_t cachedGyroYaw{0
_deg};
218 units::degree_t cachedGyroRoll{0
_deg};
219 wpi::array<frc::SwerveModuleState, MODULE_COUNT> cachedModuleStates{wpi::empty_array};
220 units::degrees_per_second_t cachedAngularVelocity{0
_deg_per_s};
222 frc::Notifier odometryThread{[
this] { updateOdometry(); }};
224 frc::PIDController xChoreoController{10.0, 0.0, 0.0};
225 frc::PIDController yChoreoController{10.0, 0.0, 0.0};
226 frc::PIDController headingChoreoController{7.5, 0.0, 0.0};
void drive(units::velocity::meters_per_second_t vx_mps, units::velocity::meters_per_second_t vy_mps, units::angular_velocity::radians_per_second_t omega_radps, bool isFOC)
Drives the robot with given x, y, and rotational velocities. This function internally converts the in...