Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes
EthercatHardwareDiagnosticsPublisher Class Reference

Publishes EthercatHardware diagnostics. More...

#include <ethercat_hardware.h>

List of all members.

Public Member Functions

 EthercatHardwareDiagnosticsPublisher (ros::NodeHandle &node)
void initialize (const string &interface, unsigned int buffer_size, const std::vector< boost::shared_ptr< EthercatDevice > > &slaves, unsigned int num_ethercat_devices_, unsigned timeout, unsigned max_pd_retries)
 Initializes hardware publish.
void publish (const unsigned char *buffer, const EthercatHardwareDiagnostics &diagnostics)
 Triggers publishing of new diagnostics data.
void stop ()
 Stops publishing thread. May block.
 ~EthercatHardwareDiagnosticsPublisher ()

Private Member Functions

void diagnosticsThreadFunc ()
 Publishing thread main loop.
void publishDiagnostics ()
 Publishes diagnostics.

Static Private Member Functions

static void timingInformation (diagnostic_updater::DiagnosticStatusWrapper &status, const string &key, const accumulator_set< double, stats< tag::max, tag::mean > > &acc, double max)
 Helper function for converting timing for diagnostics.

Private Attributes

unsigned int buffer_size_
diagnostic_msgs::DiagnosticArray diagnostic_array_
EthercatHardwareDiagnostics diagnostics_
 Diagnostics information use by publish function.
unsigned char * diagnostics_buffer_
boost::condition_variable diagnostics_cond_
boost::mutex diagnostics_mutex_
 mutex protects all class data and cond variable
bool diagnostics_ready_
boost::thread diagnostics_thread_
EthernetInterfaceInfo ethernet_interface_info_
 Information about Ethernet interface used for EtherCAT communication.
string interface_
uint64_t last_dropped_packet_count_
 Count of dropped packets last diagnostics cycle.
ros::Time last_dropped_packet_time_
 Time last packet was dropped 0 otherwise. Used for warning about dropped packets.
unsigned max_pd_retries_
 Number of times (in a row) to retry sending process data (realtime data) before halting motors.
ros::NodeHandle node_
unsigned int num_ethercat_devices_
ros::Publisher publisher_
std::vector< boost::shared_ptr
< EthercatDevice > > 
slaves_
diagnostic_updater::DiagnosticStatusWrapper status_
unsigned timeout_
 Timeout controls how long EtherCAT driver waits for packet before declaring it as dropped.
vector< diagnostic_msgs::KeyValue > values_

Static Private Attributes

static const unsigned dropped_packet_warning_hold_time_ = 10
 Number of seconds since late dropped packet to keep warning.

Detailed Description

Publishes EthercatHardware diagnostics.

All the string formating used for creatign diagnostics is too slow to be run in the realtime thread. Instead, a copy of the raw diagnostics data is made and a separate thread does the string conversion and publishing. Previously, the diagnostics data used by publishing thread was contained in the EthercatHardware class. However, this allowed the publishing thread access to other non thread-safe data. This class keeps the diagnostics data used by the publish thread explicitly separate.

Definition at line 108 of file ethercat_hardware.h.


Constructor & Destructor Documentation

Definition at line 342 of file ethercat_hardware.cpp.

Definition at line 352 of file ethercat_hardware.cpp.


Member Function Documentation

Publishing thread main loop.

Waits for condition variable to start publishing internal data.

Definition at line 404 of file ethercat_hardware.cpp.

void EthercatHardwareDiagnosticsPublisher::initialize ( const string &  interface,
unsigned int  buffer_size,
const std::vector< boost::shared_ptr< EthercatDevice > > &  slaves,
unsigned int  num_ethercat_devices_,
unsigned  timeout,
unsigned  max_pd_retries 
)

Initializes hardware publish.

Parameters:
buffer_sizesize of proccess data buffer
numberof EtherCAT slave devices

Definition at line 357 of file ethercat_hardware.cpp.

void EthercatHardwareDiagnosticsPublisher::publish ( const unsigned char *  buffer,
const EthercatHardwareDiagnostics diagnostics 
)

Triggers publishing of new diagnostics data.

Makes copy of diagnostics data and triggers internal thread to started conversion and publish of data. This function will not block.

Definition at line 380 of file ethercat_hardware.cpp.

Publishes diagnostics.

Takes internally saved diagnostics data and converts to a ROS diagnostics status message. This function performs a lot of string formatting, so it is slow.

Definition at line 431 of file ethercat_hardware.cpp.

Stops publishing thread. May block.

Definition at line 397 of file ethercat_hardware.cpp.

void EthercatHardwareDiagnosticsPublisher::timingInformation ( diagnostic_updater::DiagnosticStatusWrapper status,
const string &  key,
const accumulator_set< double, stats< tag::max, tag::mean > > &  acc,
double  max 
) [static, private]

Helper function for converting timing for diagnostics.

Definition at line 420 of file ethercat_hardware.cpp.


Member Data Documentation

Definition at line 178 of file ethercat_hardware.h.

diagnostic_msgs::DiagnosticArray EthercatHardwareDiagnosticsPublisher::diagnostic_array_ [private]

Definition at line 195 of file ethercat_hardware.h.

Diagnostics information use by publish function.

Definition at line 176 of file ethercat_hardware.h.

Definition at line 177 of file ethercat_hardware.h.

boost::condition_variable EthercatHardwareDiagnosticsPublisher::diagnostics_cond_ [private]

Definition at line 170 of file ethercat_hardware.h.

mutex protects all class data and cond variable

Definition at line 169 of file ethercat_hardware.h.

Definition at line 171 of file ethercat_hardware.h.

Definition at line 172 of file ethercat_hardware.h.

Number of seconds since late dropped packet to keep warning.

Definition at line 193 of file ethercat_hardware.h.

Information about Ethernet interface used for EtherCAT communication.

Definition at line 197 of file ethercat_hardware.h.

Definition at line 181 of file ethercat_hardware.h.

Count of dropped packets last diagnostics cycle.

Definition at line 189 of file ethercat_hardware.h.

Time last packet was dropped 0 otherwise. Used for warning about dropped packets.

Definition at line 191 of file ethercat_hardware.h.

Number of times (in a row) to retry sending process data (realtime data) before halting motors.

Definition at line 186 of file ethercat_hardware.h.

Definition at line 167 of file ethercat_hardware.h.

Definition at line 180 of file ethercat_hardware.h.

Definition at line 174 of file ethercat_hardware.h.

std::vector<boost::shared_ptr<EthercatDevice> > EthercatHardwareDiagnosticsPublisher::slaves_ [private]

Definition at line 179 of file ethercat_hardware.h.

Definition at line 199 of file ethercat_hardware.h.

Timeout controls how long EtherCAT driver waits for packet before declaring it as dropped.

Definition at line 184 of file ethercat_hardware.h.

vector<diagnostic_msgs::KeyValue> EthercatHardwareDiagnosticsPublisher::values_ [private]

Definition at line 198 of file ethercat_hardware.h.


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


ethercat_hardware
Author(s): Rob Wheeler , Derek King
autogenerated on Fri Aug 28 2015 12:09:44