REVLib - C++
first::a301::A301 Class Reference

#include <A301.h>

Inheritance diagram for first::a301::A301:

Classes

struct  Faults
 
struct  FirmwareVersion
 
struct  Warnings
 

Public Types

enum class  GearboxRPM { kRPM_Unknown , kRPM_215 , kRPM_500 }
 

Public Member Functions

 A301 (int busId, int deviceId=defaultDeviceId)
 
 ~A301 () override
 
int GetBusId () const
 
int GetDeviceId () const
 
FirmwareVersion GetFirmwareVersion () const
 
std::string GetFirmwareString () const
 
rev::util::Signal< bool > HasActiveFault () const
 
rev::util::Signal< bool > HasStickyFault () const
 
rev::util::Signal< bool > HasActiveWarning () const
 
rev::util::Signal< bool > HasStickyWarning () const
 
rev::util::Signal< FaultsGetFaults () const
 
rev::util::Signal< FaultsGetStickyFaults () const
 
rev::util::Signal< WarningsGetWarnings () const
 
rev::util::Signal< WarningsGetStickyWarnings () const
 
rev::util::Signal< double > GetBusVoltage () const
 
rev::util::Signal< double > GetAppliedOutput () const
 
rev::util::Signal< double > GetMotorCurrent () const
 
rev::util::Signal< double > GetMotorTemperature () const
 
rev::util::Signal< GearboxRPMGetGearboxRPM () const
 
rev::util::Signal< double > GetRelativeEncoderPosition () const
 
rev::util::Signal< double > GetEncoderVelocity () const
 
rev::util::Signal< double > GetAbsoluteEncoderPosition () const
 
rev::REVLibError SetRelativeEncoderPosition (double position)
 
rev::REVLibError SetAbsoluteEncoderPosition (double position)
 
rev::REVLibError ClearFaults ()
 
rev::REVLibError SetVelocity (double velocity)
 
rev::REVLibError SetRelativePosition (double position)
 
rev::REVLibError SetRelativePositionWithSpeed (double position, double speed)
 
rev::REVLibError SetAbsolutePosition (double absPosition)
 
rev::REVLibError SetAbsolutePositionWithSpeed (double absPosition, double speed)
 
rev::REVLibError EnableAbsolutePositionContinuousInput ()
 
rev::REVLibError DisableAbsolutePositionContinuousInput ()
 
bool IsAbsolutePositionContinuousInputEnabled () const
 
rev::REVLibError SetCurrent (double current)
 
void SetThrottle (double throttle) override
 
double GetThrottle () const override
 
void SetVoltage (wpi::units::volt_t output) override
 
void SetInverted (bool isInverted) override
 
bool GetInverted () const override
 
void Disable () override
 
A301FaultsPeriodMs (int period_ms)
 
int GetFaultsPeriodMs () const
 
A301WarningsPeriodMs (int period_ms)
 
int GetWarningsPeriodMs () const
 
A301BusVoltagePeriodMs (int period_ms)
 
int GetBusVoltagePeriodMs () const
 
A301AppliedOutputPeriodMs (int period_ms)
 
int GetAppliedOutputPeriodMs () const
 
A301MotorCurrentPeriodMs (int period_ms)
 
int GetMotorCurrentPeriodMs () const
 
A301MotorTemperaturePeriodMs (int period_ms)
 
int GetMotorTemperaturePeriodMs () const
 
A301RelativeEncoderPositionPeriodMs (int period_ms)
 
int GetRelativeEncoderPositionPeriodMs () const
 
A301EncoderVelocityPeriodMs (int period_ms)
 
int GetEncoderVelocityPeriodMs () const
 
A301AbsoluteEncoderPositionPeriodMs (int period_ms)
 
int GetAbsoluteEncoderPositionPeriodMs () const
 

Member Enumeration Documentation

◆ GearboxRPM

enum class first::a301::A301::GearboxRPM
strong
Enumerator
kRPM_Unknown 
kRPM_215 
kRPM_500 

Constructor & Destructor Documentation

◆ A301()

A301::A301 ( int  busId,
int  deviceId = defaultDeviceId 
)
explicit

Create a new object to control a FIRST A301 motor

