CANJaguar

class wpilib.CANJaguar(deviceNumber)[source]

Bases: wpilib.LiveWindowSendable, wpilib.MotorSafety

Texas Instruments Jaguar Speed Controller as a CAN device.

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.

Parameters:deviceNumber – The address of the Jaguar on the CAN bus.
class ControlMode[source]

Bases: builtins.object

Determines how the Jaguar is controlled, used internally.

Current = 1
PercentVbus = 0
Position = 3
Speed = 2
Voltage = 4
class CANJaguar.LimitMode[source]

Bases: builtins.object

Determines which sensor to use for position reference. Limit switches will always be used to limit the rotation. This can not be disabled.

SoftPositionLimits = 1

Enables the soft position limits on the Jaguar. These will be used in addition to the limit switches. This does not disable the behavior of the limit switch input. See configSoftPositionLimits.

SwitchInputsOnly = 0

Disables the soft position limits and only uses the limit switches to limit rotation. See getForwardLimitOK and getReverseLimitOK.

class CANJaguar.Mode[source]

Bases: builtins.object

Control Mode.

kEncoder = 0

Sets an encoder as the speed reference only.

kPotentiometer = 2

Sets a potentiometer as the position reference only.

kQuadEncoder = 1

Sets a quadrature encoder as the position and speed reference.

class CANJaguar.NeutralMode[source]

Bases: builtins.object

Determines how the Jaguar behaves when sending a zero signal.

Brake = 1

Stop the motor’s rotation by applying a force.

Coast = 2

Do not attempt to stop the motor. Instead allow it to coast to a stop without applying resistance.

Jumper = 0

Use the NeutralMode that is set by the jumper wire on the CAN device

CANJaguar.allocated = <wpilib.resource.Resource object at 0x7fccefa197f0>
CANJaguar.changeControlMode(controlMode)[source]

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:controlMode – The new mode.
CANJaguar.configEncoderCodesPerRev(codesPerRev)[source]

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

Parameters:codesPerRev – The number of counts per revolution in 1X mode.
CANJaguar.configFaultTime(faultTime)[source]

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:faultTime – The time to wait before resuming operation, in seconds.
CANJaguar.configForwardLimit(forwardLimitPosition)[source]

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

Use configSoftPositionLimits() to set this and the LimitMode automatically.

Parameters:forwardLimitPosition – The position that, if exceeded, will disable the forward direction.
CANJaguar.configLimitMode(mode)[source]

Set the limit mode for position control mode.<br>

Use configSoftPositionLimits() or disableSoftPositionLimits() to set this automatically.

Parameters:mode – The LimitMode to use to limit the rotation of the device.
CANJaguar.configMaxOutputVoltage(voltage)[source]

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:voltage – The maximum voltage output by the Jaguar.
CANJaguar.configNeutralMode(mode)[source]

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:mode – Select to use the jumper setting or to override it to coast or brake (see NeutralMode).
CANJaguar.configPotentiometerTurns(turns)[source]

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:turns – The number of turns of the potentiometer
CANJaguar.configReverseLimit(reverseLimitPosition)[source]

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

Use configSoftPositionLimits() to set this and the LimitMode automatically.

Parameters:reverseLimitPosition – The position that, if exceeded, will disable the reverse direction.
CANJaguar.configSoftPositionLimits(forwardLimitPosition, reverseLimitPosition)[source]

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:
  • forwardLimitPosition – The position that, if exceeded, will disable the forward direction.
  • reverseLimitPosition – The position that, if exceeded, will disable the reverse direction.
CANJaguar.disable()[source]

Common interface for disabling a motor.

Deprecated since version 2015: Use disableControl() instead.

CANJaguar.disableControl()[source]

Disable the closed loop controller.

Stop driving the output based on the feedback.

CANJaguar.disableSoftPositionLimits()[source]

Disable Soft Position Limits if previously enabled.<br>

Soft Position Limits are disabled by default.

CANJaguar.enableControl(encoderInitialPosition=0.0)[source]

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:encoderInitialPosition – Encoder position to set if position with encoder reference (default of 0.0). Ignored otherwise.
CANJaguar.free()[source]

Cancel periodic messages to the Jaguar, effectively disabling it. No other methods should be called after this is called.

