WPILibC++
unspecified
|
CTRE Talon SRX Speed Controller with CAN Control. More...
#include <CANTalon.h>
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... | |
![]() | |
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< ITable > | GetTable () 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... | |
![]() | |
ErrorBase (const ErrorBase &)=delete | |
ErrorBase & | operator= (const ErrorBase &)=delete |
virtual Error & | GetError () |
Retrieve the current error. More... | |
virtual const Error & | GetError () 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... | |
![]() | |
virtual void | ValueChangedEx (ITable *source, llvm::StringRef key, std::shared_ptr< nt::Value > value, unsigned int flags) |
Extended version of ValueChanged. More... | |
![]() | |
virtual void | SetPIDSourceType (PIDSourceType pidSource) |
Set which parameter you are using as a process control variable. More... | |
PIDSourceType | GetPIDSourceType () const |
Additional Inherited Members | |
![]() | |
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 Error & | GetGlobalError () |
Retrieve the current global error. | |
![]() | |
Error | m_error |
![]() | |
PIDSourceType | m_pidSource = PIDSourceType::kDisplacement |
![]() | |
static priority_mutex | _globalErrorMutex |
static Error | _globalError |
CTRE Talon SRX Speed Controller with CAN Control.
Depending on the sensor type, Talon can determine if sensor is plugged in ot not.
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.
|
explicit |
|
explicit |
void CANTalon::ChangeMotionControlFramePeriod | ( | int | periodMs | ) |
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.
|
overridevirtual |
Configure how many codes per revolution are generated by your encoder.
codesPerRev | The 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.
bForwardSoftLimitEn | true 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.
normallyOpen | true for normally open. false for normally closed. |
|
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.
|
overridevirtual |
Configure the number of turns on the potentiometer.
turns | The 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.
bReverseSoftLimitEn | true 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.
normallyOpen | true 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.
|
overridevirtual |
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.
enable | boolean input, pass true to enable feature or false to disable. |
risingEdge | boolean input, pass true to clear the position on rising edge, pass false to clear the position on falling edge. |
|
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.
Implements CANSpeedController.
|
virtual |
Get the position of whatever is in the analog pin of the Talon, regardless of whether it is actually being used for feedback.
|
virtual |
|
virtual |
int CANTalon::GetBrakeEnableDuringNeutral | ( | ) | const |
|
overridevirtual |
Returns the voltage coming in from the battery.
Implements CANSpeedController.
|
virtual |
Returns the current error in the controller.
|
overridevirtual |
TODO documentation (see CANJaguar.cpp)
Implements PIDInterface.
|
virtual |
|
virtual |
|
virtual |
|
overridevirtual |
Implements CANSpeedController.
|
overridevirtual |
TODO documentation (see CANJaguar.cpp)
Implements PIDInterface.
int CANTalon::GetIaccum | ( | ) | const |
|
overridevirtual |
Common interface for the inverting direction of a speed controller.
Implements SpeedController.
int CANTalon::GetIzone | ( | ) | const |
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.
[out] | motionProfileStatus | contains 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.
|
overridevirtual |
Implements CANSpeedController.
|
overridevirtual |
Get the current proportional constant.
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 |
int CANTalon::GetPinStateQuadB | ( | ) | const |
int CANTalon::GetPinStateQuadIdx | ( | ) | const |
|
overridevirtual |
TODO documentation (see CANJaguar.cpp)
Implements CANSpeedController.
|
overridevirtual |
Implements PIDInterface.
|
overridevirtual |
Implements Sendable.
|
overridevirtual |
TODO documentation (see CANJaguar.cpp)
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.
|
overridevirtual |
Implements Sendable.
|
overridevirtual |
Initializes a table for this sendable object.
subtable | The table to put the values in. |
Implements Sendable.
bool CANTalon::IsControlEnabled | ( | ) | const |
|
overridevirtual |
Implements PIDInterface.
int CANTalon::IsFwdLimitSwitchClosed | ( | ) | const |
bool CANTalon::IsMotionProfileTopLevelBufferFull | ( | ) |
int CANTalon::IsRevLimitSwitchClosed | ( | ) | const |
|
virtual |
which | feedback sensor to check it if is connected. |
|
overridevirtual |
|
overridevirtual |
Write out the PID value as seen in the PIDOutput base object.
output | Write 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).
trajPt | the trajectory point to insert into buffer. |
void CANTalon::SelectProfileSlot | ( | int | slotIdx | ) |
SRX has two available slots for PID.
slotIdx | one or zero depending on which slot caller wants. |
|
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.
outputValue | The setpoint value, as described above. |
Implements CANSpeedController.
|
virtual |
Set the allowable closed loop error.
allowableCloseLoopError | allowable 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.
reverseOutput | True 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.
rampRate | The maximum rate of voltage change in Percent Voltage mode in V/s. |
|
overridevirtual |
Set the derivative constant of the currently selected profile.
d | Derivative constant for the currently selected PID profile. |
Implements CANSpeedController.
void CANTalon::SetF | ( | double | f | ) |
Set the feedforward value of the currently selected profile.
f | Feedforward constant for the currently selected PID profile. |
|
overridevirtual |
Set the integration constant of the currently selected profile.
i | Integration constant for the currently selected PID profile. |
Implements CANSpeedController.
|
overridevirtual |
Common interface for inverting direction of a speed controller.
Only works in PercentVbus, speed, and Voltage modes.
isInverted | The 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.
|
overridevirtual |
p | Proportional constant to use in PID loop. |
Implements CANSpeedController.
|
overridevirtual |
Sets control values for closed loop control.
p | Proportional constant. |
i | Integration constant. |
d | Differential constant. This function does not modify F-gain. Considerable passing a zero for f using the four-parameter function. |
Implements PIDInterface.
|
virtual |
Sets control values for closed loop control.
p | Proportional constant. |
i | Integration constant. |
d | Differential constant. |
f | Feedforward 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).
|
overridevirtual |
|
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.
rampRate | The maximum rate of voltage change in Percent Voltage mode in V/s. |
Implements CANSpeedController.
|
overridevirtual |
Common interface for stopping the motor until the next Set() call Part of the MotorSafety interface.
Implements CANSpeedController.
|
overridevirtual |
Called when a key-value pair is changed in a ITable.
source | the table the key-value pair exists in |
key | the key associated with the value that changed |
value | the new value |
isNew | true if the key did not previously exist in the table, otherwise it is false |
Implements ITableListener.