REVLib - C++
rev::servohub::ServoHub Class Reference

#include <ServoHub.h>

Inherits rev::servohub::ServoHubLowLevel.

Classes

struct  Faults
 
struct  Warnings
 

Public Types

enum class  ResetMode { kNoResetSafeParameters , kResetSafeParameters }
 
enum class  Bank { kBank0_2 = 0 , kBank3_5 = 1 }
 
- Public Types inherited from rev::servohub::ServoHubLowLevel
enum class  CommunicationMode { kNone = 0 , kCAN = 1 , kRS_485 = 2 }
 

Public Member Functions

 ServoHub (int busID, int deviceID)
 
 ~ServoHub () override
 
REVLibError Configure (ServoHubConfig &config, ResetMode resetMode=ResetMode::kNoResetSafeParameters)
 
REVLibError Configure (ServoHubConfig &config, rev::ResetMode resetMode=rev::ResetMode::kNoResetSafeParameters)
 
REVLibError ConfigureAsync (ServoHubConfig &config, ResetMode resetMode=ResetMode::kNoResetSafeParameters)
 
REVLibError ConfigureAsync (ServoHubConfig &config, rev::ResetMode resetMode=rev::ResetMode::kNoResetSafeParameters)
 
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
 
REVLibError ClearFaults ()
 
rev::util::Signal< double > GetDeviceVoltage () const
 
rev::util::Signal< double > GetDeviceCurrent () const
 
rev::util::Signal< double > GetServoVoltage () const
 
ServoChannelGetServoChannel (ServoChannel::ChannelId channelId)
 
REVLibError SetBankPulsePeriod (Bank bank, int pulsePeriod_us)
 
- Public Member Functions inherited from rev::servohub::ServoHubLowLevel
virtual ~ServoHubLowLevel ()
 
int GetBusId () const
 
int GetDeviceId () const
 
FirmwareVersion GetFirmwareVersion () const
 
std::string GetFirmwareVersionString () const
 
void SetPeriodicFrameTimeout (int timeout_ms)
 
REVLibError SetCANTimeout (int timeout_ms)
 
void SetCANMaxRetries (int numRetries)
 
void SetControlFramePeriodMs (int period_ms)
 
int GetControlFramePeriodMs () const
 
rev::util::Signal< PeriodicStatus0GetPeriodicStatus0 () const
 
rev::util::Signal< PeriodicStatus1GetPeriodicStatus1 () const
 
rev::util::Signal< PeriodicStatus2GetPeriodicStatus2 () const
 
rev::util::Signal< PeriodicStatus3GetPeriodicStatus3 () const
 
rev::util::Signal< PeriodicStatus4GetPeriodicStatus4 () const
 
void CreateSimFaultManager ()
 

Public Attributes

ServoHubConfigAccessor configAccessor
 

Friends

class ServoHubSim
 

Additional Inherited Members

- Protected Member Functions inherited from rev::servohub::ServoHubLowLevel
 ServoHubLowLevel (int busID, int deviceID)
 
- Protected Attributes inherited from rev::servohub::ServoHubLowLevel
void * m_servoHubHandle {nullptr}
 

Member Enumeration Documentation

◆ ResetMode

Enumerator
kNoResetSafeParameters 
kResetSafeParameters 

◆ Bank

enum class rev::servohub::ServoHub::Bank
strong
Enumerator
kBank0_2 
kBank3_5 

Constructor & Destructor Documentation

◆ ServoHub()

ServoHub::ServoHub ( int  busID,
int  deviceID 
)

Create a new object to control a ServoHub Servo Controller

Parameters
busIDThe CAN bus ID this device will be on.
deviceIDThe device ID.

◆ ~ServoHub()

ServoHub::~ServoHub ( )
override

Closes the ServoHub

Member Function Documentation

◆ Configure() [1/2]

REVLibError ServoHub::Configure ( ServoHubConfig config,
ResetMode  resetMode = ResetMode::kNoResetSafeParameters 
)

Set the configuration for the ServoHub.

If resetMode is ResetMode::kResetSafeParameters, this method will reset safe writable parameters to their default values before setting the given configuration.

Parameters
configThe desired ServoHub configuration
resetModeWhether to reset safe parameters before setting the configuration
Returns
REVLibError::kOk if successful
Deprecated:
Use Configure(ServoHubConfig&, rev::ResetMode) instead. This method will be removed in 2027.

◆ Configure() [2/2]

REVLibError ServoHub::Configure ( ServoHubConfig config,
rev::ResetMode  resetMode = rev::ResetMode::kNoResetSafeParameters 
)

Set the configuration for the ServoHub.

If resetMode is ResetMode::kResetSafeParameters, this method will reset safe writable parameters to their default values before setting the given configuration.

