Package com.revrobotics
Class CANSparkMaxLowLevel
- java.lang.Object
-
- com.revrobotics.CANSparkMaxLowLevel
-
- All Implemented Interfaces:
edu.wpi.first.wpilibj.PIDOutput
,edu.wpi.first.wpilibj.SpeedController
- Direct Known Subclasses:
CANSparkMax
public abstract class CANSparkMaxLowLevel extends java.lang.Object implements edu.wpi.first.wpilibj.SpeedController
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
CANSparkMaxLowLevel.ConfigParameter
protected static class
CANSparkMaxLowLevel.FollowConfig
static class
CANSparkMaxLowLevel.MotorType
static class
CANSparkMaxLowLevel.ParameterStatus
static class
CANSparkMaxLowLevel.ParameterType
static class
CANSparkMaxLowLevel.PeriodicFrame
class
CANSparkMaxLowLevel.PeriodicStatus0
class
CANSparkMaxLowLevel.PeriodicStatus1
class
CANSparkMaxLowLevel.PeriodicStatus2
-
Field Summary
Fields Modifier and Type Field Description static int
kDefaultCANTimeoutMs
static int
kDefaultControlFramePeriodMs
static int
kDefaultStatus0PeriodMs
static int
kDefaultStatus1PeriodMs
static int
kDefaultStatus2PeriodMs
static int
kMinFirmwareVersion
static byte
kNumFirmwareRetries
protected edu.wpi.first.wpilibj.CAN
m_can
protected int
m_canTimeoutMs
protected int
m_controlPeriodMs
protected boolean
m_inverted
-
Constructor Summary
Constructors Constructor Description CANSparkMaxLowLevel(int deviceID, CANSparkMaxLowLevel.MotorType type)
Create a new SPARK MAX Controller
-
Method Summary
-
-
-
Field Detail
-
kNumFirmwareRetries
public static final byte kNumFirmwareRetries
- See Also:
- Constant Field Values
-
kDefaultControlFramePeriodMs
public static final int kDefaultControlFramePeriodMs
- See Also:
- Constant Field Values
-
kDefaultCANTimeoutMs
public static final int kDefaultCANTimeoutMs
- See Also:
- Constant Field Values
-
kDefaultStatus0PeriodMs
public static final int kDefaultStatus0PeriodMs
- See Also:
- Constant Field Values
-
kDefaultStatus1PeriodMs
public static final int kDefaultStatus1PeriodMs
- See Also:
- Constant Field Values
-
kDefaultStatus2PeriodMs
public static final int kDefaultStatus2PeriodMs
- See Also:
- Constant Field Values
-
kMinFirmwareVersion
public static final int kMinFirmwareVersion
- See Also:
- Constant Field Values
-
m_can
protected edu.wpi.first.wpilibj.CAN m_can
-
m_controlPeriodMs
protected int m_controlPeriodMs
-
m_canTimeoutMs
protected int m_canTimeoutMs
-
m_inverted
protected boolean m_inverted
-
-
Constructor Detail
-
CANSparkMaxLowLevel
public CANSparkMaxLowLevel(int deviceID, CANSparkMaxLowLevel.MotorType type)
Create a new SPARK MAX Controller- Parameters:
deviceID
- The device ID.type
- The motor type connected to the controller. Brushless motors must be connected to their matching color and the hall sensor plugged in. Brushed motors must be connected to the Red and Black terminals only.
-
-
Method Detail
-
getFirmwareVersion
public int 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
-
getFirmwareString
public java.lang.String getFirmwareString()
Get the firmware version of the SPARK MAX as a string.- Returns:
- std::string Human readable firmware version string
-
getSerialNumber
public byte[] getSerialNumber()
Get the unique serial number of the SPARK MAX.- Returns:
- byte[] Vector of bytes representig the unique serial number
-
getDeviceId
public int getDeviceId()
Get the configured Device ID of the SPARK MAX.- Returns:
- int device ID
-
setMotorType
public CANError setMotorType(CANSparkMaxLowLevel.MotorType type)
Set the motor type connected to the SPARK MAX. This uses the Set Parameter API and should be used infrequently. The parameter does not presist unless burnFlash() is called. The recommended method to configure this parameter is to use the SPARK MAX GUI to tune and save parameters.- Parameters:
type
- The type of motor connected to the controller. Brushless motors must be connected to their matching color and the hall sensor plugged in. Brushed motors must be connected to the Red and Black terminals only.- Returns:
- CANError Set to CANError::kOk if successful
-
getMotorType
public CANSparkMaxLowLevel.MotorType getMotorType()
Get the motor type setting for the SPARK MAX. This uses the Get Parameter API and should be used infrequently. This function uses a non-blocking call and will return a cached value if the parameter is not returned by the timeout. The timeout can be changed by calling SetCANTimeout(int milliseconds)- Returns:
- MotorType Motor type setting
-
setPeriodicFramePeriod
public CANError setPeriodicFramePeriod(CANSparkMaxLowLevel.PeriodicFrame frameID, int periodMs)
Set the rate of transmission for periodic frames from the SPARK MAX Refer to the SPARK MAX reference manual on details for how and when to configure this parameter.- Returns:
- CANError Set to CANError::kOk if successful
-
setControlFramePeriod
public void setControlFramePeriod(int periodMs)
Set the rate of transmission for setpoint frame. This will not take effect until the next call of a method that sets a new setpoint. Refer to the SPARK MAX reference manual on details for how and when to configure this parameter.- Parameters:
periodMs
- The rate to send control frames
-
getControlFramePeriod
public int getControlFramePeriod()
Return the rate of transmission for setpoint frame- Returns:
- Control frame perioid in milliseconds
-
setParameter
public CANSparkMaxLowLevel.ParameterStatus setParameter(CANSparkMaxLowLevel.ConfigParameter parameterID, double value)
-
setParameter
public CANSparkMaxLowLevel.ParameterStatus setParameter(CANSparkMaxLowLevel.ConfigParameter parameterID, int value)
-
setParameter
public CANSparkMaxLowLevel.ParameterStatus setParameter(CANSparkMaxLowLevel.ConfigParameter parameterID, boolean value)
-
getParameterDouble
public java.util.Optional<java.lang.Double> getParameterDouble(CANSparkMaxLowLevel.ConfigParameter parameterID)
-
getParameterInt
public java.util.Optional<java.lang.Integer> getParameterInt(CANSparkMaxLowLevel.ConfigParameter parameterID)
-
getParameterBoolean
public java.util.Optional<java.lang.Boolean> getParameterBoolean(CANSparkMaxLowLevel.ConfigParameter parameterID)
-
setParameterCore
public CANSparkMaxLowLevel.ParameterStatus setParameterCore(CANSparkMaxLowLevel.ConfigParameter parameterID, CANSparkMaxLowLevel.ParameterType type, int value)
-
getParameterCore
public java.util.Optional<java.lang.Integer> getParameterCore(CANSparkMaxLowLevel.ConfigParameter parameterID, CANSparkMaxLowLevel.ParameterType expectedType)
-
getParameterType
public CANSparkMaxLowLevel.ParameterType getParameterType(CANSparkMaxLowLevel.ConfigParameter parameterID)
-
getPeriodicStatus0
protected CANSparkMaxLowLevel.PeriodicStatus0 getPeriodicStatus0()
-
getPeriodicStatus1
protected CANSparkMaxLowLevel.PeriodicStatus1 getPeriodicStatus1()
-
getPeriodicStatus2
protected CANSparkMaxLowLevel.PeriodicStatus2 getPeriodicStatus2()
-
-