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

@@ -375,6 +375,15 @@ public class CANJaguar implements MotorSafety, PIDOutput, CANSpeedController {
byte[] data = new byte[8];
byte dataSize;
if (m_safetyHelper != null)
m_safetyHelper.feed();
if (m_stopped)
{
enableControl();
m_stopped = false;
}
if (m_controlEnabled) {
switch (m_controlMode) {
case PercentVbus:
@@ -412,9 +421,6 @@ public class CANJaguar implements MotorSafety, PIDOutput, CANSpeedController {
}
sendMessage(messageID, data, dataSize, kSendMessagePeriod);
if (m_safetyHelper != null)
m_safetyHelper.feed();
}
m_value = outputValue;
@@ -1890,6 +1896,7 @@ public class CANJaguar implements MotorSafety, PIDOutput, CANSpeedController {
static final int kReceiveStatusAttempts = 50;
boolean m_controlEnabled = true;
boolean m_stopped = false;
static void sendMessageHelper(int messageID, byte[] data, int dataSize, int period)
throws CANMessageNotFoundException {
@@ -2247,6 +2254,7 @@ public class CANJaguar implements MotorSafety, PIDOutput, CANSpeedController {
@Deprecated
public void stopMotor() {
disableControl();
m_stopped = true;
}
/*

View File

@@ -284,6 +284,7 @@ public class CANTalon implements MotorSafety, PIDOutput, PIDSource, CANSpeedCont
int m_deviceNumber;
boolean m_controlEnabled;
boolean m_stopped = false;
int m_profile;
double m_setPoint;
@@ -423,6 +424,11 @@ public class CANTalon implements MotorSafety, PIDOutput, PIDSource, CANSpeedCont
public void set(double outputValue) {
/* feed safety helper since caller just updated our output */
m_safetyHelper.feed();
if(m_stopped)
{
enableControl();
m_stopped = false;
}
if (m_controlEnabled) {
m_setPoint = outputValue; /* cache set point for getSetpoint() */
switch (m_controlMode) {
@@ -1215,6 +1221,7 @@ public class CANTalon implements MotorSafety, PIDOutput, PIDSource, CANSpeedCont
@Deprecated
public void stopMotor() {
disableControl();
m_stopped = true;
}
@Override