Package com.revrobotics
Class CANSparkFlex
- java.lang.Object
-
- com.revrobotics.CANSparkLowLevel
-
- com.revrobotics.CANSparkBase
-
- com.revrobotics.CANSparkFlex
-
- All Implemented Interfaces:
edu.wpi.first.wpilibj.motorcontrol.MotorController
,java.lang.AutoCloseable
public class CANSparkFlex extends CANSparkBase
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.revrobotics.CANSparkBase
CANSparkBase.ControlType, CANSparkBase.ExternalFollower, CANSparkBase.FaultID, CANSparkBase.IdleMode, CANSparkBase.InputMode, CANSparkBase.SoftLimitDirection
-
Nested classes/interfaces inherited from class com.revrobotics.CANSparkLowLevel
CANSparkLowLevel.FollowConfig, CANSparkLowLevel.MotorType, CANSparkLowLevel.PeriodicFrame, CANSparkLowLevel.PeriodicStatus0, CANSparkLowLevel.PeriodicStatus1, CANSparkLowLevel.PeriodicStatus2, CANSparkLowLevel.SparkModel
-
-
Field Summary
-
Fields inherited from class com.revrobotics.CANSparkLowLevel
expectedSparkModel, isClosed, kAPIBuildVersion, kAPIMajorVersion, kAPIMinorVersion, kAPIVersion, motorType, sparkMaxHandle
-
-
Constructor Summary
Constructors Constructor Description CANSparkFlex(int deviceId, CANSparkLowLevel.MotorType type)
Create a new object to control a SPARK Flex motor Controller
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description RelativeEncoder
getEncoder()
Returns an object for interfacing with the encoder connected through the the motor interface of the SPARK Flex.RelativeEncoder
getExternalEncoder(int countsPerRev)
Returns an object for interfacing with an external quadrature encoderRelativeEncoder
getExternalEncoder(SparkFlexExternalEncoder.Type encoderType, int countsPerRev)
Returns an object for interfacing with an external quadrature encoder-
Methods inherited from class com.revrobotics.CANSparkBase
burnFlash, clearFaults, disable, disableVoltageCompensation, enableSoftLimit, enableVoltageCompensation, follow, follow, follow, follow, get, getAbsoluteEncoder, getAbsoluteEncoder, getAbsoluteEncoder, getAnalog, getAnalog, getAnalog, getAnalog, getAppliedOutput, getBusVoltage, getClosedLoopRampRate, getEncoder, getEncoder, getEncoder, getFault, getFaults, getFeedbackDeviceID, getForwardLimitSwitch, getForwardLimitSwitch, getForwardLimitSwitch, getIdleMode, getInverted, getLastError, getMotorTemperature, getOpenLoopRampRate, getOutputCurrent, getPIDController, getReverseLimitSwitch, getReverseLimitSwitch, getReverseLimitSwitch, getSoftLimit, getStickyFault, getStickyFaults, getVoltageCompensationNominalVoltage, isFollower, isSoftLimitEnabled, set, setCANTimeout, setClosedLoopRampRate, setIdleMode, setInverted, setOpenLoopRampRate, setSecondaryCurrentLimit, setSecondaryCurrentLimit, setSmartCurrentLimit, setSmartCurrentLimit, setSmartCurrentLimit, setSoftLimit, setVoltage, stopMotor
-
Methods inherited from class com.revrobotics.CANSparkLowLevel
close, enableExternalUSBControl, getDeviceId, getFirmwareString, getFirmwareVersion, getInitialMotorType, getMotorType, getSafeFloat, getSerialNumber, restoreFactoryDefaults, restoreFactoryDefaults, setCANMaxRetries, setControlFramePeriodMs, setPeriodicFramePeriod, setPeriodicFramePeriod, setPeriodicFrameTimeout, throwIfClosed
-
-
-
-
Constructor Detail
-
CANSparkFlex
public CANSparkFlex(int deviceId, CANSparkLowLevel.MotorType type)
Create a new object to control a SPARK Flex motor Controller- Parameters:
deviceId
- The device ID.type
- The motor type connected to the controller. Brushless motor wires must be connected to their matching colors and the hall sensor must be plugged in. Brushed motors must be connected to the Red and Black terminals only.
-
-
Method Detail
-
getEncoder
public RelativeEncoder getEncoder()
Returns an object for interfacing with the encoder connected through the the motor interface of the SPARK Flex.For a SPARK Flex in brushless mode, it is assumed that the default encoder type is quadrature and the counts per revolution is 7168.
For a SPARK Flex in brushed mode, use
CANSparkBase.getEncoder(com.revrobotics.SparkRelativeEncoder.Type, int)
- Specified by:
getEncoder
in classCANSparkBase
- Returns:
- An object for interfacing with the integrated encoder.
-
getExternalEncoder
public RelativeEncoder getExternalEncoder(int countsPerRev)
Returns an object for interfacing with an external quadrature encoder- Parameters:
countsPerRev
- The counts per revolution of the encoder- Returns:
- An object for interfacing with an external quadrature encoder
-
getExternalEncoder
public RelativeEncoder getExternalEncoder(SparkFlexExternalEncoder.Type encoderType, int countsPerRev)
Returns an object for interfacing with an external quadrature encoder- Parameters:
encoderType
- The encoder type for the motor: currently only kQuadraturecountsPerRev
- The counts per revolution of the encoder- Returns:
- An object for interfacing with an external quadrature encoder
-
-