fastcat 0.13.15
C++ EtherCAT Device Command & Control Library
Loading...
Searching...
No Matches
Classes | Public Member Functions | List of all members
fastcat::Manager Class Reference

Fastcat::Manager is the main application interface to manage all fastcat devices. More...

#include "manager.h"

Public Member Functions

 Manager ()
 
 ~Manager ()
 
void Shutdown ()
 Shutdown the bus and joins all threads.
 
bool ConfigFromYaml (const YAML::Node &node, double external_time=-1)
 Method that accepts a fastcat topology yaml and intializes bus.
 
bool CreateConfigFromYaml (const YAML::Node &node, double external_time=-1)
 Parses YAML configuration and creates device objects (no hardware init)
 
bool InitHardware ()
 Initializes EtherCAT hardware (executes deferred jsd_init calls)
 
bool Process (double external_time=-1)
 Updates synchronous PDO and background async SDO requests.
 
void QueueCommand (DeviceCmd &cmd)
 Interface to command devices on the bus.
 
std::vector< DeviceState > GetDeviceStates ()
 Returns list of device states.
 
std::vector< std::shared_ptr< const DeviceState > > GetDeviceStatePointers ()
 Returns list of device state pointers.
 
double GetTargetLoopRate ()
 Public getter to the YAML target_loop_rate_hz parameter.
 
bool IsFaulted ()
 Public getter retrieve fault status.
 
bool RecoverBus (std::string ifname)
 Attempts to recover a faulty JSD bus by name.
 
bool ExecuteDeviceReset (std::string device_name)
 Triggers a single device to reset.
 
bool ExecuteDeviceFault (std::string device_name)
 Triggers a single device to fault.
 
void ExecuteAllDeviceResets ()
 Triggers all devices to Reset.
 
void ExecuteAllDeviceFaults ()
 Triggers all devices to Fault.
 
bool IsSdoResponseQueueEmpty ()
 checks if the SdoResponse Queue is empty
 
bool PopSdoResponseQueue (SdoResponse &res)
 get the result of a background SDO operation
 
bool GetActuatorParams (const std::string &name, fastcat::Actuator::ActuatorParams &param)
 get actuator parameters
 
void GetDeviceNamesByType (std::vector< std::string > &, fastcat::DeviceStateType)
 names of actuator devices
 
void SetExplicitInterpolationAlgorithmCubic ()
 Set interpolation algorithm to use 3rd order cubic interpolation between knot points for all actuators.
 
void SetExplicitInterpolationAlgorithmLinear ()
 Set interpolation algorithm to use 1st order linear interpolation between knot points for both position and velocity for all actuators.
 
void SetExplicitInterpolationTimestampSourceCspMessage ()
 Set interpolation algorithm to use the timestamp in the CSP message generated by the calling module for determining time of interpolation knot-points, which accounts for latency in message passing.
 
void SetExplicitInterpolationTimestampSourceClock ()
 Set interpolation algorithm to use the timestamp when the CSP message was received according to fastcat's clock; this mode of interpolation does not account for latency in message passing.
 
bool SetExplicitInterpolationCyclesDelay (size_t delay)
 Set number of cycles of the calling module to delay the onset of explicit interpolation, e.g. if delay is set to 3, fastcast will wait until 4 messages accumulate in the buffer before beginning motion profile. A larger buffer provides a greater margin against motion setpoints not being received fast enough as motion profile is executing, which may happen due to process jitter or message passing latency.
 
bool SetInterpolationCyclesStale (size_t cycles)
 CSP interpolation will transition to a holding state if it has not received a CSP message within the provided number of fastcat process cycles.
 

Detailed Description

Fastcat::Manager is the main application interface to manage all fastcat devices.

Constructor & Destructor Documentation

◆ Manager()

fastcat::Manager::Manager ( )

◆ ~Manager()

fastcat::Manager::~Manager ( )

Member Function Documentation

◆ ConfigFromYaml()

bool fastcat::Manager::ConfigFromYaml ( const YAML::Node &  node,
double  external_time = -1 
)

Method that accepts a fastcat topology yaml and intializes bus.

Returns
true on successful initialization. If false, application should quit.

◆ CreateConfigFromYaml()

bool fastcat::Manager::CreateConfigFromYaml ( const YAML::Node &  node,
double  external_time = -1 
)

Parses YAML configuration and creates device objects (no hardware init)

Returns
true on successful configuration. If false, application should quit.
Here is the call graph for this function:

◆ ExecuteAllDeviceFaults()

void fastcat::Manager::ExecuteAllDeviceFaults ( )

Triggers all devices to Fault.

This function loops over all devices in the topology and calls their DeviceBase::Fault() Method. An example usage is a soft-stop GUI button that can be used to arrest motion.

Returns
void

◆ ExecuteAllDeviceResets()

void fastcat::Manager::ExecuteAllDeviceResets ( )

Triggers all devices to Reset.

This function loops over all devices in the topology and calls their DeviceBase::Reset() Method.

Returns
void

◆ ExecuteDeviceFault()

bool fastcat::Manager::ExecuteDeviceFault ( std::string  device_name)

Triggers a single device to fault.

Parameters
device_namethe name of the device to fault, calls its Fault() method
Returns
true if the device exists, false if device_name is invalid.

◆ ExecuteDeviceReset()

bool fastcat::Manager::ExecuteDeviceReset ( std::string  device_name)

Triggers a single device to reset.

Parameters
device_namethe name of the device to reset, calls its Reset() method
Returns
true if the device exists, false if device_name is invalid.

◆ GetActuatorParams()

