public class CANJaguar extends java.lang.Object implements MotorSafety, PIDOutput, CANSpeedController
| Modifier and Type | Class and Description |
|---|---|
static class |
CANJaguar.JaguarControlMode
Mode determines how the Jaguar is controlled, used internally.
|
static class |
CANJaguar.LimitMode
Determines which sensor to use for position reference.
|
static class |
CANJaguar.NeutralMode
Determines how the Jaguar behaves when sending a zero signal.
|
CANSpeedController.ControlMode| Modifier and Type | Field and Description |
|---|---|
static double |
kApproxBusVoltage |
static int |
kBusVoltageFault |
static int |
kControllerRate |
static int |
kCurrentFault |
static edu.wpi.first.wpilibj.CANJaguar.EncoderTag |
kEncoder
Sets an encoder as the speed reference only.
|
static int |
kForwardLimit
Limit switch masks
|
static int |
kGateDriverFault |
static int |
kMaxMessageDataSize |
static edu.wpi.first.wpilibj.CANJaguar.PotentiometerTag |
kPotentiometer
Sets a potentiometer as the position reference only.
|
static edu.wpi.first.wpilibj.CANJaguar.QuadEncoderTag |
kQuadEncoder
Sets a quadrature encoder as the position and speed reference.
|
static int |
kReverseLimit |
static int |
kTemperatureFault |
DEFAULT_SAFETY_EXPIRATIONSMART_DASHBOARD_TYPE| Constructor and Description |
|---|
CANJaguar(int deviceNumber)
Constructor for the CANJaguar device.
By default the device is configured in Percent mode. |
| Modifier and Type | Method and Description |
|---|---|
void |
configEncoderCodesPerRev(int codesPerRev)
Configure how many codes per revolution are generated by your encoder.
|
void |
configFaultTime(float faultTime)
Configure how long the Jaguar waits in the case of a fault before resuming
operation.
|
void |
configForwardLimit(double forwardLimitPosition)
Set the position that, if exceeded, will disable the forward direction.
|
void |
configLimitMode(CANJaguar.LimitMode mode)
Set the limit mode for position control mode.
Use configSoftPositionLimits(double, double) or
disableSoftPositionLimits() to set this automatically. |
void |
configMaxOutputVoltage(double voltage)
Configure the maximum voltage that the Jaguar will ever output.
|
void |
configNeutralMode(CANJaguar.NeutralMode mode)
Configure what the controller does to the H-Bridge when neutral (not
driving the output).
|
void |
configPotentiometerTurns(int turns)
Configure the number of turns on the potentiometer.
|
void |
configReverseLimit(double reverseLimitPosition)
Set the position that, if exceeded, will disable the reverse direction.
|
void |
configSoftPositionLimits(double forwardLimitPosition,
double reverseLimitPosition)
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. |
void |
disable()
Deprecated.
Call
disableControl() instead. |
void |
disableControl()
Disable the closed loop controller.
|
void |
disableSoftPositionLimits()
Disable Soft Position Limits if previously enabled.
Soft Position Limits are disabled by default. |
void |
enable()
Allows the control loop to run.
|
void |
enableControl()
Enable the closed loop controller.
|
void |
enableControl(double encoderInitialPosition)
Enable the closed loop controller.
|
void |
free()
Cancel periodic messages to the Jaguar, effectively disabling it.
|
boolean |
FXP16_EQ(double a,
double b) |
boolean |
FXP8_EQ(double a,
double b) |
double |
get()
Get the recently set outputValue set point.
|
double |
getBusVoltage()
Get the voltage at the battery input terminals of the Jaguar.
|
CANJaguar.JaguarControlMode |
getControlMode()
Get the active control mode from the Jaguar.
|
double |
getD()
Get the Derivative gain of the controller.
|
java.lang.String |
getDescription() |
int |
getDeviceID() |
double |
getError()
Get the difference between the setpoint and goal in closed loop modes.
|
double |
getExpiration() |
short |
getFaults()
Get the status of any faults the Jaguar has detected.
|
int |
getFirmwareVersion()
Get the version of the firmware running on the Jaguar.
|
boolean |
getForwardLimitOK()
Get the status of the forward limit switch.
|
byte |
getHardwareVersion()
Get the version of the Jaguar hardware.
|
double |
getI()
Get the Integral gain of the controller.
|
boolean |
getInverted()
Common interface for the inverting direction of a speed controller.
|
protected void |
getMessage(int messageID,
int messageMask,
byte[] data)
Get a previously requested message.
|
double |
getOutputCurrent()
Get the current through the motor terminals of the Jaguar.
|
double |
getOutputVoltage()
Get the voltage being output from the motor terminals of the Jaguar.
|
double |
getP()
Get the Proportional gain of the controller.
|
double |
getPosition()
Get the position of the encoder or potentiometer.
|
boolean |
getReverseLimitOK()
Get the status of the reverse limit switch.
|
double |
getSetpoint()
Equivalent to
get(). |
double |
getSpeed()
Get the speed of the encoder.
|
ITable |
getTable() |
double |
getTemperature()
Get the internal temperature of the Jaguar.
|
void |
initTable(ITable subtable)
Initializes a table for this sendable object.
|
boolean |
isAlive() |
boolean |
isEnabled()
Return whether the controller is enabled.
|
boolean |
isSafetyEnabled() |
void |
pidWrite(double output)
Set the output to the value calculated by PIDController
$
|
protected void |
requestMessage(int messageID)
Request a message from the Jaguar, but don't wait for it to arrive.
|
protected void |
requestMessage(int messageID,
int period)
Request a message from the Jaguar, but don't wait for it to arrive.
|
void |
reset() |
protected void |
sendMessage(int messageID,
byte[] data,
int dataSize)
Send a message to the Jaguar, non-periodically
|
protected void |
sendMessage(int messageID,
byte[] data,
int dataSize,
int period)
Send a message to the Jaguar.
|
void |
set(double value)
Sets the output set-point value.
|
void |
set(double outputValue,
byte syncGroup)
Sets the output set-point value.
|
void |
setControlMode(int mode)
Sets the control mode of this speed controller.
|
void |
setCurrentMode(edu.wpi.first.wpilibj.CANJaguar.EncoderTag tag,
int 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 enableControl() or
enableControl(double) to enable the device. |
void |
setCurrentMode(edu.wpi.first.wpilibj.CANJaguar.PotentiometerTag tag,
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 enableControl() or
enableControl(double) to enable the device. |
void |
setCurrentMode(edu.wpi.first.wpilibj.CANJaguar.QuadEncoderTag tag,
int 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 enableControl() or
enableControl(double) to enable the device. |
void |
setCurrentMode(double p,
double i,
double d)
Enable controlling the motor current with a PID loop.
After calling this you must call enableControl() or
enableControl(double) to enable the device. |
void |
setD(double d)
Set the D constant for the closed loop modes.
|
void |
setExpiration(double timeout) |
void |
setI(double i)
Set the I constant for the closed loop modes.
|
void |
setInverted(boolean isInverted)
Inverts the direction of rotation of the motor Only works in percentVbus,
Speed, and Voltage mode
$
|
void |
setP(double p)
Set the P constant for the closed loop modes.
|
void |
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 enableControl() or
enableControl(double) to enable the device. |
void |
setPercentMode(edu.wpi.first.wpilibj.CANJaguar.EncoderTag tag,
int 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 enableControl() or
enableControl(double) to enable the device. |
void |
setPercentMode(edu.wpi.first.wpilibj.CANJaguar.PotentiometerTag tag)
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 enableControl() or
enableControl(double) to enable the device. |
void |
setPercentMode(edu.wpi.first.wpilibj.CANJaguar.QuadEncoderTag tag,
int codesPerRev)
Enable controlling the motor voltage as a percentage of the bus voltage,
and enable position and speed sensing from a quadrature encoder.
After calling this you must call enableControl() or
enableControl(double) to enable the device. |
void |
setPID(double p,
double i,
double d)
Set the P, I, and D constants for the closed loop modes.
|
void |
setPositionMode(edu.wpi.first.wpilibj.CANJaguar.PotentiometerTag tag,
double p,
double i,
double d)
Enable controlling the position with a feedback loop using a potentiometer.
After calling this you must call enableControl() or
enableControl(double) to enable the device. |
void |
setPositionMode(edu.wpi.first.wpilibj.CANJaguar.QuadEncoderTag tag,
int codesPerRev,
double p,
double i,
double d)
Enable controlling the position with a feedback loop using an encoder.
After calling this you must call enableControl() or
enableControl(double) to enable the device. |
void |
setSafetyEnabled(boolean enabled) |
void |
setSetpoint(double value)
Equivalent to
set(double). |
void |
setSpeedMode(edu.wpi.first.wpilibj.CANJaguar.EncoderTag tag,
int 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 enableControl() or
enableControl(double) to enable the device. |
void |
setSpeedMode(edu.wpi.first.wpilibj.CANJaguar.QuadEncoderTag tag,
int 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 enableControl() or
enableControl(double) to enable the device. |
protected void |
setupPeriodicStatus()
Enables periodic status updates from the Jaguar
|
void |
setVoltageMode()
Enable controlling the motor voltage without any position or speed
feedback.
After calling this you must call enableControl() or
enableControl(double) to enable the device. |
void |
setVoltageMode(edu.wpi.first.wpilibj.CANJaguar.EncoderTag tag,
int codesPerRev)
Enable controlling the motor voltage with speed feedback from a
non-quadrature encoder and no position feedback.
After calling this you must call enableControl() or
enableControl(double) to enable the device. |
void |
setVoltageMode(edu.wpi.first.wpilibj.CANJaguar.PotentiometerTag tag)
Enable controlling the motor voltage with position feedback from a
potentiometer and no speed feedback.
|
void |
setVoltageMode(edu.wpi.first.wpilibj.CANJaguar.QuadEncoderTag tag,
int codesPerRev)
Enable controlling the motor voltage with position and speed feedback from
a quadrature encoder.
After calling this you must call enableControl() or
enableControl(double) to enable the device. |
void |
setVoltageRampRate(double rampRate)
set the maximum voltage change rate.
|
void |
startLiveWindowMode()
Start having this sendable object automatically respond to value changes
reflect the value on the table.
|
void |
stopLiveWindowMode()
Stop having this sendable object automatically respond to value changes.
|
void |
stopMotor()
Deprecated.
Use disableControl instead.
|
protected void |
updatePeriodicStatus()
Check for new periodic status updates and unpack them into local variables.
|
static void |
updateSyncGroup(byte syncGroup)
Update all the motors that have pending sets in the syncGroup.
|
void |
updateTable()
Update the table for this sendable object with the latest values.
|
protected void |
verify()
Check all unverified params and make sure they're equal to their local
cached versions.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcreateTableListener, getF, getSmartDashboardType, setFpublic static final int kMaxMessageDataSize
public static final int kControllerRate
public static final double kApproxBusVoltage
public static final edu.wpi.first.wpilibj.CANJaguar.EncoderTag kEncoder
public static final edu.wpi.first.wpilibj.CANJaguar.QuadEncoderTag kQuadEncoder
public static final edu.wpi.first.wpilibj.CANJaguar.PotentiometerTag kPotentiometer
public static final int kCurrentFault
public static final int kTemperatureFault
public static final int kBusVoltageFault
public static final int kGateDriverFault
public static final int kForwardLimit
public static final int kReverseLimit
public CANJaguar(int deviceNumber)
deviceNumber - The address of the Jaguar on the CAN bus.setCurrentMode(double, double, double),
setCurrentMode(PotentiometerTag, double, double, double),
setCurrentMode(EncoderTag, int, double, double, double),
setCurrentMode(QuadEncoderTag, int, double, double, double),
setPercentMode(),
setPercentMode(PotentiometerTag),
setPercentMode(EncoderTag, int),
setPercentMode(QuadEncoderTag, int),
setPositionMode(PotentiometerTag, double, double, double),
setPositionMode(QuadEncoderTag, int, double, double, double),
setSpeedMode(EncoderTag, int, double, double, double),
setSpeedMode(QuadEncoderTag, int, double, double, double),
setVoltageMode(),
setVoltageMode(PotentiometerTag),
setVoltageMode(EncoderTag, int),
setVoltageMode(QuadEncoderTag, int)public void free()
public double get()
get in interface SpeedControllerpublic double getSetpoint()
get().getSetpoint in interface PIDInterfacepublic double getError()
getError in interface PIDInterfacepublic void set(double outputValue, byte syncGroup)
set in interface SpeedControlleroutputValue - The set-point to sent to the motor controller.syncGroup - The update group to add this set() to, pending
UpdateSyncGroup(). If 0, update immediately.public void set(double value)
set in interface SpeedControllervalue - The set-point to sent to the motor controller.public void setSetpoint(double value)
set(double). Implements PIDInterface.setSetpoint in interface PIDInterfacepublic void reset()
reset in interface PIDInterfacepublic void setInverted(boolean isInverted)
setInverted in interface SpeedControllerisInverted - The state of inversion true is invertedpublic boolean getInverted()
getInverted in interface SpeedControllerprotected void verify()
@Deprecated public void disable()
disableControl() instead.disable in interface PIDInterfacedisable in interface SpeedControllerpublic void enable()
enable in interface PIDInterfacepublic void pidWrite(double output)
PIDOutputpublic void setP(double p)
setP in interface CANSpeedControllerp - The proportional gain of the Jaguar's PID controller.public void setI(double i)
setI in interface CANSpeedControlleri - The integral gain of the Jaguar's PID controller.public void setD(double d)
setD in interface CANSpeedControllerd - The derivative gain of the Jaguar's PID controller.public void setPID(double p, double i, double d)
setPID in interface PIDInterfacep - The proportional gain of the Jaguar's PID controller.i - The integral gain of the Jaguar's PID controller.d - The differential gain of the Jaguar's PID controller.public double getP()
getP in interface PIDInterfacepublic double getI()
getI in interface PIDInterfacepublic double getD()
getD in interface PIDInterfacepublic void enableControl(double encoderInitialPosition)
encoderInitialPosition - Encoder position to set if position with
encoder reference. Ignored otherwise.public void enableControl()
CANJaguar.enableControl(double encoderInitialPosition) with
encoderInitialPosition set to 0.0public boolean isEnabled()
isEnabled in interface PIDInterfacepublic void disableControl()
public void setPercentMode()
enableControl() or
enableControl(double) to enable the device.public void setPercentMode(edu.wpi.first.wpilibj.CANJaguar.EncoderTag tag, int codesPerRev)
enableControl() or
enableControl(double) to enable the device.tag - The constant kEncodercodesPerRev - The counts per revolution on the encoderpublic void setPercentMode(edu.wpi.first.wpilibj.CANJaguar.QuadEncoderTag tag, int codesPerRev)
enableControl() or
enableControl(double) to enable the device.tag - The constant kQuadEncodercodesPerRev - The counts per revolution on the encoderpublic void setPercentMode(edu.wpi.first.wpilibj.CANJaguar.PotentiometerTag tag)
enableControl() or
enableControl(double) to enable the device.tag - The constant kPotentiometerpublic void setCurrentMode(double p, double i, double d)
enableControl() or
enableControl(double) to enable the device.p - The proportional gain of the Jaguar's PID controller.i - The integral gain of the Jaguar's PID controller.d - The differential gain of the Jaguar's PID controller.public void setCurrentMode(edu.wpi.first.wpilibj.CANJaguar.EncoderTag tag, int codesPerRev, double p, double i, double d)
enableControl() or
enableControl(double) to enable the device.tag - The constant kEncoderp - The proportional gain of the Jaguar's PID controller.i - The integral gain of the Jaguar's PID controller.d - The differential gain of the Jaguar's PID controller.public void setCurrentMode(edu.wpi.first.wpilibj.CANJaguar.QuadEncoderTag tag, int codesPerRev, double p, double i, double d)
enableControl() or
enableControl(double) to enable the device.tag - The constant kQuadEncoderp - The proportional gain of the Jaguar's PID controller.i - The integral gain of the Jaguar's PID controller.d - The differential gain of the Jaguar's PID controller.public void setCurrentMode(edu.wpi.first.wpilibj.CANJaguar.PotentiometerTag tag, double p, double i, double d)
enableControl() or
enableControl(double) to enable the device.tag - The constant kPotentiometerp - The proportional gain of the Jaguar's PID controller.i - The integral gain of the Jaguar's PID controller.d - The differential gain of the Jaguar's PID controller.public void setSpeedMode(edu.wpi.first.wpilibj.CANJaguar.EncoderTag tag, int codesPerRev, double p, double i, double d)
enableControl() or
enableControl(double) to enable the device.tag - The constant kEncodercodesPerRev - The counts per revolution on the encoderp - The proportional gain of the Jaguar's PID controller.i - The integral gain of the Jaguar's PID controller.d - The differential gain of the Jaguar's PID controller.public void setSpeedMode(edu.wpi.first.wpilibj.CANJaguar.QuadEncoderTag tag, int codesPerRev, double p, double i, double d)
enableControl() or
enableControl(double) to enable the device.tag - The constant kQuadEncodercodesPerRev - The counts per revolution on the encoderp - The proportional gain of the Jaguar's PID controller.i - The integral gain of the Jaguar's PID controller.d - The differential gain of the Jaguar's PID controller.public void setPositionMode(edu.wpi.first.wpilibj.CANJaguar.QuadEncoderTag tag, int codesPerRev, double p, double i, double d)
enableControl() or
enableControl(double) to enable the device.tag - The constant kQuadEncodercodesPerRev - The counts per revolution on the encoderp - The proportional gain of the Jaguar's PID controller.i - The integral gain of the Jaguar's PID controller.d - The differential gain of the Jaguar's PID controller.public void setPositionMode(edu.wpi.first.wpilibj.CANJaguar.PotentiometerTag tag, double p, double i, double d)
enableControl() or
enableControl(double) to enable the device.tag - The constant kPotentiometerp - The proportional gain of the Jaguar's PID controller.i - The integral gain of the Jaguar's PID controller.d - The differential gain of the Jaguar's PID controller.public void setVoltageMode()
enableControl() or
enableControl(double) to enable the device.public void setVoltageMode(edu.wpi.first.wpilibj.CANJaguar.EncoderTag tag, int codesPerRev)
enableControl() or
enableControl(double) to enable the device.tag - The constant kEncodercodesPerRev - The counts per revolution on the encoderpublic void setVoltageMode(edu.wpi.first.wpilibj.CANJaguar.QuadEncoderTag tag, int codesPerRev)
enableControl() or
enableControl(double) to enable the device.tag - The constant kQuadEncodercodesPerRev - The counts per revolution on the encoderpublic void setVoltageMode(edu.wpi.first.wpilibj.CANJaguar.PotentiometerTag tag)
tag - The constant kPotentiometerpublic CANJaguar.JaguarControlMode getControlMode()
getControlMode in interface CANSpeedControllerpublic void setControlMode(int mode)
CANSpeedControllersetControlMode in interface CANSpeedControllermode - the the new modepublic double getBusVoltage()
getBusVoltage in interface CANSpeedControllerpublic double getOutputVoltage()
getOutputVoltage in interface CANSpeedControllerpublic double getOutputCurrent()
getOutputCurrent in interface CANSpeedControllerpublic double getTemperature()
getTemperature in interface CANSpeedControllerpublic double getPosition()
getPosition in interface CANSpeedControllerconfigPotentiometerTurns(int),
configEncoderCodesPerRev(int)public double getSpeed()
getSpeed in interface CANSpeedControllerpublic boolean getForwardLimitOK()
public boolean getReverseLimitOK()
public short getFaults()
kCurrentFault,
kBusVoltageFault,
kTemperatureFault,
kGateDriverFaultpublic void setVoltageRampRate(double rampRate)
setVoltageRampRate in interface CANSpeedControllerrampRate - The maximum rate of voltage change in Percent Voltage mode
in V/s.public int getFirmwareVersion()
public byte getHardwareVersion()
public void configNeutralMode(CANJaguar.NeutralMode mode)
mode - Select to use the jumper setting or to override it to coast or
brake.public void configEncoderCodesPerRev(int codesPerRev)
codesPerRev - The number of counts per revolution in 1X mode.public void configPotentiometerTurns(int turns)
turns - The number of turns of the potentiometerpublic void configSoftPositionLimits(double forwardLimitPosition, double reverseLimitPosition)
forwardLimitPosition - The position that, if exceeded, will disable
the forward direction.reverseLimitPosition - The position that, if exceeded, will disable
the reverse direction.public void disableSoftPositionLimits()
public void configLimitMode(CANJaguar.LimitMode mode)
configSoftPositionLimits(double, double) or
disableSoftPositionLimits() to set this automatically.
$mode - The CANJaguar.LimitMode to use to limit the rotation of the
device.CANJaguar.LimitMode.SwitchInputsOnly,
CANJaguar.LimitMode.SoftPositionLimitspublic void configForwardLimit(double forwardLimitPosition)
configSoftPositionLimits(double, double) to set this and the
CANJaguar.LimitMode automatically.
$forwardLimitPosition - The position that, if exceeded, will disable
the forward direction.public void configReverseLimit(double reverseLimitPosition)
configSoftPositionLimits(double, double) to set this and the
CANJaguar.LimitMode automatically.
$reverseLimitPosition - The position that, if exceeded, will disable
the reverse direction.public void configMaxOutputVoltage(double voltage)
voltage - The maximum voltage output by the Jaguar.public void configFaultTime(float faultTime)
faultTime - The time to wait before resuming operation, in seconds.protected void sendMessage(int messageID, byte[] data, int dataSize, int period)
messageID - The messageID to be used on the CAN bus (device number is
added internally)data - The up to 8 bytes of data to be sent with the messagedataSize - Specify how much of the data in "data" to sendperiod - If positive, tell Network Communications to send the message
every "period" milliseconds.protected void sendMessage(int messageID, byte[] data, int dataSize)
messageID - The messageID to be used on the CAN bus (device number is
added internally)data - The up to 8 bytes of data to be sent with the messagedataSize - Specify how much of the data in "data" to sendprotected void requestMessage(int messageID, int period)
messageID - The message to requestperiod - If positive, tell Network Communications to request the
message every "period" milliseconds.protected void requestMessage(int messageID)
messageID - The message to requestprotected void getMessage(int messageID, int messageMask, byte[] data) throws CANMessageNotFoundException
messageID - The messageID to read from the CAN bus (device number is
added internally)data - The up to 8 bytes of data that was received with the messageCANMessageNotFoundException - if there's not new message availableprotected void setupPeriodicStatus()
protected void updatePeriodicStatus()
public static void updateSyncGroup(byte syncGroup)
syncGroup - A bitmask of groups to generate synchronous output.public boolean FXP8_EQ(double a, double b)
public boolean FXP16_EQ(double a, double b)
public void setExpiration(double timeout)
setExpiration in interface MotorSafetypublic double getExpiration()
getExpiration in interface MotorSafetypublic boolean isAlive()
isAlive in interface MotorSafetypublic boolean isSafetyEnabled()
isSafetyEnabled in interface MotorSafetypublic void setSafetyEnabled(boolean enabled)
setSafetyEnabled in interface MotorSafetypublic java.lang.String getDescription()
getDescription in interface MotorSafetypublic int getDeviceID()
@Deprecated public void stopMotor()
stopMotor in interface MotorSafetypublic void updateTable()
updateTable in interface CANSpeedControllerupdateTable in interface LiveWindowSendablepublic void startLiveWindowMode()
startLiveWindowMode in interface LiveWindowSendablepublic void stopLiveWindowMode()
stopLiveWindowMode in interface LiveWindowSendable