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

Luminary Micro / Vex Robotics Jaguar Speed Control. More...

#include <CANJaguar.h>

Inheritance diagram for CANJaguar:
MotorSafety CANSpeedController ErrorBase LiveWindowSendable ITableListener SpeedController Sendable PIDOutput

Classes

struct  EncoderStruct
 Sets an encoder as the speed reference only.
 
struct  PotentiometerStruct
 Sets a potentiometer as the position reference only.
 
struct  QuadEncoderStruct
 Sets a quadrature encoder as the position and speed reference.
 

Public Member Functions

 CANJaguar (uint8_t deviceNumber)
 Constructor for the CANJaguar device. More...
 
uint8_t getDeviceNumber () const
 
uint8_t GetHardwareVersion () const
 Get the version of the Jaguar hardware. More...
 
virtual void PIDWrite (float output) override
 Write out the PID value as seen in the PIDOutput base object. More...
 
void EnableControl (double encoderInitialPosition=0.0)
 Enable the closed loop controller. More...
 
void DisableControl ()
 Disable the closed loop controller. More...
 
void SetPercentMode ()
 Enable controlling the motor voltage as a percentage of the bus voltage without any position or speed feedback. More...
 
void SetPercentMode (EncoderStruct, uint16_t codesPerRev)
 Enable controlling the motor voltage as a percentage of the bus voltage, and enable speed sensing from a non-quadrature encoder. More...
 
void SetPercentMode (QuadEncoderStruct, uint16_t codesPerRev)
 Enable controlling the motor voltage as a percentage of the bus voltage, and enable speed sensing from a non-quadrature encoder. More...
 
void SetPercentMode (PotentiometerStruct)
 Enable controlling the motor voltage as a percentage of the bus voltage, and enable position sensing from a potentiometer and no speed feedback. More...
 
void SetCurrentMode (double p, double i, double d)
 Enable controlling the motor current with a PID loop. More...
 
void SetCurrentMode (EncoderStruct, uint16_t codesPerRev, double p, double i, double d)
 Enable controlling the motor current with a PID loop, and enable speed sensing from a non-quadrature encoder. More...
 
void SetCurrentMode (QuadEncoderStruct, uint16_t codesPerRev, double p, double i, double d)
 Enable controlling the motor current with a PID loop, and enable speed and position sensing from a quadrature encoder. More...
 
void SetCurrentMode (PotentiometerStruct, double p, double i, double d)
 Enable controlling the motor current with a PID loop, and enable position sensing from a potentiometer. More...
 
void SetSpeedMode (EncoderStruct, uint16_t codesPerRev, double p, double i, double d)
 Enable controlling the speed with a feedback loop from a non-quadrature encoder. More...
 
void SetSpeedMode (QuadEncoderStruct, uint16_t codesPerRev, double p, double i, double d)
 Enable controlling the speed with a feedback loop from a quadrature encoder. More...
 
void SetPositionMode (QuadEncoderStruct, uint16_t codesPerRev, double p, double i, double d)
 Enable controlling the position with a feedback loop using an encoder. More...
 
void SetPositionMode (PotentiometerStruct, double p, double i, double d)
 Enable controlling the position with a feedback loop using a potentiometer. More...
 
void SetVoltageMode ()
 Enable controlling the motor voltage without any position or speed feedback. More...
 
void SetVoltageMode (EncoderStruct, uint16_t codesPerRev)
 Enable controlling the motor voltage with speed feedback from a non-quadrature encoder and no position feedback. More...
 
void SetVoltageMode (QuadEncoderStruct, uint16_t codesPerRev)
 Enable controlling the motor voltage with position and speed feedback from a quadrature encoder. More...
 
void SetVoltageMode (PotentiometerStruct)
 Enable controlling the motor voltage with position feedback from a potentiometer and no speed feedback. More...
 
virtual float Get () const override
 Get the recently set outputValue setpoint. More...
 
virtual void Set (float value, uint8_t syncGroup=0) override
 Sets the output set-point value. More...
 
virtual void Disable () override
 Common interface for disabling a motor. More...
 
virtual void SetP (double p) override
 Set the P constant for the closed loop modes. More...
 
virtual void SetI (double i) override
 Set the I constant for the closed loop modes. More...
 
virtual void SetD (double d) override
 Set the D constant for the closed loop modes. More...
 