bool fastcat::Manager::GetActuatorParams ( const std::string &  name,
fastcat::Actuator::ActuatorParams param 
)

get actuator parameters

Returns
true if the return reference 'parameters' is valid

◆ GetDeviceNamesByType()

void fastcat::Manager::GetDeviceNamesByType ( std::vector< std::string > &  names,
fastcat::DeviceStateType  device_state_type 
)

names of actuator devices

◆ GetDeviceStatePointers()

std::vector< std::shared_ptr< const fastcat::DeviceState > > fastcat::Manager::GetDeviceStatePointers ( )

Returns list of device state pointers.

Provided for potential optimization. GetDeviceStates() generally performs better. This function is not intended to be called in a realtime process loop because it dynamically allocates memory to hold a vector of device state pointers.

Returns
device states

◆ GetDeviceStates()

std::vector< fastcat::DeviceState > fastcat::Manager::GetDeviceStates ( )

Returns list of device states.

Returns
device states

◆ GetTargetLoopRate()

double fastcat::Manager::GetTargetLoopRate ( )

Public getter to the YAML target_loop_rate_hz parameter.

Returns
loop rate in hz

◆ InitHardware()

bool fastcat::Manager::InitHardware ( )

Initializes EtherCAT hardware (executes deferred jsd_init calls)

Returns
true on successful hardware initialization. If false, application should quit.

◆ IsFaulted()

bool fastcat::Manager::IsFaulted ( )

Public getter retrieve fault status.

Returns
true if bus is faulted

◆ IsSdoResponseQueueEmpty()

bool fastcat::Manager::IsSdoResponseQueueEmpty ( )

checks if the SdoResponse Queue is empty

Returns
if queue is empty

◆ PopSdoResponseQueue()

bool fastcat::Manager::PopSdoResponseQueue ( SdoResponse &  res)

get the result of a background SDO operation

If the SDO Response queue contains any responses, this function pops the oldest value and returns it to the application.

Returns
true if the return reference 'res' is valid

◆ Process()

bool fastcat::Manager::Process ( double  external_time = -1)

Updates synchronous PDO and background async SDO requests.

Process() proceeds by

  1. Triggers PDO Read on EtherCAT bus
  2. Reads all JSD devices into the manager
  3. Reads all Fastcat devices (including observed device state propagation)
  4. Calls DeviceBase::Process() on Fastcat Devices, checking for faults and SDO requests
  5. Writes Device Commands (Includes User commands and Fastcat Device Commands)
  6. Calls Process() on JSD devices, checking for faults
  7. Triggers PDO Write on EtherCAT bus

    Note: For best performance, the application should call the Manager::Process() function at the same frequency as the input YAML field target_loop_rate_hz. This parameter is needed by certain devices for profiling and filtering.

Parameters
external_timeSupply an external time if desired, otherwise defaults to jsd supplied system time
Returns
Return true if bus is not faulted, otherwise a bus fault is active.

◆ QueueCommand()

void fastcat::Manager::QueueCommand ( DeviceCmd &  cmd)

Interface to command devices on the bus.

Commands each have a name field and that name is used to dispatch the command to the right device. If the provided name is not found on the loaded bus topology, a warning message is printed to stdout but no faults are triggered.

Returns
void

◆ RecoverBus()

bool fastcat::Manager::RecoverBus ( std::string  ifname)

Attempts to recover a faulty JSD bus by name.

A bus fault example is spurious Working Counter (WKC) error, or perhaps an intended power cycle of a configured EtherCAT slave.

Parameters
ifnamethe name of the JSD bus configured in the input topology YAML
Returns
true if bus ifname exists, does not indicate the error is fixed.

◆ SetExplicitInterpolationAlgorithmCubic()

void fastcat::Manager::SetExplicitInterpolationAlgorithmCubic ( )

Set interpolation algorithm to use 3rd order cubic interpolation between knot points for all actuators.

◆ SetExplicitInterpolationAlgorithmLinear()

void fastcat::Manager::SetExplicitInterpolationAlgorithmLinear ( )

Set interpolation algorithm to use 1st order linear interpolation between knot points for both position and velocity for all actuators.

◆ SetExplicitInterpolationCyclesDelay()

bool fastcat::Manager::SetExplicitInterpolationCyclesDelay ( size_t  delay)

Set number of cycles of the calling module to delay the onset of explicit interpolation, e.g. if delay is set to 3, fastcast will wait until 4 messages accumulate in the buffer before beginning motion profile. A larger buffer provides a greater margin against motion setpoints not being received fast enough as motion profile is executing, which may happen due to process jitter or message passing latency.

◆ SetExplicitInterpolationTimestampSourceClock()

void fastcat::Manager::SetExplicitInterpolationTimestampSourceClock ( )

Set interpolation algorithm to use the timestamp when the CSP message was received according to fastcat's clock; this mode of interpolation does not account for latency in message passing.

◆ SetExplicitInterpolationTimestampSourceCspMessage()

void fastcat::Manager::SetExplicitInterpolationTimestampSourceCspMessage ( )

Set interpolation algorithm to use the timestamp in the CSP message generated by the calling module for determining time of interpolation knot-points, which accounts for latency in message passing.

◆ SetInterpolationCyclesStale()

bool fastcat::Manager::SetInterpolationCyclesStale ( size_t  cycles)

CSP interpolation will transition to a holding state if it has not received a CSP message within the provided number of fastcat process cycles.

◆ Shutdown()

void fastcat::Manager::Shutdown ( )

Shutdown the bus and joins all threads.

Also Writes Actuator positions to file if applicable.

Returns
void

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