WPILibC++  unspecified
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Pages
CANTalon Class Reference

CTRE Talon SRX Speed Controller with CAN Control. More...

#include <CANTalon.h>

Inheritance diagram for CANTalon:
MotorSafety CANSpeedController ErrorBase LiveWindowSendable ITableListener PIDSource PIDInterface SpeedController Sendable Controller PIDOutput

Classes

struct  MotionProfileStatus
 Motion Profile Status This is simply a data transer object. More...
 
struct  TrajectoryPoint
 Motion Profile Trajectory Point This is simply a data transer object. More...
 

Public Types

enum  FeedbackDevice {
  QuadEncoder = 0, AnalogPot = 2, AnalogEncoder = 3, EncRising = 4,
  EncFalling = 5, CtreMagEncoder_Relative = 6, CtreMagEncoder_Absolute = 7, PulseWidth = 8
}
 
enum  FeedbackDeviceStatus { FeedbackStatusUnknown = 0, FeedbackStatusPresent = 1, FeedbackStatusNotPresent = 2 }
 Depending on the sensor type, Talon can determine if sensor is plugged in ot not. More...
 
enum  StatusFrameRate {
  StatusFrameRateGeneral = 0, StatusFrameRateFeedback = 1, StatusFrameRateQuadEncoder = 2, StatusFrameRateAnalogTempVbat = 3,
  StatusFrameRatePulseWidthMeas = 4
}
 
enum  SetValueMotionProfile { SetValueMotionProfileDisable = 0, SetValueMotionProfileEnable = 1, SetValueMotionProfileHold = 2 }
 Enumerated types for Motion Control Set Values. More...
 
- Public Types inherited from CANSpeedController
enum  ControlMode {
  kPercentVbus = 0, kCurrent = 1, kSpeed = 2, kPosition = 3,
  kVoltage = 4, kFollower = 5, kMotionProfile = 6
}
 
enum  Faults {
  kCurrentFault = 1, kTemperatureFault = 2, kBusVoltageFault = 4, kGateDriverFault = 8,
  kFwdLimitSwitch = 0x10, kRevLimitSwitch = 0x20, kFwdSoftLimit = 0x40, kRevSoftLimit = 0x80
}
 
enum  Limits { kForwardLimit = 1, kReverseLimit = 2 }
 
enum  NeutralMode { kNeutralMode_Jumper = 0, kNeutralMode_Brake = 1, kNeutralMode_Coast = 2 }
 
enum  LimitMode { kLimitMode_SwitchInputsOnly = 0, kLimitMode_SoftPositionLimits = 1, kLimitMode_SrxDisableSwitchInputs = 2 }
 

Public Member Functions

 CANTalon (int deviceNumber)
 Constructor for the CANTalon device. More...
 
 CANTalon (int deviceNumber, int controlPeriodMs)
 Constructor for the CANTalon device. More...
 
 DEFAULT_MOVE_CONSTRUCTOR (CANTalon)
 
virtual void PIDWrite (float output) override
 Write out the PID value as seen in the PIDOutput base object. More...
 
virtual double PIDGet () override
 Retrieve the current sensor value. More...
 
virtual void SetExpiration (float timeout) override
 
virtual float GetExpiration () const override
 
virtual bool IsAlive () const override
 
virtual void StopMotor () override
 Common interface for stopping the motor until the next Set() call Part of the MotorSafety interface. More...
 
virtual void SetSafetyEnabled (bool enabled) override
 
virtual bool IsSafetyEnabled () const override
 
virtual void GetDescription (std::ostringstream &desc) const override
 
virtual float Get () const override
 Gets the current status of the Talon (usually a sensor value). More...
 
virtual void Set (float value, uint8_t syncGroup=0) override
 Sets the appropriate output on the talon, depending on the mode. More...
 
virtual void Reset () override
 Resets the integral term and disables the controller.
 
virtual void SetSetpoint (float value) override
 Sets the setpoint to value. More...
 
virtual void Disable () override
 Disables control of the talon, causing the motor to brake or coast depending on its mode (see the Talon SRX Software Reference manual for more information).
 
virtual void EnableControl ()
 Enables control of the Talon, allowing the motor to move.
 
virtual void Enable () override
 Enables control of the Talon, allowing the motor to move.
 
virtual void SetP (double p) override
 
virtual void SetI (double i) override
 Set the integration constant of the currently selected profile. More...
 
virtual void SetD (double d) override
 Set the derivative constant of the currently selected profile. More...
 
void SetF (double f)
 Set the feedforward value of the currently selected profile. More...
 
void SetIzone (unsigned iz)
 Set the Izone to a nonzero value to auto clear the integral accumulator when the absolute value of CloseLoopError exceeds Izone. More...
 
virtual void SetPID (double p, double i, double d) override
 Sets control values for closed loop control. More...
 