virtual void SetPID (double p, double i, double d) override
 Set the P, I, and D constants for the closed loop modes. More...
 
virtual double GetP () const override
 Get the Proportional gain of the controller. More...
 
virtual double GetI () const override
 Get the Intregral gain of the controller. More...
 
virtual double GetD () const override
 Get the Differential gain of the controller. More...
 
virtual bool IsModePID (CANSpeedController::ControlMode mode) const override
 
virtual float GetBusVoltage () const override
 Get the voltage at the battery input terminals of the Jaguar. More...
 
virtual float GetOutputVoltage () const override
 Get the voltage being output from the motor terminals of the Jaguar. More...
 
virtual float GetOutputCurrent () const override
 Get the current through the motor terminals of the Jaguar. More...
 
virtual float GetTemperature () const override
 Get the internal temperature of the Jaguar. More...
 
virtual double GetPosition () const override
 Get the position of the encoder or potentiometer. More...
 
virtual double GetSpeed () const override
 Get the speed of the encoder. More...
 
virtual bool GetForwardLimitOK () const override
 Get the status of the forward limit switch. More...
 
virtual bool GetReverseLimitOK () const override
 Get the status of the reverse limit switch. More...
 
virtual uint16_t GetFaults () const override
 Get the status of any faults the Jaguar has detected. More...
 
virtual void SetVoltageRampRate (double rampRate) override
 Set the maximum voltage change rate. More...
 
virtual uint32_t GetFirmwareVersion () const override
 Get the version of the firmware running on the Jaguar. More...
 
virtual void ConfigNeutralMode (NeutralMode mode) override
 Configure what the controller does to the H-Bridge when neutral (not driving the output). More...
 
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
 Configure Soft Position Limits when in Position Controller mode. More...
 
virtual void DisableSoftPositionLimits () override
 Disable Soft Position Limits if previously enabled. More...
 
virtual void ConfigLimitMode (LimitMode mode) override
 Set the limit mode for position control mode. More...
 
virtual void ConfigForwardLimit (double forwardLimitPosition) override
 Set the position that if exceeded will disable the forward direction. More...
 
virtual void ConfigReverseLimit (double reverseLimitPosition) override
 Set the position that if exceeded will disable the reverse direction. More...
 
virtual void ConfigMaxOutputVoltage (double voltage) override
 Configure the maximum voltage that the Jaguar will ever output. More...
 
virtual void ConfigFaultTime (float faultTime) override
 Configure how long the Jaguar waits in the case of a fault before resuming operation. More...
 
virtual void SetControlMode (ControlMode mode)
 Used internally. More...
 
virtual ControlMode GetControlMode () const
 Get the active control mode from the Jaguar. More...
 
void SetExpiration (float timeout) override
 
float GetExpiration () const override
 
bool IsAlive () const override
 
void StopMotor () override
 Common interface for stopping the motor until the next Set() command Part of the MotorSafety interface. More...
 
bool IsSafetyEnabled () const override
 
void SetSafetyEnabled (bool enabled) override
 
void GetDescription (std::ostringstream &desc) const override
 
uint8_t GetDeviceID () const
 
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 CANSpeedController
virtual void ConfigNeutralMode (NeutralMode mode)=0
 
- 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...
 

Static Public Member Functions

static void UpdateSyncGroup (uint8_t syncGroup)
 Update all the motors that have pending sets in the syncGroup. More...
 
- 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.
 

Static Public Attributes

static const int32_t kControllerRate = 1000
 
static constexpr double kApproxBusVoltage = 12.0
 
static const struct
CANJaguar::EncoderStruct 
Encoder
 
static const struct
CANJaguar::QuadEncoderStruct 
QuadEncoder
 
static const struct
CANJaguar::PotentiometerStruct 
Potentiometer
 

Protected Member Functions

void SetSpeedReference (uint8_t reference)
 Set the reference source device for speed controller mode. More...
 
uint8_t GetSpeedReference () const
 Get the reference source device for speed controller mode. More...
 
void SetPositionReference (uint8_t reference)
 Set the reference source device for position controller mode. More...
 
uint8_t GetPositionReference () const
 Get the reference source device for position controller mode. More...
 
uint8_t packPercentage (uint8_t *buffer, double value)
 
uint8_t packFXP8_8 (uint8_t *buffer, double value)
 
uint8_t packFXP16_16 (uint8_t *buffer, double value)
 
