motor_model.h
Go to the documentation of this file.
1 
2 
3 #ifndef ETHERCAT_HARDWARE_MOTOR_MODEL_H
4 #define ETHERCAT_HARDWARE_MOTOR_MODEL_H
5 
6 #include <string>
7 #include <vector>
8 
10 #include <ethercat_hardware/MotorTraceSample.h>
11 #include <ethercat_hardware/MotorTrace.h>
12 #include <ethercat_hardware/ActuatorInfo.h>
13 #include <ethercat_hardware/BoardInfo.h>
14 
16 
17 #include <boost/utility.hpp>
18 #include <boost/thread/mutex.hpp>
19 
20 class MotorModel : private boost::noncopyable
21 {
22 public:
23  MotorModel(unsigned trace_size);
24  bool initialize(const ethercat_hardware::ActuatorInfo &actuator_info,
25  const ethercat_hardware::BoardInfo &board_info);
26  void flagPublish(const std::string &reason, int level, int delay);
27  void checkPublish();
29  void sample(const ethercat_hardware::MotorTraceSample &s);
30  bool verify();
31  void reset();
32 protected:
33  unsigned trace_size_;
34  unsigned trace_index_; /* index of most recent element in trace vector */
36  ethercat_hardware::ActuatorInfo actuator_info_;
37  ethercat_hardware::BoardInfo board_info_;
40  std::vector<ethercat_hardware::MotorTraceSample> trace_buffer_;
45  std::string publish_reason_;
46  //bool new_max_current_error_;
47  //bool new_max_voltage_error_;
49  std::string diagnostics_reason_;
50 
52  {
53  public:
54  SimpleFilter();
55  void sample(double value, double filter_coefficient);
56  void reset();
57  double filter() const { return filtered_value_; }
58  protected:
60  };
61 
62  // Filters and keeps a record of max values
63  class Filter : public SimpleFilter
64  {
65  public:
66  Filter(double filter_coefficient);
67  bool sample(double value);
68  void reset();
69  double filter_max() const { return max_filtered_value_; }
70  protected:
73  };
74 
75  // Lock around values used for diagnostics,
76  // filter updates and diagnostic publishing are called from same different threads
77  boost::mutex diagnostics_mutex_;
85 
86  // These filter is for indentifing source of errors not for calculations
91 
92 };
93 
94 #endif /* ETHERCAT_HARDWARE_MOTOR_MODEL_H */
MotorModel::measured_voltage_error_
Filter measured_voltage_error_
Definition: motor_model.h:80
realtime_publisher.h
MotorModel::SimpleFilter::filtered_value_
double filtered_value_
Definition: motor_model.h:59
MotorModel::publish_delay_
int publish_delay_
Definition: motor_model.h:43
MotorModel::initialize
bool initialize(const ethercat_hardware::ActuatorInfo &actuator_info, const ethercat_hardware::BoardInfo &board_info)
Initializes motor trace publisher.
Definition: motor_model.cpp:53
MotorModel::trace_buffer_
std::vector< ethercat_hardware::MotorTraceSample > trace_buffer_
Definition: motor_model.h:40
MotorModel::Filter::filter_coefficient_
double filter_coefficient_
Definition: motor_model.h:71
MotorModel::abs_board_voltage_
Filter abs_board_voltage_
Definition: motor_model.h:89
MotorModel::SimpleFilter::reset
void reset()
Definition: motor_model.cpp:441
MotorModel::abs_motor_voltage_error_
Filter abs_motor_voltage_error_
Definition: motor_model.h:79
s
XmlRpcServer s
MotorModel::previous_pwm_saturated_
bool previous_pwm_saturated_
Definition: motor_model.h:39
MotorModel
Definition: motor_model.h:20
MotorModel::SimpleFilter::sample
void sample(double value, double filter_coefficient)
Updates filter with newly sampled value.
Definition: motor_model.cpp:406
MotorModel::Filter::sample
bool sample(double value)
Updates filter with newly sampled value, also tracks max value.
Definition: motor_model.cpp:418
MotorModel::publish_level_
int publish_level_
Definition: motor_model.h:44
MotorModel::flagPublish
void flagPublish(const std::string &reason, int level, int delay)
flags delayed publish of motor trace.
Definition: motor_model.cpp:125
MotorModel::current_error_
Filter current_error_
Definition: motor_model.h:82
MotorModel::publish_reason_
std::string publish_reason_
Definition: motor_model.h:45
MotorModel::checkPublish
void checkPublish()
Publishes motor trace if delay time is up.
Definition: motor_model.cpp:87
MotorModel::Filter::Filter
Filter(double filter_coefficient)
Definition: motor_model.cpp:434
MotorModel::actuator_info_
ethercat_hardware::ActuatorInfo actuator_info_
Definition: motor_model.h:36
MotorModel::Filter::filter_max
double filter_max() const
Definition: motor_model.h:69
MotorModel::backemf_constant_
double backemf_constant_
Definition: motor_model.h:38
realtime_tools::RealtimePublisher< ethercat_hardware::MotorTrace >
MotorModel::abs_current_error_
Filter abs_current_error_
Definition: motor_model.h:83
MotorModel::MotorModel
MotorModel(unsigned trace_size)
Definition: motor_model.cpp:6
MotorModel::Filter
Definition: motor_model.h:63
d
d
DiagnosticStatusWrapper.h
MotorModel::reset
void reset()
Definition: motor_model.cpp:27
MotorModel::trace_index_
unsigned trace_index_
Definition: motor_model.h:34
MotorModel::diagnostics_mutex_
boost::mutex diagnostics_mutex_
Definition: motor_model.h:77
MotorModel::verify
bool verify()
Check for errors between sample data and motor model.
Definition: motor_model.cpp:313
MotorModel::Filter::max_filtered_value_
double max_filtered_value_
Definition: motor_model.h:72
MotorModel::abs_measured_voltage_error_
Filter abs_measured_voltage_error_
Definition: motor_model.h:81
MotorModel::current_error_limit_
double current_error_limit_
Definition: motor_model.h:42
MotorModel::board_info_
ethercat_hardware::BoardInfo board_info_
Definition: motor_model.h:37
MotorModel::abs_position_delta_
Filter abs_position_delta_
Definition: motor_model.h:90
MotorModel::Filter::reset
void reset()
Definition: motor_model.cpp:446
MotorModel::trace_size_
unsigned trace_size_
Definition: motor_model.h:33
MotorModel::abs_measured_current_
Filter abs_measured_current_
Definition: motor_model.h:88
MotorModel::abs_velocity_
Filter abs_velocity_
Definition: motor_model.h:87
diagnostic_updater::DiagnosticStatusWrapper
MotorModel::published_traces_
unsigned published_traces_
Definition: motor_model.h:35
MotorModel::motor_voltage_error_
Filter motor_voltage_error_
Definition: motor_model.h:78
MotorModel::diagnostics
void diagnostics(diagnostic_updater::DiagnosticStatusWrapper &d)
Collects and publishes device diagnostics.
Definition: motor_model.cpp:143
MotorModel::SimpleFilter::SimpleFilter
SimpleFilter()
Definition: motor_model.cpp:429
MotorModel::SimpleFilter
Definition: motor_model.h:51
MotorModel::motor_resistance_
SimpleFilter motor_resistance_
Definition: motor_model.h:84
MotorModel::diagnostics_reason_
std::string diagnostics_reason_
Definition: motor_model.h:49
MotorModel::diagnostics_level_
int diagnostics_level_
Definition: motor_model.h:48
MotorModel::SimpleFilter::filter
double filter() const
Definition: motor_model.h:57
MotorModel::sample
void sample(const ethercat_hardware::MotorTraceSample &s)
Call for each update.
Definition: motor_model.cpp:198
MotorModel::publisher_
realtime_tools::RealtimePublisher< ethercat_hardware::MotorTrace > * publisher_
Definition: motor_model.h:41


ethercat_hardware
Author(s): Rob Wheeler , Derek King
autogenerated on Thu Sep 26 2024 02:44:04