virtual void SetPID (double p, double i, double d, double f)
 Sets control values for closed loop control. More...
 
virtual double GetP () const override
 Get the current proportional constant. More...
 
virtual double GetI () const override
 TODO documentation (see CANJaguar.cpp) More...
 
virtual double GetD () const override
 TODO documentation (see CANJaguar.cpp) More...
 
virtual double GetF () const
 
virtual bool IsModePID (CANSpeedController::ControlMode mode) const override
 
virtual float GetBusVoltage () const override
 Returns the voltage coming in from the battery. More...
 
virtual float GetOutputVoltage () const override
 
virtual float GetOutputCurrent () const override
 Returns the current going through the Talon, in Amperes.
 
virtual float GetTemperature () const override
 Returns temperature of Talon, in degrees Celsius.
 
void SetPosition (double pos)
 Set the position value of the selected sensor. More...
 
virtual double GetPosition () const override
 TODO documentation (see CANJaguar.cpp) More...
 
virtual double GetSpeed () const override
 TODO documentation (see CANJaguar.cpp) More...
 
virtual int GetClosedLoopError () const
 Returns the current error in the controller. More...
 
virtual void SetAllowableClosedLoopErr (uint32_t allowableCloseLoopError)
 Set the allowable closed loop error. More...
 
virtual int GetAnalogIn () const
 Get the position of whatever is in the analog pin of the Talon, regardless of whether it is actually being used for feedback. More...
 
virtual void SetAnalogPosition (int newPosition)
 
virtual int GetAnalogInRaw () const
 Get the position of whatever is in the analog pin of the Talon, regardless of whether it is actually being used for feedback. More...
 
virtual int GetAnalogInVel () const
 Get the position of whatever is in the analog pin of the Talon, regardless of whether it is actually being used for feedback. More...
 
virtual int GetEncPosition () const
 Get the position of whatever is in the analog pin of the Talon, regardless of whether it is actually being used for feedback. More...
 
virtual void SetEncPosition (int)
 
virtual int GetEncVel () const
 Get the position of whatever is in the analog pin of the Talon, regardless of whether it is actually being used for feedback. More...
 
int GetPinStateQuadA () const
 
int GetPinStateQuadB () const
 
int GetPinStateQuadIdx () const
 
int IsFwdLimitSwitchClosed () const
 
int IsRevLimitSwitchClosed () const
 
int GetNumberOfQuadIdxRises () const
 
void SetNumberOfQuadIdxRises (int rises)
 
virtual int GetPulseWidthPosition () const
 
virtual void SetPulseWidthPosition (int newpos)
 
virtual int GetPulseWidthVelocity () const
 
virtual int GetPulseWidthRiseToFallUs () const
 
virtual int GetPulseWidthRiseToRiseUs () const
 
virtual FeedbackDeviceStatus IsSensorPresent (FeedbackDevice feedbackDevice) const
 
virtual bool GetForwardLimitOK () const override
 TODO documentation (see CANJaguar.cpp)
 
virtual bool GetReverseLimitOK () const override
 TODO documentation (see CANJaguar.cpp)
 
virtual uint16_t GetFaults () const override
 TODO documentation (see CANJaguar.cpp)
 
uint16_t GetStickyFaults () const
 
void ClearStickyFaults ()
 
virtual void SetVoltageRampRate (double rampRate) override
 Set the maximum voltage change rate. More...
 
virtual void SetVoltageCompensationRampRate (double rampRate)
 
virtual uint32_t GetFirmwareVersion () const override
 
virtual void ConfigNeutralMode (NeutralMode mode) override
 TODO documentation (see CANJaguar.cpp)
 
virtual void ConfigEncoderCodesPerRev (uint16_t codesPerRev) override
 Configure how many codes per revolution are generated by your encoder. More...
 
virtual void ConfigPotentiometerTurns (uint16_t turns) override
 Configure the number of turns on the potentiometer. More...
 
virtual void ConfigSoftPositionLimits (double forwardLimitPosition, double reverseLimitPosition) override
 
virtual void DisableSoftPositionLimits () override
 TODO documentation (see CANJaguar.cpp)
 
virtual void ConfigLimitMode (LimitMode mode) override
 Configures the soft limit enable (wear leveled persistent memory). More...
 
virtual void ConfigForwardLimit (double forwardLimitPosition) override
 TODO documentation (see CANJaguar.cpp)
 
virtual void ConfigReverseLimit (double reverseLimitPosition) override
 TODO documentation (see CANJaguar.cpp)
 
void ConfigLimitSwitchOverrides (bool bForwardLimitSwitchEn, bool bReverseLimitSwitchEn)
 Overrides the forward and reverse limit switch enables. More...
 
void ConfigForwardSoftLimitEnable (bool bForwardSoftLimitEn)
 Set the Forward Soft Limit Enable. More...
 