uint8_t packint16_t (uint8_t *buffer, int16_t value)
 
uint8_t packint32_t (uint8_t *buffer, int32_t value)
 
double unpackPercentage (uint8_t *buffer) const
 
double unpackFXP8_8 (uint8_t *buffer) const
 
double unpackFXP16_16 (uint8_t *buffer) const
 
int16_t unpackint16_t (uint8_t *buffer) const
 
int32_t unpackint32_t (uint8_t *buffer) const
 
void sendMessage (uint32_t messageID, const uint8_t *data, uint8_t dataSize, int32_t period=CAN_SEND_PERIOD_NO_REPEAT)
 Send a message to the Jaguar. More...
 
void requestMessage (uint32_t messageID, int32_t period=CAN_SEND_PERIOD_NO_REPEAT)
 Request a message from the Jaguar, but don't wait for it to arrive. More...
 
bool getMessage (uint32_t messageID, uint32_t mask, uint8_t *data, uint8_t *dataSize) const
 Get a previously requested message. More...
 
void setupPeriodicStatus ()
 Enables periodic status updates from the Jaguar.
 
void updatePeriodicStatus () const
 Check for new periodic status updates and unpack them into local variables.
 
void verify ()
 Check all unverified params and make sure they're equal to their local cached versions. 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
 

Protected Attributes

priority_recursive_mutex m_mutex
 
uint8_t m_deviceNumber
 
float m_value = 0.0f
 
ControlMode m_controlMode = kPercentVbus
 
uint8_t m_speedReference = LM_REF_NONE
 
uint8_t m_positionReference = LM_REF_NONE
 
double m_p = 0.0
 
double m_i = 0.0
 
double m_d = 0.0
 
NeutralMode m_neutralMode = kNeutralMode_Jumper
 
uint16_t m_encoderCodesPerRev = 0
 
uint16_t m_potentiometerTurns = 0
 
LimitMode m_limitMode = kLimitMode_SwitchInputsOnly
 
double m_forwardLimit = 0.0
 
double m_reverseLimit = 0.0
 
double m_maxOutputVoltage = 30.0
 
double m_voltageRampRate = 0.0
 
float m_faultTime = 0.0f
 
bool m_controlModeVerified = false
 
bool m_speedRefVerified = true
 
bool m_posRefVerified = true
 
bool m_pVerified = true
 
bool m_iVerified = true
 
bool m_dVerified = true
 
bool m_neutralModeVerified = true
 
bool m_encoderCodesPerRevVerified = true
 
bool m_potentiometerTurnsVerified = true
 
bool m_forwardLimitVerified = true
 
bool m_reverseLimitVerified = true
 
bool m_limitModeVerified = true
 
bool m_maxOutputVoltageVerified = true
 
bool m_voltageRampRateVerified = true
 
bool m_faultTimeVerified = true
 
float m_busVoltage = 0.0f
 
float m_outputVoltage = 0.0f
 
float m_outputCurrent = 0.0f
 
float m_temperature = 0.0f
 
double m_position = 0.0
 
double m_speed = 0.0
 
uint8_t m_limits = 0x00
 
uint16_t m_faults = 0x0000
 
uint32_t m_firmwareVersion = 0
 
uint8_t m_hardwareVersion = 0
 
std::atomic< bool > m_receivedStatusMessage0 {false}
 
std::atomic< bool > m_receivedStatusMessage1 {false}
 
std::atomic< bool > m_receivedStatusMessage2 {false}
 
bool m_controlEnabled = false
 
bool m_stopped = false
 
std::unique_ptr
< MotorSafetyHelper
m_safetyHelper
 
std::shared_ptr< ITablem_table
 
- Protected Attributes inherited from ErrorBase
Error m_error
 

Additional Inherited Members

- 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 }
 
- Static Protected Attributes inherited from ErrorBase
static priority_mutex _globalErrorMutex
 
static Error _globalError
 

Detailed Description

Luminary Micro / Vex Robotics Jaguar Speed Control.

Constructor & Destructor Documentation

CANJaguar::CANJaguar ( uint8_t  deviceNumber)
explicit

Constructor for the CANJaguar device.


By default the device is configured in Percent mode. The control mode can be changed by calling one of the control modes listed below.

