75 bool TalonSRXConfig(ctre::phoenix::motorcontrol::can::TalonSRX& motorController,
76 units::millisecond_t configTimeout) {
77 ctre::phoenix::motorcontrol::can::TalonSRXConfiguration config;
78 auto timeout = configTimeout.to<
int>();
81 motorController.SetInverted(T::inverted);
84 motorController.SetSensorPhase(T::sensorPhase);
87 motorController.SetNeutralMode(T::neutralMode);
90 constexpr units::volt_t voltage = T::voltCompSat;
91 config.voltageCompSaturation = voltage.to<
double>();
92 motorController.EnableVoltageCompensation(
true);
94 motorController.EnableVoltageCompensation(
false);
97 ctre::phoenix::motorcontrol::can::FilterConfiguration filterConfig;
98 filterConfig.remoteSensorDeviceID = T::remoteFilter0_addr.address;
99 filterConfig.remoteSensorSource = T::remoteFilter0_type;
100 config.remoteFilter0 = filterConfig;
103 config.primaryPID.selectedFeedbackSensor = T::pid0_selectedSensor;
106 config.slot0.kP = T::pid0_kP;
109 config.slot0.kI = T::pid0_kI;
112 config.slot0.kD = T::pid0_kD;
115 config.slot0.kF = T::pid0_kF;
118 config.slot0.integralZone = T::pid0_iZone;
121 config.slot0.allowableClosedloopError = T::pid0_allowableError;
124 constexpr units::ampere_t currentLimit = T::peakCurrentLimit;
125 static_assert(currentLimit.to<
double>() > 0,
"Current limit must be positive");
126 config.peakCurrentLimit = std::round(currentLimit.to<
double>());
129 constexpr units::millisecond_t currentDuration = T::peakCurrentDuration;
130 static_assert(currentDuration.to<
double>() > 0,
"Current duration must be positive");
131 config.peakCurrentDuration = std::round(currentDuration.to<
double>());
134 constexpr units::ampere_t currentLimit = T::continuousCurrentLimit;
135 static_assert(currentLimit.to<
double>() > 0,
"Current limit must be positive");
136 config.continuousCurrentLimit = std::round(currentLimit.to<
double>());
139 config.peakOutputForward = T::peakOutputForward;
142 config.peakOutputReverse = T::peakOutputReverse;
150 config.forwardLimitSwitchSource = T::forwardLimitSwitchSource;
154 config.reverseLimitSwitchSource = T::reverseLimitSwitchSource;
158 config.forwardLimitSwitchNormal = T::forwardLimitSwitchNormal;
162 config.reverseLimitSwitchNormal = T::reverseLimitSwitchNormal;
167 motorController.EnableCurrentLimit(
true);
169 motorController.EnableCurrentLimit(
false);
174 config.peakCurrentLimit = 0;
177 return 0 != motorController.ConfigAllSettings(config, timeout);