NOTE: If busId indicates a Motioncore bus, the device ID will be auto-detected and deviceId will be ignored.

Parameters
busIdThe CAN bus ID this device will be on.
deviceIdThe device ID.

◆ ~A301()

A301::~A301 ( )
overridedefault

Closes the A301

Member Function Documentation

◆ GetBusId()

int A301::GetBusId ( ) const

Get the configured CAN Bus ID of the FIRST A301.

Returns
int CAN bus ID

◆ GetDeviceId()

int A301::GetDeviceId ( ) const

Get the configured Device ID of the FIRST A301.

Returns
int device ID

◆ GetFirmwareVersion()

A301::FirmwareVersion A301::GetFirmwareVersion ( ) const

Get the firmware version of the FIRST A301.

Returns
FirmwareVersion

◆ GetFirmwareString()

std::string A301::GetFirmwareString ( ) const

Get the firmware version of the FIRST A301 as a string.

Returns
std::string Human readable firmware version string

◆ HasActiveFault()

Signal< bool > A301::HasActiveFault ( ) const

Get whether the A301 has one or more active faults.

Returns
Signal containing true if there is an active fault
See also
GetFaults()

◆ HasStickyFault()

Signal< bool > A301::HasStickyFault ( ) const

Get whether the A301 has one or more sticky faults.

Returns
Signal containing true if there is a sticky fault
See also
GetStickyFaults()

◆ HasActiveWarning()

Signal< bool > A301::HasActiveWarning ( ) const

Get whether the A301 has one or more active warnings.

Returns
Signal containing true if there is an active warning
See also
GetWarnings()

◆ HasStickyWarning()

Signal< bool > A301::HasStickyWarning ( ) const

Get whether the A301 has one or more sticky warnings.

Returns
Signal containing true if there is a sticky warning
See also
GetStickyWarnings()

◆ GetFaults()

Signal< A301::Faults > A301::GetFaults ( ) const

Get the active faults that are currently present on the A301. Faults are fatal errors that prevent the motor from running.

Returns
Signal containing each fault and their active value

◆ GetStickyFaults()

Signal< A301::Faults > A301::GetStickyFaults ( ) const

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 A301::ClearFaults().

Returns
Signal containing each fault and their sticky value

◆ GetWarnings()

Signal< A301::Warnings > A301::GetWarnings ( ) const

Get the active warnings that are currently present on the A301. Warnings are non-fatal errors.

Returns
Signal containing each warning and their active value

◆ GetStickyWarnings()

Signal< A301::Warnings > A301::GetStickyWarnings ( ) const

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 A301::clearFaults().

Returns
Signal containing each warning and their sticky value

◆ GetBusVoltage()

Signal< double > A301::GetBusVoltage ( ) const

Returns the voltage fed into the A301.

Returns
Signal containing the bus voltage

◆ GetAppliedOutput()

Signal< double > A301::GetAppliedOutput ( ) const

Returns the A301's output duty cycle.

Returns
Signal containing the applied output duty cycle

◆ GetMotorCurrent()

Signal< double > A301::GetMotorCurrent ( ) const

Returns A301's motor current in Amps.

Returns
Signal containing the motor current in Amps

◆ GetMotorTemperature()

Signal< double > A301::GetMotorTemperature ( ) const

Returns the motor temperature in Celsius.

Returns
Signal containing the motor temperature in Celsius

◆ GetGearboxRPM()

Signal< A301::GearboxRPM > A301::GetGearboxRPM ( ) const

Returns the RPM of the A301's attached gearbox.

Returns
Signal containing the gearbox RPM (
See also
GearboxRPM)

◆ GetRelativeEncoderPosition()

Signal< double > A301::GetRelativeEncoderPosition ( ) const

Get the position of the motor. This returns the native units of 'rotations'.

Returns
Signal containing the number of rotations of the motor

◆ GetEncoderVelocity()

Signal< double > A301::GetEncoderVelocity ( ) const

Get the velocity of the motor. This returns the native units of 'RPM'.

Returns
Signal containing the RPM of the motor

◆ GetAbsoluteEncoderPosition()

Signal< double > A301::GetAbsoluteEncoderPosition ( ) const