Parameters
deviceNumberThe address of the Jaguar on the CAN bus.
See Also
CANJaguar::SetCurrentMode(double, double, double)
CANJaguar::SetCurrentMode(PotentiometerTag, double, double, double)
CANJaguar::SetCurrentMode(EncoderTag, int, double, double, double)
CANJaguar::SetCurrentMode(QuadEncoderTag, int, double, double, double)
CANJaguar::SetPercentMode()
CANJaguar::SetPercentMode(PotentiometerTag)
CANJaguar::SetPercentMode(EncoderTag, int)
CANJaguar::SetPercentMode(QuadEncoderTag, int)
CANJaguar::SetPositionMode(PotentiometerTag, double, double, double)
CANJaguar::SetPositionMode(QuadEncoderTag, int, double, double, double)
CANJaguar::SetSpeedMode(EncoderTag, int, double, double, double)
CANJaguar::SetSpeedMode(QuadEncoderTag, int, double, double, double)
CANJaguar::SetVoltageMode()
CANJaguar::SetVoltageMode(PotentiometerTag)
CANJaguar::SetVoltageMode(EncoderTag, int)
CANJaguar::SetVoltageMode(QuadEncoderTag, int)

Member Function Documentation

void CANJaguar::ConfigEncoderCodesPerRev ( uint16_t  codesPerRev)
overridevirtual

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

Parameters
codesPerRevThe number of counts per revolution in 1X mode.

Implements CANSpeedController.

void CANJaguar::ConfigFaultTime ( float  faultTime)
overridevirtual

Configure how long the Jaguar waits in the case of a fault before resuming operation.

Faults include over temerature, over current, and bus under voltage. The default is 3.0 seconds, but can be reduced to as low as 0.5 seconds.

Parameters
faultTimeThe time to wait before resuming operation, in seconds.

Implements CANSpeedController.

void CANJaguar::ConfigForwardLimit ( double  forwardLimitPosition)
overridevirtual

Set the position that if exceeded will disable the forward direction.

Use ConfigSoftPositionLimits to set this and the limit mode automatically.

Implements CANSpeedController.

void CANJaguar::ConfigLimitMode ( LimitMode  mode)
overridevirtual

Set the limit mode for position control mode.

Use ConfigSoftPositionLimits or DisableSoftPositionLimits to set this automatically.

Implements CANSpeedController.

void CANJaguar::ConfigMaxOutputVoltage ( double  voltage)
overridevirtual

Configure the maximum voltage that the Jaguar will ever output.

This can be used to limit the maximum output voltage in all modes so that motors which cannot withstand full bus voltage can be used safely.

Parameters
voltageThe maximum voltage output by the Jaguar.

Implements CANSpeedController.

void CANJaguar::ConfigNeutralMode ( NeutralMode  mode)
overridevirtual

Configure what the controller does to the H-Bridge when neutral (not driving the output).

This allows you to override the jumper configuration for brake or coast.

Parameters
modeSelect to use the jumper setting or to override it to coast or brake.
void CANJaguar::ConfigPotentiometerTurns ( uint16_t  turns)
overridevirtual

Configure the number of turns on the potentiometer.

There is no special support for continuous turn potentiometers. Only integer numbers of turns are supported.

Parameters
turnsThe number of turns of the potentiometer.

Implements CANSpeedController.

void CANJaguar::ConfigReverseLimit ( double  reverseLimitPosition)
overridevirtual

Set the position that if exceeded will disable the reverse direction.

Use ConfigSoftPositionLimits to set this and the limit mode automatically.

Implements CANSpeedController.

void CANJaguar::ConfigSoftPositionLimits ( double  forwardLimitPosition,
double  reverseLimitPosition 
)
overridevirtual

Configure Soft Position Limits when in Position Controller mode.

When controlling position, you can add additional limits on top of the limit switch inputs that are based on the position feedback. If the position limit is reached or the switch is opened, that direction will be disabled.

Parameters
forwardLimitPositionThe position that if exceeded will disable the forward direction.
reverseLimitPositionThe position that if exceeded will disable the reverse direction.

Implements CANSpeedController.

void CANJaguar::Disable ( )
overridevirtual

Common interface for disabling a motor.

Deprecated:
Call DisableControl() instead.

Implements CANSpeedController.

void CANJaguar::DisableControl ( )

Disable the closed loop controller.

Stop driving the output based on the feedback.

void CANJaguar::DisableSoftPositionLimits ( )
overridevirtual

Disable Soft Position Limits if previously enabled.

