mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-03 03:01:44 +00:00
Fixed minor issues in CANTalon. Fixes artf3884, 3885, 3887.
Adds isEnabled and getSetpoint functions to CANTalon classes. Sets m_controlEnabled=false in Java if changeControlMode(Disabled) is called. Change-Id: I08fd0972df22ad83c5578dd43dd6b3536f3b365b
This commit is contained in:
@@ -19,6 +19,7 @@ CANTalon::CANTalon(int deviceNumber)
|
||||
, m_profile(0)
|
||||
, m_controlEnabled(true)
|
||||
, m_controlMode(kPercentVbus)
|
||||
, m_setPoint(0)
|
||||
{
|
||||
SetControlMode(m_controlMode);
|
||||
m_impl->SetProfileSlotSelect(m_profile);
|
||||
@@ -88,6 +89,7 @@ float CANTalon::Get()
|
||||
void CANTalon::Set(float value, uint8_t syncGroup)
|
||||
{
|
||||
if(m_controlEnabled) {
|
||||
m_setPoint = value;
|
||||
CTR_Code status;
|
||||
switch(m_controlMode) {
|
||||
case CANSpeedController::kPercentVbus:
|
||||
@@ -148,6 +150,13 @@ void CANTalon::EnableControl() {
|
||||
m_controlEnabled = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Whether the Talon is currently enabled.
|
||||
*/
|
||||
bool CANTalon::IsControlEnabled() {
|
||||
return m_controlEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param p Proportional constant to use in PID loop.
|
||||
* @see SelectProfileSlot to choose between the two sets of gains.
|
||||
@@ -341,6 +350,13 @@ double CANTalon::GetIzone()
|
||||
return (double)iz;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the current setpoint; ie, whatever was last passed to Set().
|
||||
*/
|
||||
double CANTalon::GetSetpoint() {
|
||||
return m_setPoint;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the voltage coming in from the battery.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user