Added Config routine to allow enabling/disabling of limit switch and soft limits. This improves upon the ConfigLimitMode routine, which does not allow certain combinations of enable/disabled limit features.

Also keeps parity with LV and Java.

Change-Id: Id2f4c9f169effc6bc3ea48529e8f04f387609ddc
This commit is contained in:
Omar Zrien
2016-02-08 18:32:08 -05:00
committed by Brad Miller (WPI)
parent a33076ab9a
commit df33a78221
2 changed files with 66 additions and 1 deletions

View File

@@ -286,6 +286,9 @@ class CANTalon : public MotorSafety,
virtual void ConfigLimitMode(LimitMode mode) override;
virtual void ConfigForwardLimit(double forwardLimitPosition) override;
virtual void ConfigReverseLimit(double reverseLimitPosition) override;
void ConfigLimitSwitchOverrides(bool bForwardLimitSwitchEn, bool bReverseLimitSwitchEn);
void ConfigForwardSoftLimitEnable(bool bForwardSoftLimitEn);
void ConfigReverseSoftLimitEnable(bool bReverseSoftLimitEn);
/**
* Change the fwd limit switch setting to normally open or closed.
* Talon will disable momentarilly if the Talon's current setting

View File

@@ -1212,7 +1212,43 @@ void CANTalon::DisableSoftPositionLimits() {
}
/**
* TODO documentation (see CANJaguar.cpp)
* Overrides the forward and reverse limit switch enables.
* Unlike ConfigLimitMode, this function allows individual control of forward and
* reverse limit switch enables.
* Unlike ConfigLimitMode, this function does not affect the soft-limit features of Talon SRX.
* @see ConfigLimitMode()
*/
void CANTalon::ConfigLimitSwitchOverrides(bool bForwardLimitSwitchEn, bool bReverseLimitSwitchEn) {
CTR_Code status = CTR_OKAY;
int fwdRevEnable;
/* chose correct signal value based on caller's requests enables */
if(!bForwardLimitSwitchEn) {
/* caller wants Forward Limit Switch OFF */
if(!bReverseLimitSwitchEn) {
/* caller wants both OFF */
fwdRevEnable = CanTalonSRX::kLimitSwitchOverride_DisableFwd_DisableRev;
} else {
/* caller Forward OFF and Reverse ON */
fwdRevEnable = CanTalonSRX::kLimitSwitchOverride_DisableFwd_EnableRev;
}
} else {
/* caller wants Forward Limit Switch ON */
if(!bReverseLimitSwitchEn) {
/* caller wants Forward ON and Reverse OFF */
fwdRevEnable = CanTalonSRX::kLimitSwitchOverride_EnableFwd_DisableRev;
} else {
/* caller wants both ON */
fwdRevEnable = CanTalonSRX::kLimitSwitchOverride_EnableFwd_EnableRev;
}
}
/* update signal and error check code */
status = m_impl->SetOverrideLimitSwitchEn(fwdRevEnable);
if (status != CTR_OKAY) {
wpi_setErrorWithContext(status, getHALErrorMessage(status));
}
}
/**
* Configures the soft limit enable (wear leveled persistent memory).
* Also sets the limit switch overrides.
*/
@@ -1289,6 +1325,32 @@ void CANTalon::ConfigForwardLimit(double forwardLimitPosition) {
wpi_setErrorWithContext(status, getHALErrorMessage(status));
}
}
/**
* Set the Forward Soft Limit Enable.
* This is the same setting that is in the Web-Based Configuration.
* @param bForwardSoftLimitEn true to enable Soft limit, false to disable.
*/
void CANTalon::ConfigForwardSoftLimitEnable(bool bForwardSoftLimitEn) {
CTR_Code status = CTR_OKAY;
status = m_impl->SetForwardSoftEnable(bForwardSoftLimitEn);
if (status != CTR_OKAY) {
wpi_setErrorWithContext(status, getHALErrorMessage(status));
}
}
/**
* Set the Reverse Soft Limit Enable.
* This is the same setting that is in the Web-Based Configuration.
* @param bReverseSoftLimitEn true to enable Soft limit, false to disable.
*/
void CANTalon::ConfigReverseSoftLimitEnable(bool bReverseSoftLimitEn) {
CTR_Code status = CTR_OKAY;
status = m_impl->SetReverseSoftEnable(bReverseSoftLimitEn);
if (status != CTR_OKAY) {
wpi_setErrorWithContext(status, getHALErrorMessage(status));
}
}
/**
* Change the fwd limit switch setting to normally open or closed.
* Talon will disable momentarilly if the Talon's current setting