Soft Position Limits are disabled by default.

Implements CANSpeedController.

void CANJaguar::EnableControl ( double  encoderInitialPosition = 0.0)

Enable the closed loop controller.

Start actually controlling the output based on the feedback. If starting a position controller with an encoder reference, use the encoderInitialPosition parameter to initialize the encoder state.

Parameters
encoderInitialPositionEncoder position to set if position with encoder reference. Ignored otherwise.
float CANJaguar::Get ( ) const
overridevirtual

Get the recently set outputValue setpoint.

The scale and the units depend on the mode the Jaguar is in.
In percentVbus Mode, the outputValue is from -1.0 to 1.0 (same as PWM Jaguar).
In voltage Mode, the outputValue is in volts.
In current Mode, the outputValue is in amps.
In speed Mode, the outputValue is in rotations/minute.
In position Mode, the outputValue is in rotations.

Returns
The most recently set outputValue setpoint.

Implements CANSpeedController.

float CANJaguar::GetBusVoltage ( ) const
overridevirtual

Get the voltage at the battery input terminals of the Jaguar.

Returns
The bus voltage in volts.

Implements CANSpeedController.

CANJaguar::ControlMode CANJaguar::GetControlMode ( ) const
virtual

Get the active control mode from the Jaguar.

Ask the Jag what mode it is in.

Returns
ControlMode that the Jag is in.
double CANJaguar::GetD ( ) const
overridevirtual

Get the Differential gain of the controller.

Returns
The differential gain.

Implements CANSpeedController.

uint8_t CANJaguar::getDeviceNumber ( ) const
Returns
The CAN ID passed in the constructor
uint16_t CANJaguar::GetFaults ( ) const
overridevirtual

Get the status of any faults the Jaguar has detected.

Returns
A bit-mask of faults defined by the "Faults" enum.
See Also
#kCurrentFault
#kBusVoltageFault
#kTemperatureFault
#kGateDriverFault

Implements CANSpeedController.

uint32_t CANJaguar::GetFirmwareVersion ( ) const
overridevirtual

Get the version of the firmware running on the Jaguar.

Returns
The firmware version. 0 if the device did not respond.

Implements CANSpeedController.

bool CANJaguar::GetForwardLimitOK ( ) const
overridevirtual

Get the status of the forward limit switch.

Returns
The motor is allowed to turn in the forward direction when true.

Implements CANSpeedController.

uint8_t CANJaguar::GetHardwareVersion ( ) const

Get the version of the Jaguar hardware.

Returns
The hardware version. 1: Jaguar, 2: Black Jaguar
double CANJaguar::GetI ( ) const
overridevirtual

Get the Intregral gain of the controller.

Returns
The integral gain.

Implements CANSpeedController.

bool CANJaguar::GetInverted ( ) const
overridevirtual

Common interface for the inverting direction of a speed controller.

Returns
isInverted The state of inversion, true is inverted.

Implements SpeedController.

bool CANJaguar::getMessage ( uint32_t  messageID,
uint32_t  messageMask,
uint8_t *  data,
uint8_t *  dataSize 
) const
protected

Get a previously requested message.

Jaguar always generates a message with the same message ID when replying.

Parameters
messageIDThe messageID to read from the CAN bus (device number is added internally)
dataThe up to 8 bytes of data that was received with the message
dataSizeIndicates how much data was received
Returns
true if the message was found. Otherwise, no new message is available.
float CANJaguar::GetOutputCurrent ( ) const
overridevirtual

Get the current through the motor terminals of the Jaguar.

Returns
The output current in amps.

Implements CANSpeedController.

float CANJaguar::GetOutputVoltage ( ) const
overridevirtual

Get the voltage being output from the motor terminals of the Jaguar.

Returns
The output voltage in volts.

Implements CANSpeedController.

double CANJaguar::GetP ( ) const
overridevirtual

Get the Proportional gain of the controller.

Returns
The proportional gain.

Implements CANSpeedController.

double CANJaguar::GetPosition ( ) const
overridevirtual

Get the position of the encoder or potentiometer.

Returns
The position of the motor in rotations based on the configured feedback.
See Also
CANJaguar::ConfigPotentiometerTurns(int)
CANJaguar::ConfigEncoderCodesPerRev(int)

Implements CANSpeedController.

uint8_t CANJaguar::GetPositionReference ( ) const
protected