CANJaguar.get()[source]

Get the recently set outputValue set point.

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 set point.
CANJaguar.getBusVoltage()[source]

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

Returns:The bus voltage in Volts.
CANJaguar.getControlMode()[source]

Get the active control mode from the Jaguar.

Ask the Jagaur what mode it is in.

Return ControlMode:
 that the Jag is in.
CANJaguar.getD()[source]

Get the Derivative gain of the controller.

Returns:The derivative gain.
CANJaguar.getDescription()[source]
CANJaguar.getDeviceID()[source]
CANJaguar.getDeviceNumber()[source]
Returns:The CAN ID passed in the constructor
CANJaguar.getFaults()[source]

Get the status of any faults the Jaguar has detected.

Returns:A bit-mask of faults defined by the “Faults” constants.
  • kCurrentFault
  • kBusVoltageFault
  • kTemperatureFault
  • GateDriverFault
CANJaguar.getFirmwareVersion()[source]

Get the version of the firmware running on the Jaguar.

Returns:The firmware version. 0 if the device did not respond.
CANJaguar.getForwardLimitOK()[source]

Get the status of the forward limit switch.

Returns:True if the motor is allowed to turn in the forward direction.
CANJaguar.getHardwareVersion()[source]

Get the version of the Jaguar hardware.

Returns:The hardware version. 1: Jaguar, 2: Black Jaguar
CANJaguar.getI()[source]

Get the Integral gain of the controller.

Returns:The integral gain.
CANJaguar.getMessage(messageID, messageMask)[source]

Get a previously requested message.

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

Parameters:messageID – The messageID to read from the CAN bus (device number is added internally)
Returns:The up to 8 bytes of data that was received with the message
CANJaguar.getOutputCurrent()[source]

Get the current through the motor terminals of the Jaguar.

Returns:The output current in Amps.
CANJaguar.getOutputVoltage()[source]

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

Returns:The output voltage in Volts.
CANJaguar.getP()[source]

Get the Proportional gain of the controller.

Returns:The proportional gain.
CANJaguar.getPosition()[source]

Get the position of the encoder or potentiometer.

Returns:The position of the motor in rotations based on the configured feedback. See configPotentiometerTurns() and configEncoderCodesPerRev().
CANJaguar.getReverseLimitOK()[source]

Get the status of the reverse limit switch.

Returns:True if the motor is allowed to turn in the reverse direction.
CANJaguar.getSpeed()[source]

Get the speed of the encoder.

Returns:The speed of the motor in RPM based on the configured feedback.
CANJaguar.getTemperature()[source]

Get the internal temperature of the Jaguar.

Returns:The temperature of the Jaguar in degrees Celsius.
CANJaguar.kApproxBusVoltage = 12.0
CANJaguar.kBusVoltageFault = 4
CANJaguar.kControllerRate = 1000
CANJaguar.kCurrentFault = 1
CANJaguar.kForwardLimit = 1
CANJaguar.kFullMessageIDMask = 536870848
CANJaguar.kGateDriverFault = 8
CANJaguar.kMaxMessageDataSize = 8
CANJaguar.kReceiveStatusAttempts = 50
CANJaguar.kReverseLimit = 2
CANJaguar.kSendMessagePeriod = 20
CANJaguar.kTemperatureFault = 2
CANJaguar.kTrustedMessages = {33685760, 33685824, 33686976, 33687040, 33687872, 33687936, 33689024, 33689088, 33689984, 33690048}
CANJaguar.pidWrite(output)[source]
CANJaguar.requestMessage(messageID, period=0)[source]

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

Parameters:
  • messageID – The message to request
  • periodic – If positive, tell Network Communications to request the message every “period” milliseconds.
CANJaguar.sendMessage(messageID, data, period=0)[source]

Send a message to the Jaguar.

Parameters:
  • 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 message
  • period – If positive, tell Network Communications to send the message every “period” milliseconds.
CANJaguar.set(outputValue, syncGroup=0)[source]

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:
  • outputValue – The set-point to sent to the motor controller.
  • syncGroup – The update group to add this set() to, pending UpdateSyncGroup(). If 0 (default), update immediately.