Get the absolute position of the motor. This returns the native units of 'rotations'.

Returns
Signal containing the number of rotations of the motor

◆ SetRelativeEncoderPosition()

rev::REVLibError A301::SetRelativeEncoderPosition ( double  position)

Set the position of the relative encoder.

Parameters
positionNumber of rotations of the motor
Returns
REVLibError::kOk if successful

◆ SetAbsoluteEncoderPosition()

rev::REVLibError A301::SetAbsoluteEncoderPosition ( double  position)

Set the position of the absolute encoder.

Parameters
positionNumber of rotations of the motor
Returns
REVLibError::kOk if successful

◆ ClearFaults()

rev::REVLibError A301::ClearFaults ( )

Clears all sticky faults.

◆ SetVelocity()

rev::REVLibError A301::SetVelocity ( double  velocity)

Sets the velocity of the A301.

Parameters
velocityThe velocity (in RPM) to set
Returns
REVLibError::kOk if successful

◆ SetRelativePosition()

rev::REVLibError A301::SetRelativePosition ( double  position)

Sets the relative position of the A301 (with maximum speed).

Parameters
positionThe relative position (in Rotations) to set
Returns
REVLibError::kOk if successful

◆ SetRelativePositionWithSpeed()

rev::REVLibError A301::SetRelativePositionWithSpeed ( double  position,
double  speed 
)

Sets the relative position of the A301 with a specific speed.

Parameters
positionThe relative position (in Rotations) to set
speedThe speed to approach the position at (in RPM)
Returns
REVLibError::kOk if successful

◆ SetAbsolutePosition()

rev::REVLibError A301::SetAbsolutePosition ( double  absPosition)

Sets the absolute position of the A301 (with maximum speed).

Parameters
absPositionThe absolute position (-0.5 to 0.5) to set
Returns
REVLibError::kOk if successful

◆ SetAbsolutePositionWithSpeed()

rev::REVLibError A301::SetAbsolutePositionWithSpeed ( double  absPosition,
double  speed 
)

Sets the absolute position of the A301 with a specific speed.

Setting speed <= 0 will apply maximum speed)

Parameters
absPositionThe absolute position (-0.5 to 0.5) to set
speedThe speed to approach the position at (in RPM)
Returns
REVLibError::kOk if successful

◆ EnableAbsolutePositionContinuousInput()

rev::REVLibError A301::EnableAbsolutePositionContinuousInput ( )

Enables continuous input for absolute position control.

Returns
REVLibError::kOk if successful

◆ DisableAbsolutePositionContinuousInput()

rev::REVLibError A301::DisableAbsolutePositionContinuousInput ( )

Disables continuous input for absolute position control.

Returns
REVLibError::kOk if successful

◆ IsAbsolutePositionContinuousInputEnabled()

bool A301::IsAbsolutePositionContinuousInputEnabled ( ) const

Queries the continuous input for absolute position control.

Returns
true if continuous input is enabled.

◆ SetCurrent()

rev::REVLibError A301::SetCurrent ( double  current)

Sets the motor current of the A301.

Parameters
currentThe current (in Amps) to drive the motor at
Returns
REVLibError::kOk if successful

◆ SetThrottle()

void A301::SetThrottle ( double  throttle)
override

Sets the throttle of the motor controller.

Parameters
throttleThe throttle where -1.0 indicates full reverse and 1.0 indicates full forward.

◆ GetThrottle()

double A301::GetThrottle ( ) const
override

Gets the throttle of the motor controller.

Returns
The throttle where -1.0 represents full reverse and 1.0 represents full forward.

◆ SetVoltage()

void A301::SetVoltage ( wpi::units::volt_t  output)
override

Sets the voltage output of the SpeedController. The behavior of this call differs slightly from the WPILib documentation 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.

Parameters
outputThe voltage to output. (-12.0 V to 12.0 V)

◆ SetInverted()

void A301::SetInverted ( bool  isInverted)
override

Common interface for setting the inversion state of the motor controller.

Parameters
isInvertedThe inversion state.

◆ GetInverted()

bool A301::GetInverted ( ) const
override

Common interface for getting the inversion state of the motor controller.

Returns
The inversion state.

