Class A301

java.lang.Object
com.revrobotics.spark.A301
All Implemented Interfaces:
org.wpilib.hardware.motor.MotorController

public class A301 extends Object implements org.wpilib.hardware.motor.MotorController
  • Field Details

  • Constructor Details

    • A301

      public A301(int busId)
      Create a new object to control a FIRST A301 motor

      The 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

      public String getFirmwareString()
      Get the firmware version of the FIRST A301 as a string.
      Returns:
      String Human readable firmware version string
    • hasActiveFault

      public Signal<Boolean> hasActiveFault()
      Get whether the A301 has one or more active faults.
      Returns:
      true if there is an active fault
      See Also:
    • hasStickyFault

      public Signal<Boolean> hasStickyFault()
      Get whether the A301 has one or more sticky faults.
      Returns:
      true if there is a sticky fault
      See Also:
    • hasActiveWarning

      public Signal<Boolean> hasActiveWarning()
      Get whether the A301 has one or more active warnings.
      Returns:
      true if there is an active warning
      See Also:
    • hasStickyWarning

      public Signal<Boolean> hasStickyWarning()
      Get whether the A301 has one or more sticky warnings.
      Returns:
      true if there is a sticky warning
      See Also:
    • getFaults

      public Signal<SparkBase.Faults> 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

      public Signal<SparkBase.Faults> 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

      public Signal<SparkBase.Warnings> 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

      public Signal<SparkBase.Warnings> 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

      public REVLibError clearFaults()
      Clears all sticky faults.
      Returns:
      REVLibError.kOk if successful
    • getBusVoltage

      public Signal<Double> getBusVoltage()
      Returns:
      The voltage fed into the motor controller.
    • getAppliedOutput

      public Signal<Double> getAppliedOutput()
      Returns:
      The motor controller's applied output duty cycle.
    • getOutputCurrent

      public Signal<Double> getOutputCurrent()
      Returns:
      The motor controller's output current in Amps.
    • getMotorTemperature

      public Signal<Double> getMotorTemperature()
      Returns:
      The motor temperature in Celsius.
    • getRelativeEncoderPosition

      public Signal<Double> getRelativeEncoderPosition()
    • getEncoderVelocity

      public Signal<Double> getEncoderVelocity()
    • getAbsoluteEncoderPosition

      public Signal<Double> getAbsoluteEncoderPosition()
    • setVelocity

      public REVLibError setVelocity(double velocity)
      Sets the velocity of the A301.
      Parameters:
      velocity - The velocity (in RPM) to set
      Returns:
      REVLibError.kOk if successful
    • setPosition

      public REVLibError setPosition(double position)
      Sets the relative position of the A301.
      Parameters:
      position - The relative position (in Rotations) to set
      Returns:
      REVLibError.kOk if successful
    • setAbsolutePosition

      public REVLibError setAbsolutePosition(double absPosition, boolean isContinuous)
      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 set
      isContinuous - Should the position flip when it reaches an endpoint?
      Returns:
      REVLibError.kOk if successful
    • setCurrent

      public REVLibError setCurrent(double current)
      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:
      setThrottle in interface org.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:
      getThrottle in interface org.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:
      setVoltage in interface org.wpilib.hardware.motor.MotorController
      Parameters:
      outputVolts - The voltage to output.
    • setInverted

      @Deprecated public void setInverted(boolean isInverted)
      Deprecated.
      Common interface for inverting direction of a speed controller.
      Specified by:
      setInverted in interface org.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:
      getInverted in interface org.wpilib.hardware.motor.MotorController
      Returns:
      The state of inversion, true is inverted.
    • disable

      public void disable()
      Common interface for disabling a motor.
      Specified by:
      disable in interface org.wpilib.hardware.motor.MotorController