Get the reference source device for position controller mode.

Returns
A PositionReference indicating the currently selected reference device for position controller mode.
bool CANJaguar::GetReverseLimitOK ( ) const
overridevirtual

Get the status of the reverse limit switch.

Returns
The motor is allowed to turn in the reverse direction when true.

Implements CANSpeedController.

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

Implements Sendable.

double CANJaguar::GetSpeed ( ) const
overridevirtual

Get the speed of the encoder.

Returns
The speed of the motor in RPM based on the configured feedback.

Implements CANSpeedController.

uint8_t CANJaguar::GetSpeedReference ( ) const
protected

Get the reference source device for speed controller mode.

Returns
A speed reference indicating the currently selected reference device for speed controller mode.
std::shared_ptr< ITable > CANJaguar::GetTable ( ) const
overrideprotectedvirtual
Returns
the table that is currently associated with the sendable

Implements Sendable.

float CANJaguar::GetTemperature ( ) const
overridevirtual

Get the internal temperature of the Jaguar.

Returns
The temperature of the Jaguar in degrees Celsius.

Implements CANSpeedController.

void CANJaguar::InitTable ( std::shared_ptr< ITable subtable)
overrideprotectedvirtual

Initializes a table for this sendable object.

Parameters
subtableThe table to put the values in.

Implements Sendable.

void CANJaguar::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 CANJaguar::requestMessage ( uint32_t  messageID,
int32_t  period = CAN_SEND_PERIOD_NO_REPEAT 
)
protected

Request a message from the Jaguar, but don't wait for it to arrive.

Parameters
messageIDThe message to request
periodicIf positive, tell Network Communications to send the message every "period" milliseconds.
void CANJaguar::sendMessage ( uint32_t  messageID,
const uint8_t *  data,
uint8_t  dataSize,
int32_t  period = CAN_SEND_PERIOD_NO_REPEAT 
)
protected

Send a message to the Jaguar.

Parameters
messageIDThe messageID to be used on the CAN bus (device number is added internally)
dataThe up to 8 bytes of data to be sent with the message
dataSizeSpecify how much of the data in "data" to send
periodicIf positive, tell Network Communications to send the message every "period" milliseconds.
void CANJaguar::Set ( float  outputValue,
uint8_t  syncGroup = 0 
)
overridevirtual

Sets the output set-point value.

The scale and the units depend on the mode the Jaguar is in.
In percentVbus Mode, the outputValue is from -1.0 to 1.0 (same as PWM Jaguar).
In voltage Mode, the outputValue is in volts.
In current Mode, the outputValue is in amps.
In speed Mode, the outputValue is in rotations/minute.
In position Mode, the outputValue is in rotations.

Parameters
outputValueThe set-point to sent to the motor controller.
syncGroupThe update group to add this Set() to, pending UpdateSyncGroup(). If 0, update immediately.

Implements CANSpeedController.

void CANJaguar::SetControlMode ( ControlMode  controlMode)
virtual

Used internally.

In order to set the control mode see the methods listed below. Change the control mode of this Jaguar object.

After changing modes, configure any PID constants or other settings needed and then EnableControl() to actually change the mode on the Jaguar.

Parameters
controlModeThe new mode.
void CANJaguar::SetCurrentMode ( double  p,
double  i,
double  d 
)

Enable controlling the motor current with a PID loop.


After calling this you must call CANJaguar#EnableControl() or CANJaguar#EnableControl(double) to enable the device.

Parameters
pThe proportional gain of the Jaguar's PID controller.
iThe integral gain of the Jaguar's PID controller.
dThe differential gain of the Jaguar's PID controller.
void CANJaguar::SetCurrentMode ( CANJaguar::EncoderStruct  ,
uint16_t  codesPerRev,
double  p,
double  i,
double  d 
)

Enable controlling the motor current with a PID loop, and enable speed sensing from a non-quadrature encoder.


After calling this you must call CANJaguar#EnableControl() or CANJaguar#EnableControl(double) to enable the device.

Parameters
encoderThe constant CANJaguar::Encoder
pThe proportional gain of the Jaguar's PID controller.
iThe integral gain of the Jaguar's PID controller.
dThe differential gain of the Jaguar's PID controller.
void CANJaguar::SetCurrentMode ( CANJaguar::QuadEncoderStruct  ,
uint16_t  codesPerRev,
double  p,
double  i,
double  d 
)

