Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pr2 ethercat should report last time halt occurred in diagnostics (ros ticket #4332) #26

Open
ahendrix opened this issue Mar 12, 2013 · 3 comments

Comments

@ahendrix
Copy link
Member

I will add a diagnostic key-value pair in the Ethercat Master diagnostics that contains that time that a motor halt last occurred.

trac data:

@ahendrix
Copy link
Member Author

[blaise] Actually, this might be a rob ticket...

@ahendrix
Copy link
Member Author

[blaise] Just curious why the won't fix? It is still something that strikes me as useful, and that we'll wish we had next time we run into one of these scheduling/motors halting problems.

@ahendrix
Copy link
Member Author

[dking] Patch for pr2_ethercat_drivers 1.5

{{{

--- include/ethercat_hardware/ethercat_hardware.h (revision 48057)
+++ include/ethercat_hardware/ethercat_hardware.h (working copy)
@@ -84,6 +84,7 @@
struct netif_counters counters_;
bool input_thread_is_stopped_;
bool motors_halted_; //!< True if motors are halted

  • ros::Time last_time_motors_halted_; //!< Last time motors halted

static const bool collect_extra_timing_ = true;
};

Index: src/ethercat_hardware.cpp

--- src/ethercat_hardware.cpp (revision 48057)
+++ src/ethercat_hardware.cpp (working copy)
@@ -53,6 +53,7 @@
halt_motors_error_count_(0)
{
resetMaxTiming();

  • last_time_motors_halted_ = ros::Time::now(); // Assume motors start in halted state
    }

void EthercatHardwareDiagnostics::resetMaxTiming()
@@ -374,7 +375,7 @@
boost::unique_lockboost::mutex lock(diagnostics_mutex_, try_lock);
if (lock.owns_lock())
{

  • // Make copies of diagnostic data for dianostic thread
  • // Make copies of diagnostic data for diagnostic thread
    memcpy(diagnostics_buffer_, buffer, buffer_size_);
    diagnostics_ = diagnostics;
    // Trigger diagnostics publish thread
    @@ -446,6 +447,8 @@
    }

status_.add("Motors halted", diagnostics_.motors_halted_ ? "true" : "false");

  • status_.addf("Last time motors halted", "%f", diagnostics_.last_time_motors_halted_.toSec());
  • status_.addf("EtherCAT devices (expected)", "%d", num_slaves_);
    status_.addf("EtherCAT devices (current)", "%d", diagnostics_.device_count_);
    ethernet_interface_info_.publishDiagnostics(status_);
    @@ -641,12 +644,16 @@
    motor_publisher_.unlockAndPublish();
    }
  • if ((halt_motors_ && !old_halt_motors) && (halt_motors_error))
  • if (halt_motors_ && !old_halt_motors)
    {
  • ++diagnostics_.halt_motors_error_count_;
  • if ((update_start_time - last_reset_) < ros::Duration(0.5))
  • diagnostics_.last_time_motors_halted_ = update_start_time;
  • if (halt_motors_error)
    {
  •  diagnostics_.halt_after_reset_ = true;
    
  •  ++diagnostics_.halt_motors_error_count_;
    
  •  if ((update_start_time - last_reset_) < ros::Duration(0.5))
    
  •  {
    
  •    diagnostics_.halt_after_reset_ = true;
    
  •  }
    
    }
    }

dking@bli:/wg/stor1a/dking/dros/pr2_ethercat_drivers/ethercat_hardware$ svn di

Index: include/ethercat_hardware/ethercat_hardware.h

--- include/ethercat_hardware/ethercat_hardware.h (revision 48057)
+++ include/ethercat_hardware/ethercat_hardware.h (working copy)
@@ -84,6 +84,7 @@
struct netif_counters counters_;
bool input_thread_is_stopped_;
bool motors_halted_; //!< True if motors are halted

  • ros::Time last_time_motors_halted_; //!< Last time motors halted

static const bool collect_extra_timing_ = true;
};

Index: src/ethercat_hardware.cpp

--- src/ethercat_hardware.cpp (revision 48057)
+++ src/ethercat_hardware.cpp (working copy)
@@ -53,6 +53,7 @@
halt_motors_error_count_(0)
{
resetMaxTiming();

  • last_time_motors_halted_ = ros::Time::now(); // Assume motors start in halted state
    }

void EthercatHardwareDiagnostics::resetMaxTiming()
@@ -374,7 +375,7 @@
boost::unique_lockboost::mutex lock(diagnostics_mutex_, try_lock);
if (lock.owns_lock())
{

  • // Make copies of diagnostic data for dianostic thread
  • // Make copies of diagnostic data for diagnostic thread
    memcpy(diagnostics_buffer_, buffer, buffer_size_);
    diagnostics_ = diagnostics;
    // Trigger diagnostics publish thread
    @@ -446,6 +447,8 @@
    }

status_.add("Motors halted", diagnostics_.motors_halted_ ? "true" : "false");

  • status_.addf("Last time motors halted", "%f", diagnostics_.last_time_motors_halted_.toSec());
  • status_.addf("EtherCAT devices (expected)", "%d", num_slaves_);
    status_.addf("EtherCAT devices (current)", "%d", diagnostics_.device_count_);
    ethernet_interface_info_.publishDiagnostics(status_);
    @@ -641,12 +644,16 @@
    motor_publisher_.unlockAndPublish();
    }
  • if ((halt_motors_ && !old_halt_motors) && (halt_motors_error))
  • if (halt_motors_ && !old_halt_motors)
    {
  • ++diagnostics_.halt_motors_error_count_;
  • if ((update_start_time - last_reset_) < ros::Duration(0.5))
  • diagnostics_.last_time_motors_halted_ = update_start_time;
  • if (halt_motors_error)
    {
  •  diagnostics_.halt_after_reset_ = true;
    
  •  ++diagnostics_.halt_motors_error_count_;
    
  •  if ((update_start_time - last_reset_) < ros::Duration(0.5))
    
  •  {
    
  •    diagnostics_.halt_after_reset_ = true;
    
  •  }
    
    }
    }
    }}}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant