mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
Wired close loop pos and vel to CANTalon::Set().
Did basic testing with close loop pos with talon slaving. Change-Id: I880a29bff29a43d45b7af1be05e08b09063bf5d7
This commit is contained in:
committed by
James Kuszmaul
parent
cdbe80315f
commit
d04476bb2f
@@ -87,23 +87,30 @@ void CANTalon::Set(float value, uint8_t syncGroup)
|
||||
if(m_controlEnabled) {
|
||||
CTR_Code status;
|
||||
switch(GetControlMode()) {
|
||||
case kThrottle:
|
||||
case CANSpeedController::kPercentVbus:
|
||||
{
|
||||
m_impl->Set(value);
|
||||
status = CTR_OKAY;
|
||||
}
|
||||
break;
|
||||
case kFollowerMode:
|
||||
case CANSpeedController::kFollower:
|
||||
{
|
||||
status = m_impl->SetDemand((int)value);
|
||||
}
|
||||
break;
|
||||
case kVoltageMode:
|
||||
case CANSpeedController::kVoltage:
|
||||
{
|
||||
// Voltage is an 8.8 fixed point number.
|
||||
int volts = int(value * 256);
|
||||
status = m_impl->SetDemand(volts);
|
||||
}
|
||||
break;
|
||||
case CANSpeedController::kSpeed:
|
||||
status = m_impl->SetDemand(value);
|
||||
break;
|
||||
case CANSpeedController::kPosition:
|
||||
status = m_impl->SetDemand(value);
|
||||
break;
|
||||
default:
|
||||
// TODO: Add support for other modes. Need to figure out what format
|
||||
// SetDemand needs.
|
||||
|
||||
Reference in New Issue
Block a user