Enable controlling the motor current with a PID loop, and enable speed and position sensing from a quadrature encoder.


After calling this you must call CANJaguar#EnableControl() or CANJaguar#EnableControl(double) to enable the device.

Parameters
endoerThe constant CANJaguar::QuadEncoder
pThe proportional gain of the Jaguar's PID controller.
iThe integral gain of the Jaguar's PID controller.
dThe differential gain of the Jaguar's PID controller.
void CANJaguar::SetCurrentMode ( CANJaguar::PotentiometerStruct  ,
double  p,
double  i,
double  d 
)

Enable controlling the motor current with a PID loop, and enable position sensing from a potentiometer.


After calling this you must call CANJaguar#EnableControl() or CANJaguar#EnableControl(double) to enable the device.

Parameters
potentiometerThe constant CANJaguar::Potentiometer
pThe proportional gain of the Jaguar's PID controller.
iThe integral gain of the Jaguar's PID controller.
dThe differential gain of the Jaguar's PID controller.
void CANJaguar::SetD ( double  d)
overridevirtual

Set the D constant for the closed loop modes.

Parameters
dThe derivative gain of the Jaguar's PID controller.

Implements CANSpeedController.

void CANJaguar::SetI ( double  i)
overridevirtual

Set the I constant for the closed loop modes.

Parameters
iThe integral gain of the Jaguar's PID controller.

Implements CANSpeedController.

void CANJaguar::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 CANJaguar::SetP ( double  p)
overridevirtual

Set the P constant for the closed loop modes.

Parameters
pThe proportional gain of the Jaguar's PID controller.

Implements CANSpeedController.

void CANJaguar::SetPercentMode ( )

Enable controlling the motor voltage as a percentage of the bus voltage without any position or speed feedback.


After calling this you must call CANJaguar#EnableControl() or CANJaguar#EnableControl(double) to enable the device.

void CANJaguar::SetPercentMode ( CANJaguar::EncoderStruct  ,
uint16_t  codesPerRev 
)

Enable controlling the motor voltage as a percentage of the bus voltage, and enable speed sensing from a non-quadrature encoder.


After calling this you must call CANJaguar#EnableControl() or CANJaguar#EnableControl(double) to enable the device.

Parameters
tagThe constant CANJaguar::Encoder
codesPerRevThe counts per revolution on the encoder
void CANJaguar::SetPercentMode ( CANJaguar::QuadEncoderStruct  ,
uint16_t  codesPerRev 
)

Enable controlling the motor voltage as a percentage of the bus voltage, and enable speed sensing from a non-quadrature encoder.


After calling this you must call CANJaguar#EnableControl() or CANJaguar#EnableControl(double) to enable the device.

Parameters
tagThe constant CANJaguar::QuadEncoder
codesPerRevThe counts per revolution on the encoder
void CANJaguar::SetPercentMode ( CANJaguar::PotentiometerStruct  )

Enable controlling the motor voltage as a percentage of the bus voltage, and enable position sensing from a potentiometer and no speed feedback.


After calling this you must call CANJaguar#EnableControl() or CANJaguar#EnableControl(double) to enable the device.

Parameters
potentiometerThe constant CANJaguar::Potentiometer
void CANJaguar::SetPID ( double  p,
double  i,
double  d 
)
overridevirtual

Set the P, I, and D constants for the closed loop modes.

Parameters
pThe proportional gain of the Jaguar's PID controller.
iThe integral gain of the Jaguar's PID controller.
dThe differential gain of the Jaguar's PID controller.

Implements CANSpeedController.

void CANJaguar::SetPositionMode ( CANJaguar::QuadEncoderStruct  ,
uint16_t  codesPerRev,
double  p,
double  i,
double  d 
)

Enable controlling the position with a feedback loop using an encoder.


After calling this you must call CANJaguar#EnableControl() or CANJaguar#EnableControl(double) to enable the device.

Parameters
encoderThe constant CANJaguar::QuadEncoder
codesPerRevThe counts per revolution on the encoder.
pThe proportional gain of the Jaguar's PID controller.
iThe integral gain of the Jaguar's PID controller.
dThe differential gain of the Jaguar's PID controller.
void CANJaguar::SetPositionMode ( CANJaguar::PotentiometerStruct  ,
double  p,
double  i,
double  d 
)