void ConfigReverseSoftLimitEnable (bool bReverseSoftLimitEn)
 Set the Reverse Soft Limit Enable. More...
 
void ConfigFwdLimitSwitchNormallyOpen (bool normallyOpen)
 Change the fwd limit switch setting to normally open or closed. More...
 
void ConfigRevLimitSwitchNormallyOpen (bool normallyOpen)
 Change the rev limit switch setting to normally open or closed. More...
 
virtual void ConfigMaxOutputVoltage (double voltage) override
 TODO documentation (see CANJaguar.cpp)
 
void ConfigPeakOutputVoltage (double forwardVoltage, double reverseVoltage)
 
void ConfigNominalOutputVoltage (double forwardVoltage, double reverseVoltage)
 
void EnableZeroSensorPositionOnIndex (bool enable, bool risingEdge)
 Enables Talon SRX to automatically zero the Sensor Position whenever an edge is detected on the index signal. More...
 
void ConfigSetParameter (uint32_t paramEnum, double value)
 General set frame. More...
 
bool GetParameter (uint32_t paramEnum, double &dvalue) const
 General get frame. More...
 
virtual void ConfigFaultTime (float faultTime) override
 TODO documentation (see CANJaguar.cpp)
 
virtual void SetControlMode (ControlMode mode)
 TODO documentation (see CANJaguar.cpp)
 
void SetFeedbackDevice (FeedbackDevice device)
 Select the feedback device to use in closed-loop.
 
void SetStatusFrameRateMs (StatusFrameRate stateFrame, int periodMs)
 Select the feedback device to use in closed-loop.
 
virtual ControlMode GetControlMode () const
 TODO documentation (see CANJaguar.cpp)
 
void SetSensorDirection (bool reverseSensor)
 If sensor and motor are out of phase, sensor can be inverted (position and velocity multiplied by -1). More...
 
void SetClosedLoopOutputDirection (bool reverseOutput)
 Flips the sign (multiplies by negative one) the throttle values going into the motor on the talon in closed loop modes. More...
 
void SetCloseLoopRampRate (double rampRate)
 Sets a voltage change rate that applies only when a close loop contorl mode is enabled. More...
 
void SelectProfileSlot (int slotIdx)
 SRX has two available slots for PID. More...
 
int GetIzone () const
 
int GetIaccum () const
 
void ClearIaccum ()
 Clear the accumulator for I gain.
 
int GetBrakeEnableDuringNeutral () const
 
bool IsControlEnabled () const
 
bool IsEnabled () const override
 
double GetSetpoint () const override
 
void ChangeMotionControlFramePeriod (int periodMs)
 Calling application can opt to speed up the handshaking between the robot API and the Talon to increase the download rate of the Talon's Motion Profile. More...
 
void ClearMotionProfileTrajectories ()
 Clear the buffered motion profile in both Talon RAM (bottom), and in the API (top). More...
 
int GetMotionProfileTopLevelBufferCount ()
 Retrieve just the buffer count for the api-level (top) buffer. More...
 