CANJaguar.setCurrentModeEncoder(codesPerRev, p, i, d)[source]

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() to enable the device.

Parameters:
  • 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.
CANJaguar.setCurrentModePID(p, i, d)[source]

Enable controlling the motor current with a PID loop.

After calling this you must call enableControl() to enable the device.

Parameters:
  • 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.
CANJaguar.setCurrentModePotentiometer(p, i, d)[source]

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

After calling this you must call enableControl() to enable the device.

Parameters:
  • 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.
CANJaguar.setCurrentModeQuadEncoder(codesPerRev, p, i, d)[source]

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() to enable the device.

Parameters:
  • codesPerRev – The counts per revolution on the encoder
  • 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.
CANJaguar.setD(d)[source]

Set the D constant for the closed loop modes.

Parameters:d – The derivative gain of the Jaguar’s PID controller.
CANJaguar.setI(i)[source]

Set the I constant for the closed loop modes.

Parameters:i – The integral gain of the Jaguar’s PID controller.
CANJaguar.setP(p)[source]

Set the P constant for the closed loop modes.

Parameters:p – The proportional gain of the Jaguar’s PID controller.
CANJaguar.setPID(p, i, d)[source]

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

Parameters:
  • 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.
CANJaguar.setPercentMode()[source]

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() to enable the device.

CANJaguar.setPercentModeEncoder(codesPerRev)[source]

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() to enable the device.

Parameters:codesPerRev – The counts per revolution on the encoder
CANJaguar.setPercentModePotentiometer()[source]

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() to enable the device.

Parameters:tag – The constant {@link CANJaguar#kPotentiometer}
CANJaguar.setPercentModeQuadEncoder(codesPerRev)[source]

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() to enable the device.

Parameters:
  • tag – The constant {@link CANJaguar#kQuadEncoder}
  • codesPerRev – The counts per revolution on the encoder
CANJaguar.setPositionModePotentiometer(p, i, d)[source]

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

After calling this you must call enableControl() to enable the device.

Parameters:
  • 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.
CANJaguar.setPositionModeQuadEncoder(codesPerRev, p, i, d)[source]

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

After calling this you must call enableControl() to enable the device.

Parameters:
  • codesPerRev – The counts per revolution on the encoder
  • 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.
CANJaguar.setPositionReference(reference)[source]

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:reference – Specify a position reference.
CANJaguar.setSpeedModeEncoder(codesPerRev, p, i, d)[source]

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

After calling this you must call enableControl() to enable the device.

Parameters:
  • codesPerRev – The counts per revolution on the encoder
  • 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.
CANJaguar.setSpeedModeQuadEncoder(codesPerRev, p, i, d)[source]

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

After calling this you must call enableControl() to enable the device.

Parameters:
  • codesPerRev – The counts per revolution on the encoder
  • 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.
CANJaguar.setSpeedReference(reference)[source]

Set the reference source device for speed controller mode.

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

Parameters:reference – Specify a speed reference.
CANJaguar.setVoltageMode()[source]

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

After calling this you must call enableControl() to enable the device.

CANJaguar.setVoltageModeEncoder(codesPerRev)[source]

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

After calling this you must call enableControl() to enable the device.

Parameters:codesPerRev – The counts per revolution on the encoder
CANJaguar.setVoltageModePotentiometer()[source]

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

After calling this you must call enableControl() to enable the device.

CANJaguar.setVoltageModeQuadEncoder(codesPerRev)[source]

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

After calling this you must call enableControl() to enable the device.

Parameters:
  • tag – The constant {@link CANJaguar#kQuadEncoder}
  • codesPerRev – The counts per revolution on the encoder
CANJaguar.setVoltageRampRate(rampRate)[source]

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:rampRate – The maximum rate of voltage change in Percent Voltage mode in V/s.
CANJaguar.setupPeriodicStatus()[source]

Enables periodic status updates from the Jaguar

CANJaguar.stopMotor()[source]

Common interface for stopping a motor.

CANJaguar.updatePeriodicStatus()[source]

Check for new periodic status updates and unpack them into local variables.

static CANJaguar.updateSyncGroup(syncGroup)[source]

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

Parameters:syncGroup – A bitmask of groups to generate synchronous output.
CANJaguar.verify()[source]

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.