Enable controlling the position with a feedback loop using a potentiometer.


After calling this you must call CANJaguar#EnableControl() or CANJaguar#EnableControl(double) to enable the device.

Parameters
pThe proportional gain of the Jaguar's PID controller.
iThe integral gain of the Jaguar's PID controller.
dThe differential gain of the Jaguar's PID controller.
void CANJaguar::SetPositionReference ( uint8_t  reference)
protected

Set the reference source device for position controller mode.

Choose between using and encoder and using a potentiometer as the source of position feedback when in position control mode.

Parameters
referenceSpecify a PositionReference.
void CANJaguar::SetSpeedMode ( CANJaguar::EncoderStruct  ,
uint16_t  codesPerRev,
double  p,
double  i,
double  d 
)

Enable controlling the speed with a feedback loop from a non-quadrature encoder.


After calling this you must call CANJaguar#EnableControl() or CANJaguar#EnableControl(double) to enable the device.

Parameters
encoderThe constant CANJaguar::Encoder
codesPerRevThe counts per revolution on the encoder.
pThe proportional gain of the Jaguar's PID controller.
iThe integral gain of the Jaguar's PID controller.
dThe differential gain of the Jaguar's PID controller.
void CANJaguar::SetSpeedMode ( CANJaguar::QuadEncoderStruct  ,
uint16_t  codesPerRev,
double  p,
double  i,
double  d 
)

Enable controlling the speed with a feedback loop from a quadrature encoder.


After calling this you must call CANJaguar#EnableControl() or CANJaguar#EnableControl(double) to enable the device.

Parameters
encoderThe constant CANJaguar::QuadEncoder
codesPerRevThe counts per revolution on the encoder.
pThe proportional gain of the Jaguar's PID controller.
iThe integral gain of the Jaguar's PID controller.
dThe differential gain of the Jaguar's PID controller.
void CANJaguar::SetSpeedReference ( uint8_t  reference)
protected

Set the reference source device for speed controller mode.

Choose encoder as the source of speed feedback when in speed control mode.

Parameters
referenceSpecify a speed reference.
void CANJaguar::SetVoltageMode ( )

Enable controlling the motor voltage without any position or speed feedback.


After calling this you must call CANJaguar#EnableControl() or CANJaguar#EnableControl(double) to enable the device.

void CANJaguar::SetVoltageMode ( CANJaguar::EncoderStruct  ,
uint16_t  codesPerRev 
)

Enable controlling the motor voltage with speed feedback from a non-quadrature encoder and no position feedback.


After calling this you must call CANJaguar#EnableControl() or CANJaguar#EnableControl(double) to enable the device.

Parameters
encoderThe constant CANJaguar::Encoder
codesPerRevThe counts per revolution on the encoder
void CANJaguar::SetVoltageMode ( CANJaguar::QuadEncoderStruct  ,
uint16_t  codesPerRev 
)

Enable controlling the motor voltage with position and speed feedback from a quadrature encoder.


After calling this you must call CANJaguar#EnableControl() or CANJaguar#EnableControl(double) to enable the device.

Parameters
encoderThe constant CANJaguar::QuadEncoder
codesPerRevThe counts per revolution on the encoder
void CANJaguar::SetVoltageMode ( CANJaguar::PotentiometerStruct  )

Enable controlling the motor voltage with position feedback from a potentiometer and no speed feedback.


After calling this you must call CANJaguar#EnableControl() or CANJaguar#EnableControl(double) to enable the device.

Parameters
potentiometerThe constant CANJaguar::Potentiometer
void CANJaguar::SetVoltageRampRate ( double  rampRate)
overridevirtual

Set the maximum voltage change rate.

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 CANJaguar::StopMotor ( )
overridevirtual

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

Deprecated:
Call DisableControl instead.

Implements CANSpeedController.

void CANJaguar::UpdateSyncGroup ( uint8_t  syncGroup)
static

Update all the motors that have pending sets in the syncGroup.

Parameters
syncGroupA bitmask of groups to generate synchronous output.
void CANJaguar::ValueChanged ( ITable source,
llvm::StringRef  key,
std::shared_ptr< nt::Value value,
bool  isNew 
)
overrideprotectedvirtual

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.

void CANJaguar::verify ( )
protected

Check all unverified params and make sure they're equal to their local cached versions.

If a value isn't available, it gets requested. If a value doesn't match up, it gets set again.


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