91 TalonFXSWrapper(ctre::phoenix6::hardware::TalonFXS* talon, wpi::math::DCMotor dcMotor,
107 TalonFXSWrapper(ctre::phoenix6::hardware::TalonFXS* talon, wpi::math::DCMotor dcMotor,
209 void SetVelocity(wpi::units::turns_per_second_t velocity)
override;
216 void SetVelocity(wpi::units::meters_per_second_t velocity)
override;
228 wpi::units::newton_t feedforwardForce)
override;
361 std::optional<wpi::units::volt_t> maxInput)
override;
399 ctre::phoenix6::hardware::TalonFXS* m_talon;
400 wpi::math::DCMotor m_dcMotor;
403 ctre::phoenix6::signals::MotorArrangementValue m_motorArrangement{
404 ctre::phoenix6::signals::MotorArrangementValue::Disabled};
405 ctre::phoenix6::signals::AdvancedHallSupportValue m_advancedHallSupport{
406 ctre::phoenix6::signals::AdvancedHallSupportValue::Disabled};
409 const bool m_reportStatusSignalErrors;
410 ctre::phoenix6::configs::TalonFXSConfiguration m_talonConfig;
413 using PositionControlRequest = std::variant<
414 ctre::phoenix6::controls::PositionVoltage, ctre::phoenix6::controls::PositionDutyCycle,
415 ctre::phoenix6::controls::PositionTorqueCurrentFOC,
416 ctre::phoenix6::controls::MotionMagicVoltage, ctre::phoenix6::controls::MotionMagicDutyCycle,
417 ctre::phoenix6::controls::MotionMagicExpoVoltage,
418 ctre::phoenix6::controls::MotionMagicExpoDutyCycle,
419 ctre::phoenix6::controls::MotionMagicTorqueCurrentFOC>;
420 using VelocityControlRequest =
421 std::variant<ctre::phoenix6::controls::VelocityVoltage,
422 ctre::phoenix6::controls::VelocityDutyCycle,
423 ctre::phoenix6::controls::VelocityTorqueCurrentFOC,
424 ctre::phoenix6::controls::MotionMagicVelocityVoltage,
425 ctre::phoenix6::controls::MotionMagicVelocityDutyCycle,
426 ctre::phoenix6::controls::MotionMagicVelocityTorqueCurrentFOC>;
428 PositionControlRequest m_positionReq{ctre::phoenix6::controls::PositionVoltage{0_tr}};
429 VelocityControlRequest m_velocityReq{ctre::phoenix6::controls::VelocityVoltage{0_tps}};
430 ctre::phoenix6::controls::VoltageOut m_voltageReq{0_V};
431 ctre::phoenix6::controls::DutyCycleOut m_dutyCycleReq{0.0};
434 ctre::phoenix6::hardware::CANcoder* m_cancoder{
nullptr};
435 ctre::phoenix6::hardware::CANdi* m_candi{
nullptr};
438 std::optional<wpi::sim::DCMotorSim> m_motorSim;
441 std::optional<wpi::util::Alert> m_rioControllerAlert;
443 std::optional<wpi::util::Alert> m_startingPositionExternalEncoderAlert;
445 std::optional<wpi::util::Alert> m_zeroOffsetNoExternalEncoderAlert;
447 std::optional<wpi::util::Alert> m_discontinuityPointNoExternalEncoderAlert;
450 static MotorArrangement ArrangementForMotor(ctre::phoenix6::hardware::TalonFXS* talon,
451 const wpi::math::DCMotor& motor);
453 std::string AlertId(
const std::string& alertType)
const;
455 void EnsureRequest(
const std::function<ctre::phoenix::StatusCode()>& request);
457 template <
typename Group>
458 ctre::phoenix::StatusCode ApplyGroup(
const Group& group);
460 void SetFOC(
bool foc);
462 double PositionGainUnitsPerRotation()
const;
464 double VelocityGainUnitsPerRotation()
const;
466 double AccelerationGainUnitsPerRotation()
const;
470 void WriteSlotGains(
const SmartMotorControllerConfig& config);
472 void WriteMotionMagic(
const SmartMotorControllerConfig& config);
474 void WriteSensorRatios(
const SmartMotorControllerConfig& config);
476 void ApplyExternalEncoder(
const SmartMotorControllerConfig& config);
478 std::optional<wpi::units::turn_t> GetExternalEncoderSensorPosition();
480 std::optional<wpi::units::turns_per_second_t> GetExternalEncoderSensorVelocity();
482 void ApplyFollowers(
const SmartMotorControllerConfig& config);
484 void ApplyVendorControlRequest(
const SmartMotorControllerConfig& config);