Parameters
configThe desired ServoHub configuration
resetModeWhether to reset safe parameters before setting the configuration
Returns
REVLibError::kOk if successful

◆ ConfigureAsync() [1/2]

REVLibError ServoHub::ConfigureAsync ( ServoHubConfig config,
ResetMode  resetMode = ResetMode::kNoResetSafeParameters 
)

Set the configuration for the ServoHub without waiting for a response.

If resetMode is ResetMode::kResetSafeParameters, this method will reset safe writable parameters to their default values before setting the given configuration.

NOTE: This method will immediately return REVLibError::kOk and the action will be done in the background. Any errors that occur will be reported to the driver station.

Parameters
configThe desired ServoHub configuration
resetModeWhether to reset safe parameters before setting the configuration
Returns
REVLibError::kOk
See also
Configure()
Deprecated:
Use ConfigureAsync(ServoHubConfig&, rev::ResetMode) instead. This method will be removed in 2027.

◆ ConfigureAsync() [2/2]

REVLibError ServoHub::ConfigureAsync ( ServoHubConfig config,
rev::ResetMode  resetMode = rev::ResetMode::kNoResetSafeParameters 
)

Set the configuration for the ServoHub without waiting for a response.

If resetMode is ResetMode::kResetSafeParameters, this method will reset safe writable parameters to their default values before setting the given configuration.

NOTE: This method will immediately return REVLibError::kOk and the action will be done in the background. Any errors that occur will be reported to the driver station.

Parameters
configThe desired ServoHub configuration
resetModeWhether to reset safe parameters before setting the configuration
Returns
REVLibError::kOk
See also
Configure()

◆ HasActiveFault()

Signal< bool > ServoHub::HasActiveFault ( ) const

Get whether the ServoHub has one or more active faults.

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

◆ HasStickyFault()

Signal< bool > ServoHub::HasStickyFault ( ) const

Get whether the ServoHub has one or more sticky faults.

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

◆ HasActiveWarning()

Signal< bool > ServoHub::HasActiveWarning ( ) const

Get whether the ServoHub has one or more active warnings.

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

◆ HasStickyWarning()

Signal< bool > ServoHub::HasStickyWarning ( ) const

Get whether the ServoHub has one or more sticky warnings.

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

◆ GetFaults()

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

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

Returns
Signal containing a struct with each fault and their active value

◆ GetStickyFaults()

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

Get the sticky faults that were present on the ServoHub 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 ServoHub::ClearFaults().

Returns
Signal containing a struct with each fault and their sticky value

◆ GetWarnings()

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

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

Returns
Signal containing a struct with each warning and their active value

◆ GetStickyWarnings()

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

Get the sticky warnings that were present on the ServoHub at one point since the sticky warnings were last cleared. Warnings are non-fatal errors.

Sticky warnings can be cleared with ServoHub::clearFaults().

Returns
Signal containing a struct with each warning and their sticky value

◆ ClearFaults()

REVLibError ServoHub::ClearFaults ( )

Clears all non-sticky faults.

Sticky faults must be cleared by resetting the motor controller.

◆ GetDeviceVoltage()

Signal< double > ServoHub::GetDeviceVoltage ( ) const
Returns
Signal containing the voltage fed into the servo controller.

◆ GetDeviceCurrent()

Signal< double > ServoHub::GetDeviceCurrent ( ) const
Returns
Signal containing the servo controller's output current in Amps.

◆ GetServoVoltage()

Signal< double > ServoHub::GetServoVoltage ( ) const
Returns
Signal containing the voltage fed to the actual servos.

◆ GetServoChannel()

ServoChannel & ServoHub::GetServoChannel ( ServoChannel::ChannelId  channelId)

Returns an object to control a specific servo channel.

Parameters
channelIdThe specific servo channel to get
Returns
The specified ServoChannel

◆ SetBankPulsePeriod()

REVLibError ServoHub::SetBankPulsePeriod ( Bank  bank,
int  pulsePeriod_us 
)

Set the Pulse Period for servo channels 0-2 or servo channels 3-5.

Parameters
bankThe bank of channels (0-2 or 3-5) to set
pulsePeriod_usThe pulse period in microseconds
Returns
REVLibError::kOk if successful

Friends And Related Function Documentation

◆ ServoHubSim

friend class ServoHubSim
friend

Member Data Documentation

◆ configAccessor

ServoHubConfigAccessor rev::servohub::ServoHub::configAccessor

Accessor for ServoHub parameter values. This object contains fields and methods to retrieve parameters that have been applied to the device. To set parameters, see ServoHubConfig and ServoHub::Configure().

NOTE: This uses calls that are blocking to retrieve parameters and should be used infrequently.


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