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 */
d
double filter_max() const
Definition: motor_model.h:69
boost::mutex diagnostics_mutex_
Definition: motor_model.h:77
void reset()
Definition: motor_model.cpp:27
bool verify()
Check for errors between sample data and motor model.
double current_error_limit_
Definition: motor_model.h:42
void sample(double value, double filter_coefficient)
Updates filter with newly sampled value.
unsigned trace_index_
Definition: motor_model.h:34
XmlRpcServer s
double max_filtered_value_
Definition: motor_model.h:72
Filter abs_position_delta_
Definition: motor_model.h:90
Filter abs_measured_voltage_error_
Definition: motor_model.h:81
ethercat_hardware::BoardInfo board_info_
Definition: motor_model.h:37
unsigned published_traces_
Definition: motor_model.h:35
Filter motor_voltage_error_
Definition: motor_model.h:78
unsigned trace_size_
Definition: motor_model.h:33
Filter abs_measured_current_
Definition: motor_model.h:88
void diagnostics(diagnostic_updater::DiagnosticStatusWrapper &d)
Collects and publishes device diagnostics.
Filter abs_velocity_
Definition: motor_model.h:87
SimpleFilter motor_resistance_
Definition: motor_model.h:84
int diagnostics_level_
Definition: motor_model.h:48
realtime_tools::RealtimePublisher< ethercat_hardware::MotorTrace > * publisher_
Definition: motor_model.h:41
double filter_coefficient_
Definition: motor_model.h:71
std::string diagnostics_reason_
Definition: motor_model.h:49
Filter measured_voltage_error_
Definition: motor_model.h:80
void sample(const ethercat_hardware::MotorTraceSample &s)
Call for each update.
int publish_delay_
Definition: motor_model.h:43
bool initialize(const ethercat_hardware::ActuatorInfo &actuator_info, const ethercat_hardware::BoardInfo &board_info)
Initializes motor trace publisher.
Definition: motor_model.cpp:53
Filter abs_board_voltage_
Definition: motor_model.h:89
Filter abs_motor_voltage_error_
Definition: motor_model.h:79
double filter() const
Definition: motor_model.h:57
std::vector< ethercat_hardware::MotorTraceSample > trace_buffer_
Definition: motor_model.h:40
int publish_level_
Definition: motor_model.h:44
bool previous_pwm_saturated_
Definition: motor_model.h:39
void checkPublish()
Publishes motor trace if delay time is up.
Definition: motor_model.cpp:87
Filter current_error_
Definition: motor_model.h:82
void flagPublish(const std::string &reason, int level, int delay)
flags delayed publish of motor trace.
std::string publish_reason_
Definition: motor_model.h:45
ethercat_hardware::ActuatorInfo actuator_info_
Definition: motor_model.h:36
double backemf_constant_
Definition: motor_model.h:38
MotorModel(unsigned trace_size)
Definition: motor_model.cpp:6
Filter abs_current_error_
Definition: motor_model.h:83


ethercat_hardware
Author(s): Rob Wheeler , Derek King
autogenerated on Thu Mar 4 2021 03:10:21