◆ Disable()

void A301::Disable ( )
override

Common interface for disabling a motor.

◆ FaultsPeriodMs()

first::a301::A301 & A301::FaultsPeriodMs ( int  period_ms)

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_msThe period in milliseconds
Returns
The modified A301 object for method chaining

◆ GetFaultsPeriodMs()

int A301::GetFaultsPeriodMs ( ) const

Get the period (ms) of the status frame that provides the signal returned by GetFaults() and GetStickyFaults().

Returns
The period in milliseconds

◆ WarningsPeriodMs()

first::a301::A301 & A301::WarningsPeriodMs ( int  period_ms)

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_msThe period in milliseconds
Returns
The modified A301 object for method chaining

◆ GetWarningsPeriodMs()

int A301::GetWarningsPeriodMs ( ) const

Get the period (ms) of the status frame that provides the signal returned by GetWarnings() and GetStickyWarnings().

Returns
The period in milliseconds

◆ BusVoltagePeriodMs()

first::a301::A301 & A301::BusVoltagePeriodMs ( int  period_ms)

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_msThe period in milliseconds
Returns
The modified A301 object for method chaining

◆ GetBusVoltagePeriodMs()

int A301::GetBusVoltagePeriodMs ( ) const

Get the period (ms) of the status frame that provides the signal returned by GetBusVoltage().

Returns
The period in milliseconds

◆ AppliedOutputPeriodMs()

first::a301::A301 & A301::AppliedOutputPeriodMs ( int  period_ms)

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_msThe period in milliseconds
Returns
The modified A301 object for method chaining

◆ GetAppliedOutputPeriodMs()

int A301::GetAppliedOutputPeriodMs ( ) const

Get the period (ms) of the status frame that provides the signal returned by GetAppliedOutput().

Returns
The period in milliseconds

◆ MotorCurrentPeriodMs()

first::a301::A301 & A301::MotorCurrentPeriodMs ( int  period_ms)

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_msThe period in milliseconds
Returns
The modified A301 object for method chaining

◆ GetMotorCurrentPeriodMs()

int A301::GetMotorCurrentPeriodMs ( ) const

Get the period (ms) of the status frame that provides the signal returned by GetMotorCurrent().

Returns
The period in milliseconds

◆ MotorTemperaturePeriodMs()

first::a301::A301 & A301::MotorTemperaturePeriodMs ( int  period_ms)

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_msThe period in milliseconds
Returns
The modified A301 object for method chaining

◆ GetMotorTemperaturePeriodMs()

int A301::GetMotorTemperaturePeriodMs ( ) const

Get the period (ms) of the status frame that provides the signal returned by GetMotorTemperature().

Returns
The period in milliseconds

◆ RelativeEncoderPositionPeriodMs()

first::a301::A301 & A301::RelativeEncoderPositionPeriodMs ( int  period_ms)

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_msThe period in milliseconds
Returns
The modified A301 object for method chaining

◆ GetRelativeEncoderPositionPeriodMs()

int A301::GetRelativeEncoderPositionPeriodMs ( ) const

Get the period (ms) of the status frame that provides the signal returned by GetRelativeEncoderPosition().

Returns
The period in milliseconds

◆ EncoderVelocityPeriodMs()

first::a301::A301 & A301::EncoderVelocityPeriodMs ( int  period_ms)

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_msThe period in milliseconds
Returns
The modified A301 object for method chaining

◆ GetEncoderVelocityPeriodMs()

int A301::GetEncoderVelocityPeriodMs ( ) const

Get the period (ms) of the status frame that provides the signal returned by GetEncoderVelocity().

Returns
The period in milliseconds

◆ AbsoluteEncoderPositionPeriodMs()

first::a301::A301 & A301::AbsoluteEncoderPositionPeriodMs ( int  period_ms)

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_msThe period in milliseconds
Returns
The modified A301 object for method chaining

◆ GetAbsoluteEncoderPositionPeriodMs()

int A301::GetAbsoluteEncoderPositionPeriodMs ( ) const

Get the period (ms) of the status frame that provides the signal returned by GetAbsoluteEncoderPosition().

Returns
The period in milliseconds

The documentation for this class was generated from the following files: