public class CANJaguar extends Object implements MotorSafety, PIDOutput, SpeedController, LiveWindowSendable
Modifier and Type | Class and Description |
---|---|
static class |
CANJaguar.ControlMode
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.
|
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_EXPIRATION
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 |
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.ControlMode |
getControlMode()
Get the active control mode from the Jaguar.
|
double |
getD()
Get the Derivative gain of the controller.
|
String |
getDescription() |
int |
getDeviceID() |
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.
|
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.
|
String |
getSmartDashboardType() |
double |
getSpeed()
Get the speed of the encoder.
|
edu.wpi.first.wpilibj.tables.ITable |
getTable() |
double |
getTemperature()
Get the internal temperature of the Jaguar.
|
void |
initTable(edu.wpi.first.wpilibj.tables.ITable subtable)
Initializes a table for this sendable object.
|
boolean |
isAlive() |
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.
|
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 |
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 |
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 |
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.
|
public 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 SpeedController
public void set(double outputValue, byte syncGroup)
set
in interface SpeedController
outputValue
- 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 SpeedController
value
- The set-point to sent to the motor controller.protected void verify()
@Deprecated public void disable()
disableControl()
instead.disable
in interface SpeedController
public void pidWrite(double output)
PIDOutput
public void setP(double p)
p
- The proportional gain of the Jaguar's PID controller.public void setI(double i)
i
- The integral gain of the Jaguar's PID controller.public void setD(double d)
d
- The derivative gain of the Jaguar's PID controller.public void setPID(double p, double i, double d)
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 double getP()
public double getI()
public double getD()
public 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.0
public 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 kEncoder
codesPerRev
- 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 kQuadEncoder
codesPerRev
- 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 kPotentiometer
public 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 kEncoder
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.QuadEncoderTag tag, int codesPerRev, double p, double i, double d)
enableControl()
or enableControl(double)
to enable the device.tag
- The constant kQuadEncoder
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.PotentiometerTag tag, double p, double i, double d)
enableControl()
or enableControl(double)
to enable the device.tag
- The constant kPotentiometer
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 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 kEncoder
codesPerRev
- 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 kQuadEncoder
codesPerRev
- 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 kQuadEncoder
codesPerRev
- 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 kPotentiometer
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 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 kEncoder
codesPerRev
- 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 kQuadEncoder
codesPerRev
- The counts per revolution on the encoderpublic void setVoltageMode(edu.wpi.first.wpilibj.CANJaguar.PotentiometerTag tag)
tag
- The constant kPotentiometer
public CANJaguar.ControlMode getControlMode()
public double getBusVoltage()
public double getOutputVoltage()
public double getOutputCurrent()
public double getTemperature()
public double getPosition()
configPotentiometerTurns(int)
,
configEncoderCodesPerRev(int)
public double getSpeed()
public boolean getForwardLimitOK()
public boolean getReverseLimitOK()
public short getFaults()
kCurrentFault
,
kBusVoltageFault
,
kTemperatureFault
,
kGateDriverFault
public void setVoltageRampRate(double rampRate)
rampRate
- 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.SoftPositionLimits
public 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 MotorSafety
public double getExpiration()
getExpiration
in interface MotorSafety
public boolean isAlive()
isAlive
in interface MotorSafety
public boolean isSafetyEnabled()
isSafetyEnabled
in interface MotorSafety
public void setSafetyEnabled(boolean enabled)
setSafetyEnabled
in interface MotorSafety
public String getDescription()
getDescription
in interface MotorSafety
public int getDeviceID()
@Deprecated public void stopMotor()
stopMotor
in interface MotorSafety
public String getSmartDashboardType()
getSmartDashboardType
in interface Sendable
public void initTable(edu.wpi.first.wpilibj.tables.ITable subtable)
public void updateTable()
updateTable
in interface LiveWindowSendable
public edu.wpi.first.wpilibj.tables.ITable getTable()
public void startLiveWindowMode()
startLiveWindowMode
in interface LiveWindowSendable
public void stopLiveWindowMode()
stopLiveWindowMode
in interface LiveWindowSendable
Copyright © 2015. All rights reserved.