Package com.revrobotics
Class CANSparkMaxLowLevel
java.lang.Object
com.revrobotics.CANSparkMaxLowLevel
- All Implemented Interfaces:
edu.wpi.first.wpilibj.motorcontrol.MotorController
,edu.wpi.first.wpilibj.SpeedController
,AutoCloseable
- Direct Known Subclasses:
CANSparkMax
public abstract class CANSparkMaxLowLevel
extends Object
implements edu.wpi.first.wpilibj.SpeedController, edu.wpi.first.wpilibj.motorcontrol.MotorController, AutoCloseable
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected static class
static enum
static enum
class
class
class
-
Field Summary
Modifier and TypeFieldDescriptionprotected final AtomicBoolean
static final int
static final int
static final int
static final int
protected final CANSparkMaxLowLevel.MotorType
protected final long
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Closes the SPARK MAX Controllerstatic void
enableExternalUSBControl
(boolean enable) Allow external controllers to recieve control commands over USB.int
Get the configured Device ID of the SPARK MAX.Get the firmware version of the SPARK MAX as a string.int
Get the firmware version of the SPARK MAX.Deprecated, for removal: This API element is subject to removal in a future version.Get the motor type setting for the SPARK MAXfloat
getSafeFloat
(float f) byte[]
Get the unique serial number of the SPARK MAX.Restore motor controller parameters to factory default until the next controller rebootrestoreFactoryDefaults
(boolean persist) Restore motor controller parameters to factory defaultvoid
setControlFramePeriodMs
(int periodMs) Set the control frame send period for the native CAN Send thread.setPeriodicFramePeriod
(CANSparkMaxLowLevel.PeriodicFrame frameID, int periodMs) Set the rate of transmission for periodic frames from the SPARK MAXprotected void
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface edu.wpi.first.wpilibj.motorcontrol.MotorController
disable, get, getInverted, set, setInverted, setVoltage, stopMotor
-
Field Details
-
kAPIMajorVersion
-
kAPIMinorVersion
-
kAPIBuildVersion
-
kAPIVersion
-
sparkMaxHandle
-
isClosed
-
motorType
-
-
Method Details
-
close
Closes the SPARK MAX Controller- Specified by:
close
in interfaceAutoCloseable
-
getFirmwareVersion
Get the firmware version of the SPARK MAX.- Returns:
- uint32_t Firmware version integer. Value is represented as 4 bytes, Major.Minor.Build H.Build L
-
setControlFramePeriodMs
Set the control frame send period for the native CAN Send thread.- Parameters:
periodMs
- The send period in milliseconds between 1ms and 100ms or set to 0 to disable periodic sends. Note this is not updated until the next call to Set() or SetReference().
-
getFirmwareString
Get the firmware version of the SPARK MAX as a string.- Returns:
- std::string Human readable firmware version string
-
getSerialNumber
Get the unique serial number of the SPARK MAX. Not currently available.- Returns:
- byte[] Vector of bytes representig the unique serial number
-
getDeviceId
Get the configured Device ID of the SPARK MAX.- Returns:
- int device ID
-
getInitialMotorType
Deprecated, for removal: This API element is subject to removal in a future version.UsegetMotorType()
insteadGet the motor type setting for the SPARK MAX- Returns:
- MotorType Motor type setting
-
getMotorType
Get the motor type setting for the SPARK MAX- Returns:
- MotorType Motor type setting
-
setPeriodicFramePeriod
Set the rate of transmission for periodic frames from the SPARK MAXEach motor controller sends back three status frames with different data at set rates. Use this function to change the default rates.
Defaults: Status0 - 10ms Status1 - 20ms Status2 - 50ms
This value is not stored in the FLASH after calling burnFlash() and is reset on powerup.
Refer to the SPARK MAX reference manual on details for how and when to configure this parameter.
- Parameters:
frameID
- The frame ID can be one of PeriodicFrame typeperiodMs
- The rate the controller sends the frame to the controller.- Returns:
REVLibError.kOk
if successful
-
enableExternalUSBControl
Allow external controllers to recieve control commands over USB. For example, a configuration where the heartbeat (and enable/disable) is sent by the main controller, but control frames are sent by other CAN devices over USB.This is global for all controllers on the same bus.
This does not disable sending control frames from this device. To prevent conflicts, do not enable this feature and also send Set() for SetReference() from the controllers you wish to control.
- Parameters:
enable
- Enable or disable external control
-
getSafeFloat
-
restoreFactoryDefaults
Restore motor controller parameters to factory default until the next controller reboot- Returns:
REVLibError.kOk
if successful
-
restoreFactoryDefaults
Restore motor controller parameters to factory default- Parameters:
persist
- If true, burn the flash with the factory default parameters- Returns:
REVLibError.kOk
if successful
-
throwIfClosed
-
getMotorType()
instead