Class A301
- All Implemented Interfaces:
org.wpilib.hardware.motor.MotorController
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic enumstatic enumstatic final recordstatic final recordstatic final recordstatic final recordstatic class -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabsoluteEncoderPositionPeriodMs(int period_ms) Set the period (ms) of the status frame that provides the signal returned by getAbsoluteEncoderPosition().appliedOutputPeriodMs(int period_ms) Set the period (ms) of the status frame that provides the signal returned by getAppliedOutput().busVoltagePeriodMs(int period_ms) Set the period (ms) of the status frame that provides the signal returned by getBusVoltage().Clears all sticky faults.voidclose()Closes the FIRST A301 motor controllervoiddisable()Common interface for disabling a motor.Disables continuous input for absolute position control.Enables continuous input for absolute position control.encoderVelocityPeriodMs(int period_ms) Set the period (ms) of the status frame that provides the signal returned by getEncoderVelocity().faultsPeriodMs(int period_ms) Set the period (ms) of the status frame that provides the signal returned by getFaults() and getStickyFaults().intGet the period (ms) of the status frame that provides the signal returned by getAbsoluteEncoderPosition().Returns the A301's output duty cycle.intGet the period (ms) of the status frame that provides the signal returned by getAppliedOutput().intgetBusId()Get the configured CAN Bus ID of the FIRST A301.Returns the A301 bus voltage in Volts.intGet the period (ms) of the status frame that provides the signal returned by getBusVoltage().intGet the configured Device ID of the FIRST A301.Get the velocity of the motor.intGet the period (ms) of the status frame that provides the signal returned by getEncoderVelocity().Get the active faults that are currently present on the A301.intGet the period (ms) of the status frame that provides the signal returned by getFaults() and getStickyFaults().Get the firmware version of the FIRST A301 as a string.intGet the firmware version of the FIRST A301.Returns the RPM of the A301's attached gearbox.booleanCommon interface for returning the inversion state of a speed controller.Returns A301's motor current in Amps.intGet the period (ms) of the status frame that provides the signal returned by getMotorCurrent().Returns the motor temperature in Celsius.intGet the period (ms) of the status frame that provides the signal returned by getMotorTemperature().Get the position of the motor.intGet the period (ms) of the status frame that provides the signal returned by getRelativeEncoderPosition().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.intGet the period (ms) of the status frame that provides the signal returned by getWarnings() and getStickyWarnings().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.booleanQueries the continuous input for absolute position control.motorCurrentPeriodMs(int period_ms) Set the period (ms) of the status frame that provides the signal returned by getMotorCurrent().motorTemperaturePeriodMs(int period_ms) Set the period (ms) of the status frame that provides the signal returned by getMotorTemperature().relativeEncoderPositionPeriodMs(int period_ms) Set the period (ms) of the status frame that provides the signal returned by getRelativeEncoderPosition().setAbsoluteEncoderPosition(double position) Set the position of the absolute encoder.setAbsolutePosition(double absPosition) Sets the absolute position of the A301 (with maximum speed).setAbsolutePositionWithSpeed(double absPosition, double speed) Sets the absolute position of the A301 with a specific speed.setCurrent(double current) Sets the motor current of the A301.voidsetInverted(boolean isInverted) Common interface for inverting direction of a speed controller.setRelativeEncoderPosition(double position) Set the position of the relative encoder.setRelativePosition(double position) Sets the relative position of the A301 (with maximum speed).setRelativePositionWithSpeed(double position, double speed) Sets the relative position of the A301 with a specific speed.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.warningsPeriodMs(int period_ms) Set the period (ms) of the status frame that provides the signal returned by getWarnings() and getStickyWarnings().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 motorNOTE: If busId indicates a Motioncore bus, the device ID will be auto-detected.
- 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 motorNOTE: If busId indicates a Motioncore bus, the device ID will be auto-detected and deviceId will be ignored.
- 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
clearFaults().- Returns:
- A struct with each warning and their sticky value
-
clearFaults
-
getBusVoltage
-
getAppliedOutput
-
getMotorCurrent
-
getMotorTemperature
-
getGearboxRPM
Returns the RPM of the A301's attached gearbox.- Returns:
- Signal containing the gearbox RPM (@see GearboxRPM)
-
getRelativeEncoderPosition
-
getEncoderVelocity
-
getAbsoluteEncoderPosition
-
setRelativeEncoderPosition
Set the position of the relative encoder.- Parameters:
position- Number of rotations of the motor- Returns:
- REVLibError::kOk if successful
-
setAbsoluteEncoderPosition
Set the position of the absolute encoder.- Parameters:
position- Number of rotations of the motor- Returns:
- REVLibError::kOk if successful
-
setVelocity
Sets the velocity of the A301.- Parameters:
velocity- The velocity (in RPM) to set- Returns:
- REVLibError.kOk if successful
-
setRelativePosition
Sets the relative position of the A301 (with maximum speed).- Parameters:
position- The relative position (in Rotations) to set- Returns:
- REVLibError.kOk if successful
-
setRelativePositionWithSpeed
Sets the relative position of the A301 with a specific speed.Setting speed less than or equal to 0 will apply maximum speed)
- Parameters:
position- The relative position (in Rotations) to setspeed- The speed to approach the position at (in RPM)- Returns:
- REVLibError.kOk if successful
-
setAbsolutePosition
Sets the absolute position of the A301 (with maximum speed).- Parameters:
absPosition- The absolute position (-0.5 to 0.5) to set- Returns:
- REVLibError.kOk if successful
-
setAbsolutePositionWithSpeed
Sets the absolute position of the A301 with a specific speed.Setting speed less than or equal to 0 will apply maximum speed)
- Parameters:
absPosition- The absolute position (-0.5 to 0.5) to setspeed- The speed to approach the position at (in RPM)- Returns:
- REVLibError.kOk if successful
-
enableAbsolutePositionContinuousInput
Enables continuous input for absolute position control.- Returns:
- REVLibError::kOk if successful
-
disableAbsolutePositionContinuousInput
Disables continuous input for absolute position control.- Returns:
- REVLibError::kOk if successful
-
isAbsolutePositionContinuousInputEnabled
public boolean isAbsolutePositionContinuousInputEnabled()Queries the continuous input for absolute position control.- Returns:
- true if continuous input is enabled.
-
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
public void setInverted(boolean isInverted) 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
-
faultsPeriodMs
Set the period (ms) of the status frame that provides the signal returned by getFaults() and getStickyFaults().The default period is 50ms. The maximum period is 1000ms (1s).
If multiple periods are set for signals within the same status frame, the minimum given value will be used.
- Parameters:
period_ms- The period in milliseconds- Returns:
- The modified A301 object for method chaining
-
getFaultsPeriodMs
public int getFaultsPeriodMs()Get the period (ms) of the status frame that provides the signal returned by getFaults() and getStickyFaults().- Returns:
- The period in milliseconds
-
warningsPeriodMs
Set the period (ms) of the status frame that provides the signal returned by getWarnings() and getStickyWarnings().The default period is 50ms. The maximum period is 1000ms (1s).
If multiple periods are set for signals within the same status frame, the minimum given value will be used.
- Parameters:
period_ms- The period in milliseconds- Returns:
- The modified A301 object for method chaining
-
getWarningsPeriodMs
public int getWarningsPeriodMs()Get the period (ms) of the status frame that provides the signal returned by getWarnings() and getStickyWarnings().- Returns:
- The period in milliseconds
-
busVoltagePeriodMs
Set the period (ms) of the status frame that provides the signal returned by getBusVoltage().The default period is 10ms. The maximum period is 1000ms (1s).
If multiple periods are set for signals within the same status frame, the minimum given value will be used.
- Parameters:
period_ms- The period in milliseconds- Returns:
- The modified A301 object for method chaining
-
getBusVoltagePeriodMs
public int getBusVoltagePeriodMs()Get the period (ms) of the status frame that provides the signal returned by getBusVoltage().- Returns:
- The period in milliseconds
-
appliedOutputPeriodMs
Set the period (ms) of the status frame that provides the signal returned by getAppliedOutput().The default period is 10ms. The maximum period is 1000ms (1s).
If multiple periods are set for signals within the same status frame, the minimum given value will be used.
- Parameters:
period_ms- The period in milliseconds- Returns:
- The modified A301 object for method chaining
-
getAppliedOutputPeriodMs
public int getAppliedOutputPeriodMs()Get the period (ms) of the status frame that provides the signal returned by getAppliedOutput().- Returns:
- The period in milliseconds
-
motorCurrentPeriodMs
Set the period (ms) of the status frame that provides the signal returned by getMotorCurrent().The default period is 10ms. The maximum period is 1000ms (1s).
If multiple periods are set for signals within the same status frame, the minimum given value will be used.
- Parameters:
period_ms- The period in milliseconds- Returns:
- The modified A301 object for method chaining
-
getMotorCurrentPeriodMs
public int getMotorCurrentPeriodMs()Get the period (ms) of the status frame that provides the signal returned by getMotorCurrent().- Returns:
- The period in milliseconds
-
motorTemperaturePeriodMs
Set the period (ms) of the status frame that provides the signal returned by getMotorTemperature().The default period is 10ms. The maximum period is 1000ms (1s).
If multiple periods are set for signals within the same status frame, the minimum given value will be used.
- Parameters:
period_ms- The period in milliseconds- Returns:
- The modified A301 object for method chaining
-
getMotorTemperaturePeriodMs
public int getMotorTemperaturePeriodMs()Get the period (ms) of the status frame that provides the signal returned by getMotorTemperature().- Returns:
- The period in milliseconds
-
relativeEncoderPositionPeriodMs
Set the period (ms) of the status frame that provides the signal returned by getRelativeEncoderPosition().The default period is 20ms. The maximum period is 1000ms (1s).
If multiple periods are set for signals within the same status frame, the minimum given value will be used.
- Parameters:
period_ms- The period in milliseconds- Returns:
- The modified A301 object for method chaining
-
getRelativeEncoderPositionPeriodMs
public int getRelativeEncoderPositionPeriodMs()Get the period (ms) of the status frame that provides the signal returned by getRelativeEncoderPosition().- Returns:
- The period in milliseconds
-
encoderVelocityPeriodMs
Set the period (ms) of the status frame that provides the signal returned by getEncoderVelocity().The default period is 20ms. The maximum period is 1000ms (1s).
If multiple periods are set for signals within the same status frame, the minimum given value will be used.
- Parameters:
period_ms- The period in milliseconds- Returns:
- The modified A301 object for method chaining
-
getEncoderVelocityPeriodMs
public int getEncoderVelocityPeriodMs()Get the period (ms) of the status frame that provides the signal returned by getEncoderVelocity().- Returns:
- The period in milliseconds
-
absoluteEncoderPositionPeriodMs
Set the period (ms) of the status frame that provides the signal returned by getAbsoluteEncoderPosition().The default period is 20ms. The maximum period is 1000ms (1s).
If multiple periods are set for signals within the same status frame, the minimum given value will be used.
- Parameters:
period_ms- The period in milliseconds- Returns:
- The modified A301 object for method chaining
-
getAbsoluteEncoderPositionPeriodMs
public int getAbsoluteEncoderPositionPeriodMs()Get the period (ms) of the status frame that provides the signal returned by getAbsoluteEncoderPosition().- Returns:
- The period in milliseconds
-