Two param constructor added to C++/java CANTalon so caller can optionally specify the periodMs at which the talon control frame is sent.

The param is capped in the HAL C++ class to [1ms, 95ms] so that zero and negative periods are caped to 1ms, and so that caller can't pass an absurdly large value, which causes TALON is appear disabled.

Change-Id: I4207194be25a33bbd6ad281a75301ce6684659a5
This commit is contained in:
Omar Zrien
2014-12-14 17:09:52 -05:00
parent 77997e52fb
commit 6a7e7cf611
4 changed files with 34 additions and 1 deletions

View File

@@ -24,7 +24,24 @@ CANTalon::CANTalon(int deviceNumber)
SetControlMode(m_controlMode);
m_impl->SetProfileSlotSelect(m_profile);
}
/**
* Constructor for the CANTalon device.
* @param deviceNumber The CAN ID of the Talon SRX
* @param controlPeriodMs The period in ms to send the CAN control frame.
* Period is bounded to [1ms, 95ms].
*/
CANTalon::CANTalon(int deviceNumber,int controlPeriodMs)
: m_deviceNumber(deviceNumber)
, m_impl(new CanTalonSRX(deviceNumber,controlPeriodMs)) /* bounded underneath to be within [1 ms,95 ms] */
, m_safetyHelper(new MotorSafetyHelper(this))
, m_profile(0)
, m_controlEnabled(true)
, m_controlMode(kPercentVbus)
, m_setPoint(0)
{
SetControlMode(m_controlMode);
m_impl->SetProfileSlotSelect(m_profile);
}
CANTalon::~CANTalon() {
delete m_impl;
delete m_safetyHelper;