yarp-devices
|
Representation of a CiA 402 state machine controller. More...
#include <DriveStatusMachine.hpp>
Public Types | |
using | word_t = std::bitset< 16 > |
Fixed-size sequence of 16 bits. | |
Public Member Functions | |
DriveStatusMachine (ReceivePdo *rpdo, double timeout) | |
Constructor, registers RPDO handle. | |
void | configureRpdo (ReceivePdo *rpdo) |
Configure RPDO handle. | |
bool | update (std::uint16_t statusword) |
Notify observers on a drive state change, if applicable. | |
void | reset () |
Reset internally stored state. | |
word_t | controlword () const |
Retrieve stored controlword. | |
bool | controlword (const word_t &controlbits) |
Send command via object 6040h and update stored controlword. | |
word_t | statusword () const |
Retrieve stored statusword. | |
DriveState | getCurrentState () const |
Parse stored bit representation of a statusword into a DriveState enumerator. | |
bool | requestTransition (DriveTransition transition) |
Request given drive transition via object 6040h (blocking), update stored controlword. | |
bool | requestState (DriveState goalState) |
Request given drive state via object 6040h (blocking), update stored controlword. | |
bool | awaitState (DriveState goalState) |
Await until drive reaches given state, with timeout. | |
Static Public Member Functions | |
static DriveState | parseStatusword (std::uint16_t statusword) |
Parse bit representation into a DriveState enumerator. | |
Private Attributes | |
word_t | _controlword |
word_t | _statusword |
ReceivePdo * | rpdo |
StateObserver | stateObserver |
std::mutex | stateMutex |
Manages internally a bit representation for both controlword (object 6040h) and statusword (object 6041h). This class hardcodes a list of allowed state transitions (should cover all of CiA 402 standard). Also, it supports a subset of state requests: it knows how to traverse the DriveState::SWITCH_ON_DISABLED to DriveState::OPERATION_ENABLED chain in both directions, and DriveState::QUICK_STOP_ACTIVE to DriveState::SWITCH_ON_DISABLED. Fault resets as well as quick stop transitions must be requested individually.