Add an additional member variable for "stopped" which indicates the CAN motor controller has been explicitly stopped, but not disabled by the user (main use case is MotorSafety tripping). When Set() is called the next time the controller will be re-enabled automatically.

Change-Id: Ib1c0e5d0ddd55343d83039acbc46c0f9c4e451a1
This commit is contained in:
Kevin O'Connor
2016-02-08 18:13:57 -05:00
parent f17d27aacf
commit d567bd0bca
6 changed files with 39 additions and 10 deletions

View File

@@ -134,6 +134,12 @@ float CANTalon::Get() const {
void CANTalon::Set(float value, uint8_t syncGroup) {
/* feed safety helper since caller just updated our output */
m_safetyHelper->Feed();
if (m_stopped) {
EnableControl();
m_stopped = false;
}
if (m_controlEnabled) {
m_setPoint = value; /* cache set point for GetSetpoint() */
CTR_Code status = CTR_OKAY;
@@ -1825,12 +1831,15 @@ void CANTalon::SetInverted(bool isInverted) { m_isInverted = isInverted; }
bool CANTalon::GetInverted() const { return m_isInverted; }
/**
* Common interface for stopping the motor
* Common interface for stopping the motor until the next Set() call
* Part of the MotorSafety interface
*
* @deprecated Call Disable instead.
*/
void CANTalon::StopMotor() { Disable(); }
void CANTalon::StopMotor() {
Disable();
m_stopped = true;
}
void CANTalon::ValueChanged(ITable* source, llvm::StringRef key,
std::shared_ptr<nt::Value> value, bool isNew) {