bool PushMotionProfileTrajectory (const TrajectoryPoint &trajPt)
 Push another trajectory point into the top level buffer (which is emptied into the Talon's bottom buffer as room allows). More...
 
bool IsMotionProfileTopLevelBufferFull ()
 
void ProcessMotionProfileBuffer ()
 This must be called periodically to funnel the trajectory points from the API's top level buffer to the Talon's bottom level buffer. More...
 
void GetMotionProfileStatus (MotionProfileStatus &motionProfileStatus)
 Retrieve all status information. More...
 
void ClearMotionProfileHasUnderrun ()
 Clear the hasUnderrun flag in Talon's Motion Profile Executer when MPE is ready for another point, but the low level buffer is empty. More...
 
void ValueChanged (ITable *source, llvm::StringRef key, std::shared_ptr< nt::Value > value, bool isNew) override
 Called when a key-value pair is changed in a ITable. More...
 
void UpdateTable () override
 Update the table for this sendable object with the latest values.
 
void StartLiveWindowMode () override
 Start having this sendable object automatically respond to value changes reflect the value on the table.
 
void StopLiveWindowMode () override
 Stop having this sendable object automatically respond to value changes.
 
std::string GetSmartDashboardType () const override
 
void InitTable (std::shared_ptr< ITable > subTable) override
 Initializes a table for this sendable object. More...
 
std::shared_ptr< ITableGetTable () const override
 
virtual void SetInverted (bool isInverted) override
 Common interface for inverting direction of a speed controller. More...
 
virtual bool GetInverted () const override
 Common interface for the inverting direction of a speed controller. More...
 
- Public Member Functions inherited from ErrorBase
 ErrorBase (const ErrorBase &)=delete
 
ErrorBaseoperator= (const ErrorBase &)=delete
 
virtual ErrorGetError ()
 Retrieve the current error. More...
 
virtual const ErrorGetError () const
 
virtual void SetErrnoError (llvm::StringRef contextMessage, llvm::StringRef filename, llvm::StringRef function, uint32_t lineNumber) const
 Set error information associated with a C library call that set an error to the "errno" global variable. More...
 
virtual void SetImaqError (int success, llvm::StringRef contextMessage, llvm::StringRef filename, llvm::StringRef function, uint32_t lineNumber) const
 Set the current error information associated from the nivision Imaq API. More...
 
virtual void SetError (Error::Code code, llvm::StringRef contextMessage, llvm::StringRef filename, llvm::StringRef function, uint32_t lineNumber) const
 Set the current error information associated with this sensor. More...
 
virtual void SetWPIError (llvm::StringRef errorMessage, Error::Code code, llvm::StringRef contextMessage, llvm::StringRef filename, llvm::StringRef function, uint32_t lineNumber) const
 Set the current error information associated with this sensor. More...
 
virtual void CloneError (const ErrorBase &rhs) const
 
virtual void ClearError () const
 Clear the current error information associated with this sensor.
 
virtual bool StatusIsFatal () const
 Check if the current error code represents a fatal error. More...
 
- Public Member Functions inherited from ITableListener
virtual void ValueChangedEx (ITable *source, llvm::StringRef key, std::shared_ptr< nt::Value > value, unsigned int flags)
 Extended version of ValueChanged. More...
 
- Public Member Functions inherited from PIDSource
virtual void SetPIDSourceType (PIDSourceType pidSource)
 Set which parameter you are using as a process control variable. More...
 
PIDSourceType GetPIDSourceType () const
 

Additional Inherited Members

- Static Public Member Functions inherited from ErrorBase
static void SetGlobalError (Error::Code code, llvm::StringRef contextMessage, llvm::StringRef filename, llvm::StringRef function, uint32_t lineNumber)
 
static void SetGlobalWPIError (llvm::StringRef errorMessage, llvm::StringRef contextMessage, llvm::StringRef filename, llvm::StringRef function, uint32_t lineNumber)
 
static ErrorGetGlobalError ()
 Retrieve the current global error.
 
- Protected Attributes inherited from ErrorBase
Error m_error
 
- Protected Attributes inherited from PIDSource
PIDSourceType m_pidSource = PIDSourceType::kDisplacement
 
- Static Protected Attributes inherited from ErrorBase
static priority_mutex _globalErrorMutex
 
static Error _globalError
 

Detailed Description

CTRE Talon SRX Speed Controller with CAN Control.

Member Enumeration Documentation

Enumerator
CtreMagEncoder_Relative 

Cross The Road Electronics Magnetic Encoder in Absolute/PulseWidth Mode.

CtreMagEncoder_Absolute 

Cross The Road Electronics Magnetic Encoder in Relative/Quadrature Mode.

Depending on the sensor type, Talon can determine if sensor is plugged in ot not.

Enumerator
FeedbackStatusUnknown 

Sensor status could not be determined. Not all sensors can do this.

FeedbackStatusPresent 

Sensor is present and working okay.

FeedbackStatusNotPresent 

Sensor is not present, not plugged in, not powered, etc...

Enumerated types for Motion Control Set Values.

When in Motion Profile control mode, these constants are paseed into set() to manipulate the motion profile executer. When changing modes, be sure to read the value back using getMotionProfileStatus() to ensure changes in output take effect before performing buffering actions. Disable will signal Talon to put motor output into neutral drive. Talon will stop processing motion profile points. This means the buffer is effectively disconnected from the executer, allowing the robot to gracefully clear and push new traj points. isUnderrun will get cleared. The active trajectory is also cleared. Enable will signal Talon to pop a trajectory point from it's buffer and process it. If the active trajectory is empty, Talon will shift in the next point. If the active traj is empty, and so is the buffer, the motor drive is neutral and isUnderrun is set. When active traj times out, and buffer has at least one point, Talon shifts in next one, and isUnderrun is cleared. When active traj times out, and buffer is empty, Talon keeps processing active traj and sets IsUnderrun. Hold will signal Talon keep processing the active trajectory indefinitely. If the active traj is cleared, Talon will neutral motor drive. Otherwise Talon will keep processing the active traj but it will not shift in points from the buffer. This means the buffer is effectively disconnected from the executer, allowing the robot to gracefully clear and push new traj points. isUnderrun is set if active traj is empty, otherwise it is cleared. isLast signal is also cleared.

Typical workflow: set(Disable), Confirm Disable takes effect, clear buffer and push buffer points, set(Enable) when enough points have been pushed to ensure no underruns, wait for MP to finish or decide abort, If MP finished gracefully set(Hold) to hold position servo and disconnect buffer, If MP is being aborted set(Disable) to neutral the motor and disconnect buffer, Confirm mode takes effect, clear buffer and push buffer points, and rinse-repeat.

Constructor & Destructor Documentation

CANTalon::CANTalon ( int  deviceNumber)
explicit

Constructor for the CANTalon device.

Parameters
deviceNumberThe CAN ID of the Talon SRX
CANTalon::CANTalon ( int  deviceNumber,
int  controlPeriodMs 
)
explicit

Constructor for the CANTalon device.

Parameters
deviceNumberThe CAN ID of the Talon SRX
controlPeriodMsThe period in ms to send the CAN control frame. Period is bounded to [1ms,95ms].

Member Function Documentation

void CANTalon::ChangeMotionControlFramePeriod ( int  periodMs)

Calling application can opt to speed up the handshaking between the robot API and the Talon to increase the download rate of the Talon's Motion Profile.

Ideally the period should be no more than half the period of a trajectory point.

void CANTalon::ClearMotionProfileHasUnderrun ( )

Clear the hasUnderrun flag in Talon's Motion Profile Executer when MPE is ready for another point, but the low level buffer is empty.

Once the Motion Profile Executer sets the hasUnderrun flag, it stays set until Robot Application clears it with this routine, which ensures Robot Application gets a chance to instrument or react. Caller could also check the isUnderrun flag which automatically clears when fault condition is removed.

void CANTalon::ClearMotionProfileTrajectories ( )

Clear the buffered motion profile in both Talon RAM (bottom), and in the API (top).

Be sure to check GetMotionProfileStatus() to know when the buffer is actually cleared.

void CANTalon::ConfigEncoderCodesPerRev ( uint16_t  codesPerRev)
overridevirtual

Configure how many codes per revolution are generated by your encoder.

Parameters
codesPerRevThe number of counts per revolution.

Implements CANSpeedController.

void CANTalon::ConfigForwardSoftLimitEnable ( bool  bForwardSoftLimitEn)

Set the Forward Soft Limit Enable.

This is the same setting that is in the Web-Based Configuration.

Parameters
bForwardSoftLimitEntrue to enable Soft limit, false to disable.
void CANTalon::ConfigFwdLimitSwitchNormallyOpen ( bool  normallyOpen)

Change the fwd limit switch setting to normally open or closed.

Talon will disable momentarilly if the Talon's current setting is dissimilar to the caller's requested setting.

Since Talon saves setting to flash this should only affect a given Talon initially during robot install.

Parameters
normallyOpentrue for normally open. false for normally closed.
void CANTalon::ConfigLimitMode ( LimitMode  mode)
overridevirtual

Configures the soft limit enable (wear leveled persistent memory).

Also sets the limit switch overrides.

Only use switches for limits

Use both switches and soft limits

disable both limit switches and soft limits

Implements CANSpeedController.

void CANTalon::ConfigLimitSwitchOverrides ( bool  bForwardLimitSwitchEn,
bool  bReverseLimitSwitchEn 
)

Overrides the forward and reverse limit switch enables.

Unlike ConfigLimitMode, this function allows individual control of forward and reverse limit switch enables. Unlike ConfigLimitMode, this function does not affect the soft-limit features of Talon SRX.

See Also
ConfigLimitMode()
void CANTalon::ConfigPotentiometerTurns ( uint16_t  turns)
overridevirtual

Configure the number of turns on the potentiometer.

Parameters
turnsThe number of turns of the potentiometer.

Implements CANSpeedController.

void CANTalon::ConfigReverseSoftLimitEnable ( bool  bReverseSoftLimitEn)

Set the Reverse Soft Limit Enable.

This is the same setting that is in the Web-Based Configuration.

Parameters
bReverseSoftLimitEntrue to enable Soft limit, false to disable.
void CANTalon::ConfigRevLimitSwitchNormallyOpen ( bool  normallyOpen)

Change the rev limit switch setting to normally open or closed.

Talon will disable momentarilly if the Talon's current setting is dissimilar to the caller's requested setting.

Since Talon saves setting to flash this should only affect a given Talon initially during robot install.

Parameters
normallyOpentrue for normally open. false for normally closed.
void CANTalon::ConfigSetParameter ( uint32_t  paramEnum,
double  value 
)

General set frame.

Since the parameter is a general integral type, this can be used for testing future features.

void CANTalon::ConfigSoftPositionLimits ( double  forwardLimitPosition,
double  reverseLimitPosition 
)
overridevirtual
Deprecated:
not implemented

Implements CANSpeedController.

void CANTalon::EnableZeroSensorPositionOnIndex ( bool  enable,
bool  risingEdge 
)

Enables Talon SRX to automatically zero the Sensor Position whenever an edge is detected on the index signal.

Parameters
enableboolean input, pass true to enable feature or false to disable.
risingEdgeboolean input, pass true to clear the position on rising edge, pass false to clear the position on falling edge.
float CANTalon::Get ( ) const
overridevirtual

Gets the current status of the Talon (usually a sensor value).

In Current mode: returns output current. In Speed mode: returns current speed. In Position mode: returns current sensor position. In PercentVbus and Follower modes: returns current applied throttle.

Returns
The current sensor value of the Talon.

Implements CANSpeedController.

int CANTalon::GetAnalogIn ( ) const
virtual

Get the position of whatever is in the analog pin of the Talon, regardless of whether it is actually being used for feedback.

Returns
The 24bit analog value. The bottom ten bits is the ADC (0 - 1023) on the analog pin of the Talon. The upper 14 bits tracks the overflows and underflows (continuous sensor).
int CANTalon::GetAnalogInRaw ( ) const
virtual

Get the position of whatever is in the analog pin of the Talon, regardless of whether it is actually being used for feedback.

Returns
The ADC (0 - 1023) on analog pin of the Talon.
int CANTalon::GetAnalogInVel ( ) const
virtual

Get the position of whatever is in the analog pin of the Talon, regardless of whether it is actually being used for feedback.

Returns
The value (0 - 1023) on the analog pin of the Talon.
int CANTalon::GetBrakeEnableDuringNeutral ( ) const
Returns
nonzero if brake is enabled during neutral. Zero if coast is enabled during neutral.
float CANTalon::GetBusVoltage ( ) const
overridevirtual

Returns the voltage coming in from the battery.

Returns
The input voltage in volts.

Implements CANSpeedController.

int CANTalon::GetClosedLoopError ( ) const
virtual

Returns the current error in the controller.

Returns
the difference between the setpoint and the sensor value.
double CANTalon::GetD ( ) const
overridevirtual

TODO documentation (see CANJaguar.cpp)

See Also
SelectProfileSlot to choose between the two sets of gains.

Implements PIDInterface.

int CANTalon::GetEncPosition ( ) const
virtual

Get the position of whatever is in the analog pin of the Talon, regardless of whether it is actually being used for feedback.

Returns
The value (0 - 1023) on the analog pin of the Talon.
int CANTalon::GetEncVel ( ) const
virtual

Get the position of whatever is in the analog pin of the Talon, regardless of whether it is actually being used for feedback.

Returns
The value (0 - 1023) on the analog pin of the Talon.
double CANTalon::GetF ( ) const
virtual
See Also
SelectProfileSlot to choose between the two sets of gains.
uint32_t CANTalon::GetFirmwareVersion ( ) const
overridevirtual
Returns
The version of the firmware running on the Talon

Implements CANSpeedController.

double CANTalon::GetI ( ) const
overridevirtual

TODO documentation (see CANJaguar.cpp)

See Also
SelectProfileSlot to choose between the two sets of gains.

Implements PIDInterface.

int CANTalon::GetIaccum ( ) const
Returns
The accumulator for I gain.
bool CANTalon::GetInverted ( ) const
overridevirtual

Common interface for the inverting direction of a speed controller.

Returns
isInverted The state of inversion, true is inverted.

Implements SpeedController.

int CANTalon::GetIzone ( ) const
See Also
SelectProfileSlot to choose between the two sets of gains.
void CANTalon::GetMotionProfileStatus ( MotionProfileStatus motionProfileStatus)

Retrieve all status information.

Since this all comes from one CAN frame, its ideal to have one routine to retrieve the frame once and decode everything.

Parameters
[out]motionProfileStatuscontains all progress information on the currently running MP.
int CANTalon::GetMotionProfileTopLevelBufferCount ( )

Retrieve just the buffer count for the api-level (top) buffer.

This routine performs no CAN or data structure lookups, so its fast and ideal if caller needs to quickly poll the progress of trajectory points being emptied into Talon's RAM. Otherwise just use GetMotionProfileStatus.

Returns
number of trajectory points in the top buffer.
float CANTalon::GetOutputVoltage ( ) const
overridevirtual
Returns
The voltage being output by the Talon, in Volts.

Implements CANSpeedController.

double CANTalon::GetP ( ) const
overridevirtual

Get the current proportional constant.

Returns
double proportional constant for current profile.
See Also
SelectProfileSlot to choose between the two sets of gains.

Implements PIDInterface.

bool CANTalon::GetParameter ( uint32_t  paramEnum,
double &  dvalue 
) const

General get frame.

Since the parameter is a general integral type, this can be used for testing future features.

int CANTalon::GetPinStateQuadA ( ) const
Returns
IO level of QUADA pin.
int CANTalon::GetPinStateQuadB ( ) const
Returns
IO level of QUADB pin.
int CANTalon::GetPinStateQuadIdx ( ) const
Returns
IO level of QUAD Index pin.
double CANTalon::GetPosition ( ) const
overridevirtual

TODO documentation (see CANJaguar.cpp)

Returns
The position of the sensor currently providing feedback. When using analog sensors, 0 units corresponds to 0V, 1023 units corresponds to 3.3V When using an analog encoder (wrapping around 1023 => 0 is possible) the units are still 3.3V per 1023 units. When using quadrature, each unit is a quadrature edge (4X) mode.

Implements CANSpeedController.

double CANTalon::GetSetpoint ( ) const
overridevirtual
Returns
the current setpoint; ie, whatever was last passed to Set().

Implements PIDInterface.

std::string CANTalon::GetSmartDashboardType ( ) const
overridevirtual
Returns
the string representation of the named data type that will be used by the smart dashboard for this sendable

Implements Sendable.

double CANTalon::GetSpeed ( ) const
overridevirtual

TODO documentation (see CANJaguar.cpp)

Returns
The speed of the sensor currently providing feedback.

The speed units will be in the sensor's native ticks per 100ms.

For analog sensors, 3.3V corresponds to 1023 units. So a speed of 200 equates to ~0.645 dV per 100ms or 6.451 dV per second. If this is an analog encoder, that likely means 1.9548 rotations per sec. For quadrature encoders, each unit corresponds a quadrature edge (4X). So a 250 count encoder will produce 1000 edge events per rotation. An example speed of 200 would then equate to 20% of a rotation per 100ms, or 10 rotations per second.

Implements CANSpeedController.

std::shared_ptr< ITable > CANTalon::GetTable ( ) const
overridevirtual
Returns
the table that is currently associated with the sendable

Implements Sendable.

void CANTalon::InitTable ( std::shared_ptr< ITable subtable)
overridevirtual

Initializes a table for this sendable object.

Parameters
subtableThe table to put the values in.

Implements Sendable.

bool CANTalon::IsControlEnabled ( ) const
Returns
Whether the Talon is currently enabled.
bool CANTalon::IsEnabled ( ) const
overridevirtual
Returns
Whether the Talon is currently enabled.

Implements PIDInterface.

int CANTalon::IsFwdLimitSwitchClosed ( ) const
Returns
'1' iff forward limit switch is closed, 0 iff switch is open. This function works regardless if limit switch feature is enabled.
bool CANTalon::IsMotionProfileTopLevelBufferFull ( )
Returns
true if api-level (top) buffer is full.
int CANTalon::IsRevLimitSwitchClosed ( ) const
Returns
'1' iff reverse limit switch is closed, 0 iff switch is open. This function works regardless if limit switch feature is enabled.
CANTalon::FeedbackDeviceStatus CANTalon::IsSensorPresent ( FeedbackDevice  feedbackDevice) const
virtual
Parameters
whichfeedback sensor to check it if is connected.
Returns
status of caller's specified sensor type.
double CANTalon::PIDGet ( )
overridevirtual

Retrieve the current sensor value.

Equivalent to Get().

Returns
The current sensor value of the Talon.

Implements PIDSource.

void CANTalon::PIDWrite ( float  output)
overridevirtual

Write out the PID value as seen in the PIDOutput base object.

Deprecated:
Call Set instead.
Parameters
outputWrite out the PercentVbus value as was computed by the PIDController

Implements PIDOutput.

void CANTalon::ProcessMotionProfileBuffer ( )

This must be called periodically to funnel the trajectory points from the API's top level buffer to the Talon's bottom level buffer.

Recommendation is to call this twice as fast as the executation rate of the motion profile. So if MP is running with 20ms trajectory points, try calling this routine every 10ms. All motion profile functions are thread-safe through the use of a mutex, so there is no harm in having the caller utilize threading.

bool CANTalon::PushMotionProfileTrajectory ( const TrajectoryPoint trajPt)

Push another trajectory point into the top level buffer (which is emptied into the Talon's bottom buffer as room allows).

Parameters
trajPtthe trajectory point to insert into buffer.
Returns
true if trajectory point push ok. CTR_BufferFull if buffer is full due to kMotionProfileTopBufferCapacity.
void CANTalon::SelectProfileSlot ( int  slotIdx)

SRX has two available slots for PID.

Parameters
slotIdxone or zero depending on which slot caller wants.
void CANTalon::Set ( float  value,
uint8_t  syncGroup = 0 
)
overridevirtual

Sets the appropriate output on the talon, depending on the mode.

In PercentVbus, the output is between -1.0 and 1.0, with 0.0 as stopped. In Voltage mode, output value is in volts. In Current mode, output value is in amperes. In Speed mode, output value is in position change / 10ms. In Position mode, output value is in encoder ticks or an analog value, depending on the sensor. In Follower mode, the output value is the integer device ID of the talon to duplicate.

Parameters
outputValueThe setpoint value, as described above.
See Also
SelectProfileSlot to choose between the two sets of gains.

Implements CANSpeedController.

void CANTalon::SetAllowableClosedLoopErr ( uint32_t  allowableCloseLoopError)
virtual

Set the allowable closed loop error.

Parameters
allowableCloseLoopErrorallowable closed loop error for selected profile. mA for Curent closed loop. Talon Native Units for position and velocity.
void CANTalon::SetClosedLoopOutputDirection ( bool  reverseOutput)

Flips the sign (multiplies by negative one) the throttle values going into the motor on the talon in closed loop modes.

Typically the application should use SetSensorDirection to keep sensor and motor in phase.

See Also
SetSensorDirection However this routine is helpful for reversing the motor direction when Talon is in slave mode, or when using a single-direction position sensor in a closed-loop mode.
Parameters
reverseOutputTrue if motor output should be flipped; False if not.
void CANTalon::SetCloseLoopRampRate ( double  rampRate)

Sets a voltage change rate that applies only when a close loop contorl mode is enabled.

This allows close loop specific ramp behavior.

Parameters
rampRateThe maximum rate of voltage change in Percent Voltage mode in V/s.
void CANTalon::SetD ( double  d)
overridevirtual

Set the derivative constant of the currently selected profile.

Parameters
dDerivative constant for the currently selected PID profile.
See Also
SelectProfileSlot to choose between the two sets of gains.

Implements CANSpeedController.

void CANTalon::SetF ( double  f)

Set the feedforward value of the currently selected profile.

Parameters
fFeedforward constant for the currently selected PID profile.
See Also
SelectProfileSlot to choose between the two sets of gains.
void CANTalon::SetI ( double  i)
overridevirtual

Set the integration constant of the currently selected profile.

Parameters
iIntegration constant for the currently selected PID profile.
See Also
SelectProfileSlot to choose between the two sets of gains.

Implements CANSpeedController.

void CANTalon::SetInverted ( bool  isInverted)
overridevirtual

Common interface for inverting direction of a speed controller.

Only works in PercentVbus, speed, and Voltage modes.

Parameters
isInvertedThe state of inversion, true is inverted.

Implements SpeedController.

void CANTalon::SetIzone ( unsigned  iz)

Set the Izone to a nonzero value to auto clear the integral accumulator when the absolute value of CloseLoopError exceeds Izone.

See Also
SelectProfileSlot to choose between the two sets of gains.
void CANTalon::SetP ( double  p)
overridevirtual
Parameters
pProportional constant to use in PID loop.
See Also
SelectProfileSlot to choose between the two sets of gains.

Implements CANSpeedController.

void CANTalon::SetPID ( double  p,
double  i,
double  d 
)
overridevirtual

Sets control values for closed loop control.

Parameters
pProportional constant.
iIntegration constant.
dDifferential constant. This function does not modify F-gain. Considerable passing a zero for f using the four-parameter function.

Implements PIDInterface.

void CANTalon::SetPID ( double  p,
double  i,
double  d,
double  f 
)
virtual

Sets control values for closed loop control.

Parameters
pProportional constant.
iIntegration constant.
dDifferential constant.
fFeedforward constant.
void CANTalon::SetPosition ( double  pos)

Set the position value of the selected sensor.

This is useful for zero-ing quadrature encoders. Continuous sensors (like analog encoderes) can also partially be set (the portion of the postion based on overflows).

void CANTalon::SetSensorDirection ( bool  reverseSensor)

If sensor and motor are out of phase, sensor can be inverted (position and velocity multiplied by -1).

See Also
GetPosition and
GetSpeed.
void CANTalon::SetSetpoint ( float  value)
overridevirtual

Sets the setpoint to value.

Equivalent to Set().

Implements PIDInterface.

void CANTalon::SetVoltageRampRate ( double  rampRate)
overridevirtual

Set the maximum voltage change rate.

This ramp rate is in affect regardless of which control mode the TALON is in.

When in PercentVbus or Voltage output mode, the rate at which the voltage changes can be limited to reduce current spikes. Set this to 0.0 to disable rate limiting.

Parameters
rampRateThe maximum rate of voltage change in Percent Voltage mode in V/s.

Implements CANSpeedController.

void CANTalon::StopMotor ( )
overridevirtual

Common interface for stopping the motor until the next Set() call Part of the MotorSafety interface.

Deprecated:
Call Disable instead.

Implements CANSpeedController.

void CANTalon::ValueChanged ( ITable source,
llvm::StringRef  key,
std::shared_ptr< nt::Value value,
bool  isNew 
)
overridevirtual

Called when a key-value pair is changed in a ITable.

Parameters
sourcethe table the key-value pair exists in
keythe key associated with the value that changed
valuethe new value
isNewtrue if the key did not previously exist in the table, otherwise it is false

Implements ITableListener.


The documentation for this class was generated from the following files: