Class A301
java.lang.Object
com.revrobotics.spark.A301
- All Implemented Interfaces:
org.wpilib.hardware.motor.MotorController
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionClears all sticky faults.voidclose()Closes the FIRST A301 motor controllervoiddisable()Common interface for disabling a motor.intGetBusId()Get the configured CAN Bus ID of the FIRST A301.intGet the configured Device ID of the FIRST A301.Get the active faults that are currently present on the A301.Get the firmware version of the FIRST A301 as a string.intGet the firmware version of the FIRST A301.booleanCommon interface for returning the inversion state of a speed controller.Get the sticky faults that were present on the A301 at one point since the sticky faults were last cleared.Get the sticky warnings that were present on the A301 at one point since the sticky warnings were last cleared.doubleGets the throttle of the motor controller.Get the active warnings that are currently present on the A301.Get whether the A301 has one or more active faults.Get whether the A301 has one or more active warnings.Get whether the A301 has one or more sticky faults.Get whether the A301 has one or more sticky warnings.setAbsolutePosition(double absPosition, boolean isContinuous) Sets the absolute position of the A301 with optional continuous rotation.setCurrent(double current) Sets the motor current of the A301.voidsetInverted(boolean isInverted) Deprecated.setPosition(double position) Sets the relative position of the A301.voidsetThrottle(double throttle) Sets the throttle of the motor controller.setVelocity(double velocity) Sets the velocity of the A301.voidsetVoltage(double outputVolts) Sets the voltage output of the MotorController.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.wpilib.hardware.motor.MotorController
setVoltage
-
Field Details
-
isClosed
-
defaultDeviceId
public static final int defaultDeviceId- See Also:
-
-
Constructor Details
-
A301
public A301(int busId) Create a new object to control a FIRST A301 motorThe default A301 device ID is set to 3 out of the factory.
- Parameters:
busId- The CAN bus ID this device will be on.
-
A301
public A301(int busId, int deviceId) Create a new object to control a FIRST A301 motor- Parameters:
busId- The CAN bus ID this device will be on.deviceId- The device ID.
-
-
Method Details
-
close
public void close()Closes the FIRST A301 motor controller -
GetBusId
public int GetBusId()Get the configured CAN Bus ID of the FIRST A301.- Returns:
- int CAN bus ID
-
getDeviceId
public int getDeviceId()Get the configured Device ID of the FIRST A301.- Returns:
- int device ID
-
getFirmwareVersion
public int getFirmwareVersion()Get the firmware version of the FIRST A301.- Returns:
- uint32_t Firmware version integer. Value is represented as 4 bytes, Major.Minor.Build H.Build L
-
getFirmwareString
Get the firmware version of the FIRST A301 as a string.- Returns:
- String Human readable firmware version string
-
hasActiveFault
-
hasStickyFault
-
hasActiveWarning
-
hasStickyWarning
-
getFaults
Get the active faults that are currently present on the A301. Faults are fatal errors that prevent the motor from running.- Returns:
- A struct with each fault and their active value
-
getStickyFaults
Get the sticky faults that were present on the A301 at one point since the sticky faults were last cleared. Faults are fatal errors that prevent the motor from running.Sticky faults can be cleared with
clearFaults().- Returns:
- A struct with each fault and their sticky value
-
getWarnings
Get the active warnings that are currently present on the A301. Warnings are non-fatal errors.- Returns:
- A struct with each warning and their active value
-
getStickyWarnings
Get the sticky warnings that were present on the A301 at one point since the sticky warnings were last cleared. Warnings are non-fatal errors.Sticky warnings can be cleared with
SparkBase.clearFaults().- Returns:
- A struct with each warning and their sticky value
-
clearFaults
-
getBusVoltage
-
getAppliedOutput
-
getOutputCurrent
-
getMotorTemperature
-
getRelativeEncoderPosition
-
getEncoderVelocity
-
getAbsoluteEncoderPosition
-
setVelocity
Sets the velocity of the A301.- Parameters:
velocity- The velocity (in RPM) to set- Returns:
- REVLibError.kOk if successful
-
setPosition
Sets the relative position of the A301.- Parameters:
position- The relative position (in Rotations) to set- Returns:
- REVLibError.kOk if successful
-
setAbsolutePosition
Sets the absolute position of the A301 with optional continuous rotation.The position will flip when it reaches an endpoint is continuous rotation is enabled.
- Parameters:
absPosition- The absolute position (-0.5 to 0.5) to setisContinuous- Should the position flip when it reaches an endpoint?- Returns:
- REVLibError.kOk if successful
-
setCurrent
Sets the motor current of the A301.- Parameters:
current- The current (in Amps) to drive the motor at- Returns:
- REVLibError.kOk if successful
-
setThrottle
public void setThrottle(double throttle) Sets the throttle of the motor controller.- Specified by:
setThrottlein interfaceorg.wpilib.hardware.motor.MotorController- Parameters:
throttle- The throttle where -1.0 indicates full reverse and 1.0 indicates full forward.
-
getThrottle
public double getThrottle()Gets the throttle of the motor controller.- Specified by:
getThrottlein interfaceorg.wpilib.hardware.motor.MotorController- Returns:
- The throttle where -1.0 represents full reverse and 1.0 represents full forward.
-
setVoltage
public void setVoltage(double outputVolts) Sets the voltage output of the MotorController. This is equivalent to a call to setSetpoint(output, ControlType.kVoltage). The behavior of this call differs slightly from the WPILib documetation for this call since the device internally sets the desired voltage (not a compensation value). That means that this *can* be a 'set-and-forget' call.- Specified by:
setVoltagein interfaceorg.wpilib.hardware.motor.MotorController- Parameters:
outputVolts- The voltage to output.
-
setInverted
Deprecated.Common interface for inverting direction of a speed controller.- Specified by:
setInvertedin interfaceorg.wpilib.hardware.motor.MotorController- Parameters:
isInverted- The state of inversion, true is inverted.
-
getInverted
public boolean getInverted()Common interface for returning the inversion state of a speed controller.- Specified by:
getInvertedin interfaceorg.wpilib.hardware.motor.MotorController- Returns:
- The state of inversion, true is inverted.
-
disable
public void disable()Common interface for disabling a motor.- Specified by:
disablein interfaceorg.wpilib.hardware.motor.MotorController
-