90 TalonFXWrapper(ctre::phoenix6::hardware::TalonFX* talon, wpi::math::DCMotor dcMotor,
192 void SetVelocity(wpi::units::turns_per_second_t velocity)
override;
199 void SetVelocity(wpi::units::meters_per_second_t velocity)
override;
211 wpi::units::newton_t feedforwardForce)
override;
344 std::optional<wpi::units::volt_t> maxInput)
override;
382 ctre::phoenix6::hardware::TalonFX* m_talon;
383 wpi::math::DCMotor m_dcMotor;
386 const bool m_reportStatusSignalErrors;
387 ctre::phoenix6::configs::TalonFXConfiguration m_talonConfig;
390 using PositionControlRequest = std::variant<
391 ctre::phoenix6::controls::PositionVoltage, ctre::phoenix6::controls::PositionDutyCycle,
392 ctre::phoenix6::controls::PositionTorqueCurrentFOC,
393 ctre::phoenix6::controls::MotionMagicVoltage, ctre::phoenix6::controls::MotionMagicDutyCycle,
394 ctre::phoenix6::controls::MotionMagicExpoVoltage,
395 ctre::phoenix6::controls::MotionMagicExpoDutyCycle,
396 ctre::phoenix6::controls::MotionMagicTorqueCurrentFOC>;
397 using VelocityControlRequest =
398 std::variant<ctre::phoenix6::controls::VelocityVoltage,
399 ctre::phoenix6::controls::VelocityDutyCycle,
400 ctre::phoenix6::controls::VelocityTorqueCurrentFOC,
401 ctre::phoenix6::controls::MotionMagicVelocityVoltage,
402 ctre::phoenix6::controls::MotionMagicVelocityDutyCycle,
403 ctre::phoenix6::controls::MotionMagicVelocityTorqueCurrentFOC>;
405 PositionControlRequest m_positionReq{ctre::phoenix6::controls::PositionVoltage{0_tr}};
406 VelocityControlRequest m_velocityReq{ctre::phoenix6::controls::VelocityVoltage{0_tps}};
407 ctre::phoenix6::controls::VoltageOut m_voltageReq{0_V};
408 ctre::phoenix6::controls::DutyCycleOut m_dutyCycleReq{0.0};
411 ctre::phoenix6::hardware::CANcoder* m_cancoder{
nullptr};
412 ctre::phoenix6::hardware::CANdi* m_candi{
nullptr};
415 std::optional<wpi::sim::DCMotorSim> m_motorSim;
418 std::optional<wpi::util::Alert> m_rioControllerAlert;
420 std::optional<wpi::util::Alert> m_startingPositionExternalEncoderAlert;
422 std::optional<wpi::util::Alert> m_zeroOffsetNoExternalEncoderAlert;
424 std::optional<wpi::util::Alert> m_feedbackNotAppliedAlert;
426 std::optional<wpi::util::Alert> m_feedforwardNotAppliedAlert;
428 std::optional<wpi::util::Alert> m_discontinuityPointNoExternalEncoderAlert;
431 std::string AlertId(
const std::string& alertType)
const;
433 void EnsureRequest(
const std::function<ctre::phoenix::StatusCode()>& request);
435 template <
typename Group>
436 ctre::phoenix::StatusCode ApplyGroup(
const Group& group,
437 wpi::units::second_t retryFor = wpi::units::second_t{0.1});
439 void SetFOC(
bool foc);
441 double PositionGainUnitsPerRotation()
const;
443 double VelocityGainUnitsPerRotation()
const;
445 double AccelerationGainUnitsPerRotation()
const;
449 void WriteSlotGains(
const SmartMotorControllerConfig& config);
451 void WriteMotionMagic(
const SmartMotorControllerConfig& config);
453 void WriteSensorRatios(
const SmartMotorControllerConfig& config);
455 void ApplyExternalEncoder(
const SmartMotorControllerConfig& config);
457 std::optional<wpi::units::turn_t> GetExternalEncoderSensorPosition();
459 std::optional<wpi::units::turns_per_second_t> GetExternalEncoderSensorVelocity();
461 void ApplyFollowers(
const SmartMotorControllerConfig& config);
463 void ApplyVendorControlRequest(
const SmartMotorControllerConfig& config);