69 TalonSRXConfiguration config;
70 auto timeout = configTimeout.to<
int>();
73 motorController.SetInverted(T::inverted);
76 motorController.SetSensorPhase(T::sensorPhase);
79 motorController.SetNeutralMode(T::neutralMode);
82 constexpr units::volt_t voltage = T::voltCompSat;
83 config.voltageCompSaturation = voltage.to<
double>();
84 motorController.EnableVoltageCompensation(
true);
86 motorController.EnableVoltageCompensation(
false);
89 ctre::phoenix::motorcontrol::can::FilterConfiguration filterConfig;
90 filterConfig.remoteSensorDeviceID = T::remoteFilter0_addr.address;
91 filterConfig.remoteSensorSource = T::remoteFilter0_type;
92 config.remoteFilter0 = filterConfig;
95 config.primaryPID.selectedFeedbackSensor = T::pid0_selectedSensor;
98 config.slot0.kP = T::pid0_kP;
101 config.slot0.kI = T::pid0_kI;
104 config.slot0.kD = T::pid0_kD;
107 config.slot0.kF = T::pid0_kF;
110 config.slot0.integralZone = T::pid0_iZone;
113 config.slot0.allowableClosedloopError = T::pid0_allowableError;
116 constexpr units::ampere_t currentLimit = T::peakCurrentLimit;
117 static_assert(currentLimit.to<
double>() > 0,
"Current limit must be positive");
118 config.peakCurrentLimit = std::round(currentLimit.to<
double>());
121 constexpr units::millisecond_t currentDuration = T::peakCurrentDuration;
122 static_assert(currentDuration.to<
double>() > 0,
"Current duration must be positive");
123 config.peakCurrentDuration = std::round(currentDuration.to<
double>());
126 constexpr units::ampere_t currentLimit = T::continuousCurrentLimit;
127 static_assert(currentLimit.to<
double>() > 0,
"Current limit must be positive");
128 config.continuousCurrentLimit = std::round(currentLimit.to<
double>());
131 config.peakOutputForward = T::peakOutputForward;
134 config.peakOutputReverse = T::peakOutputReverse;
143 motorController.EnableCurrentLimit(
true);
145 motorController.EnableCurrentLimit(
false);
150 config.peakCurrentLimit = 0;
153 return 0 != motorController.ConfigAllSettings(config, timeout);