Publishes EthercatHardware diagnostics. More...
#include <ethercat_hardware.h>
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. More... | |
void | publish (const unsigned char *buffer, const EthercatHardwareDiagnostics &diagnostics) |
Triggers publishing of new diagnostics data. More... | |
void | stop () |
Stops publishing thread. May block. More... | |
~EthercatHardwareDiagnosticsPublisher () | |
Private Member Functions | |
void | diagnosticsThreadFunc () |
Publishing thread main loop. More... | |
void | publishDiagnostics () |
Publishes diagnostics. More... | |
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. More... | |
Private Attributes | |
unsigned int | buffer_size_ |
diagnostic_msgs::DiagnosticArray | diagnostic_array_ |
EthercatHardwareDiagnostics | diagnostics_ |
Diagnostics information use by publish function. More... | |
unsigned char * | diagnostics_buffer_ |
boost::condition_variable | diagnostics_cond_ |
boost::mutex | diagnostics_mutex_ |
mutex protects all class data and cond variable More... | |
bool | diagnostics_ready_ |
boost::thread | diagnostics_thread_ |
EthernetInterfaceInfo | ethernet_interface_info_ |
Information about Ethernet interface used for EtherCAT communication. More... | |
string | interface_ |
uint64_t | last_dropped_packet_count_ |
Count of dropped packets last diagnostics cycle. More... | |
ros::Time | last_dropped_packet_time_ |
Time last packet was dropped 0 otherwise. Used for warning about dropped packets. More... | |
unsigned | max_pd_retries_ |
Number of times (in a row) to retry sending process data (realtime data) before halting motors. More... | |
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. More... | |
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. More... | |
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.
EthercatHardwareDiagnosticsPublisher::EthercatHardwareDiagnosticsPublisher | ( | ros::NodeHandle & | node | ) |
Definition at line 342 of file ethercat_hardware.cpp.
EthercatHardwareDiagnosticsPublisher::~EthercatHardwareDiagnosticsPublisher | ( | ) |
Definition at line 352 of file ethercat_hardware.cpp.
|
private |
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.
buffer_size | size of proccess data buffer |
number | of 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.
|
private |
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.
void EthercatHardwareDiagnosticsPublisher::stop | ( | ) |
Stops publishing thread. May block.
Definition at line 397 of file ethercat_hardware.cpp.
|
staticprivate |
Helper function for converting timing for diagnostics.
Definition at line 420 of file ethercat_hardware.cpp.
|
private |
Definition at line 178 of file ethercat_hardware.h.
|
private |
Definition at line 195 of file ethercat_hardware.h.
|
private |
Diagnostics information use by publish function.
Definition at line 176 of file ethercat_hardware.h.
|
private |
Definition at line 177 of file ethercat_hardware.h.
|
private |
Definition at line 170 of file ethercat_hardware.h.
|
private |
mutex protects all class data and cond variable
Definition at line 169 of file ethercat_hardware.h.
|
private |
Definition at line 171 of file ethercat_hardware.h.
|
private |
Definition at line 172 of file ethercat_hardware.h.
|
staticprivate |
Number of seconds since late dropped packet to keep warning.
Definition at line 193 of file ethercat_hardware.h.
|
private |
Information about Ethernet interface used for EtherCAT communication.
Definition at line 197 of file ethercat_hardware.h.
|
private |
Definition at line 181 of file ethercat_hardware.h.
|
private |
Count of dropped packets last diagnostics cycle.
Definition at line 189 of file ethercat_hardware.h.
|
private |
Time last packet was dropped 0 otherwise. Used for warning about dropped packets.
Definition at line 191 of file ethercat_hardware.h.
|
private |
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.
|
private |
Definition at line 167 of file ethercat_hardware.h.
|
private |
Definition at line 180 of file ethercat_hardware.h.
|
private |
Definition at line 174 of file ethercat_hardware.h.
|
private |
Definition at line 179 of file ethercat_hardware.h.
|
private |
Definition at line 199 of file ethercat_hardware.h.
|
private |
Timeout controls how long EtherCAT driver waits for packet before declaring it as dropped.
Definition at line 184 of file ethercat_hardware.h.
|
private |
Definition at line 198 of file ethercat_hardware.h.