mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-25 01: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) {
|
if(m_controlEnabled) {
|
||||||
CTR_Code status;
|
CTR_Code status;
|
||||||
switch(GetControlMode()) {
|
switch(GetControlMode()) {
|
||||||
case kThrottle:
|
case CANSpeedController::kPercentVbus:
|
||||||
{
|
{
|
||||||
m_impl->Set(value);
|
m_impl->Set(value);
|
||||||
status = CTR_OKAY;
|
status = CTR_OKAY;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case kFollowerMode:
|
case CANSpeedController::kFollower:
|
||||||
{
|
{
|
||||||
status = m_impl->SetDemand((int)value);
|
status = m_impl->SetDemand((int)value);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case kVoltageMode:
|
case CANSpeedController::kVoltage:
|
||||||
{
|
{
|
||||||
// Voltage is an 8.8 fixed point number.
|
// Voltage is an 8.8 fixed point number.
|
||||||
int volts = int(value * 256);
|
int volts = int(value * 256);
|
||||||
status = m_impl->SetDemand(volts);
|
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:
|
default:
|
||||||
// TODO: Add support for other modes. Need to figure out what format
|
// TODO: Add support for other modes. Need to figure out what format
|
||||||
// SetDemand needs.
|
// SetDemand needs.
|
||||||
|
|||||||
Reference in New Issue
Block a user