motor_heating_model.h
Go to the documentation of this file.
1 /*********************************************************************
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2008, Willow Garage, Inc.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * * Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * * Redistributions in binary form must reproduce the above
14  * copyright notice, this list of conditions and the following
15  * disclaimer in the documentation and/or other materials provided
16  * with the distribution.
17  * * Neither the name of the Willow Garage nor the names of its
18  * contributors may be used to endorse or promote products derived
19  * from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32  * POSSIBILITY OF SUCH DAMAGE.
33  *********************************************************************/
34 
35 #ifndef ETHERCAT_HARDWARE__MOTOR_HEATING_MODEL_H
36 #define ETHERCAT_HARDWARE__MOTOR_HEATING_MODEL_H
37 
38 #include "ethercat_hardware/MotorTemperature.h"
39 #include "ethercat_hardware/MotorTraceSample.h"
40 #include "ethercat_hardware/ActuatorInfo.h"
41 
44 
45 #include <boost/utility.hpp>
46 #include <boost/thread/mutex.hpp>
47 #include <boost/thread/thread.hpp>
48 #include <boost/shared_ptr.hpp>
49 
50 #include <vector>
51 #include <string>
52 
54 {
55 
56 
63 {
74 } __attribute__ ((__packed__));
75 
76 
88 {
89  uint16_t major_;
90  uint16_t minor_;
91  bool enforce_;
92  uint8_t pad1[3];
94  uint8_t pad2[204];
95  uint32_t crc32_;
96 
97  static const unsigned EEPROM_PAGE = 4093; // Acutator info on page 4095, MCB config on 4094
98 
99  bool verifyCRC(void) const;
100  void generateCRC(void);
101 } __attribute__ ((__packed__));
102 
103 
104 class MotorHeatingModel;
106 class MotorHeatingModelCommon : private boost::noncopyable
107 {
108 public:
111  MotorHeatingModelCommon(ros::NodeHandle nh);
112 
115  MotorHeatingModelCommon();
116 
117 
118  bool initialize();
119 
122  void attach(boost::shared_ptr<MotorHeatingModel> model);
123 
128  std::string save_directory_;
137 
138 protected:
139  bool createSaveDirectory();
140 
142  boost::thread save_thread_;
143  void saveThreadFunc();
144 
146  std::vector< boost::shared_ptr<MotorHeatingModel> > models_;
147 
149  boost::mutex mutex_;
150 };
151 
152 
153 
154 class MotorHeatingModel : private boost::noncopyable
155 {
156 public:
157 
159  const std::string &actuator_name,
160  const std::string &hwid,
161  const std::string &save_directory
162  );
163 
164  bool startTemperaturePublisher();
165 
176  bool update(double heating_power, double ambient_temperature, double duration);
177  bool update(const ethercat_hardware::MotorTraceSample &sample,
178  const ethercat_hardware::ActuatorInfo &actuator_info,
179  double ambient_temperature, double duration)
180  {
181  double heating_power = calculateMotorHeatPower(sample, actuator_info);
182  return update(heating_power, ambient_temperature, duration);
183  }
184 
186  bool hasOverheated() const {return overheat_;}
188  double getWindingTemperature() {return winding_temperature_;}
190  double getHousingTemperature() {return housing_temperature_;}
191 
192 
194  void reset();
195 
196 
208  void updateFromDowntime(double downtime, double saved_ambient_temperature);
209 
210 
218  double updateFromDowntimeWithInterval(double downtime,
219  double saved_ambient_temperature,
220  double interval,
221  unsigned cycles);
222 
223 
226  double calculateMotorHeatPower(const ethercat_hardware::MotorTraceSample &sample,
227  const ethercat_hardware::ActuatorInfo &actuator_info);
228 
229 
231  bool loadTemperatureState();
232 
233 
239  bool saveTemperatureState();
240 
241 
244 
245 
246 
247 
248 protected:
249  // Following values are calculated from motor parameters.
250  // They are more useful when peforming motor model calculations
251  //
252  // Thermal is conducance amount of heat power tranfered for a
253  // given temperature differential
254  // Thermal conductance units : Watt/C
255  // Thermal conductance = 1 / Thermal resistance
256  //
257  // Thermal mass (or Thermal capicitance) : Energy required to
258  // raise temperature of object 1 degree.
259  // Thermal mass units : C/Joule
260  // Thermal mass = Thermal time constant / thermal resistance
261 
270 
271 
278 
280  boost::mutex mutex_;
281 
283  bool overheat_;
284 
292  //double trace_sample_interval_;
295 
297  std::string actuator_name_;
298  std::string save_filename_;
299  std::string hwid_;
300 };
301 
302 
303 }; //end namepace ethercat_hardware
304 
305 #endif //ETHERCAT_HARDWARE__MOTOR_HEATING_MODEL_H
d
uint16_t major_
Major revision of this structure.
MotorHeatingModelParameters params_
Motor parameters.
double winding_thermal_time_constant_
Thermal time constant of motor winding : in seconds.
bool update(const ethercat_hardware::MotorTraceSample &sample, const ethercat_hardware::ActuatorInfo &actuator_info, double ambient_temperature, double duration)
bool enable_model_
If true, enables motor heating model. If false, motor heating model is run for any devices...
std::string save_filename_
path to file where temperature data will be saved
ROSCONSOLE_DECL void initialize()
bool disable_halt_
Disables halting caused by a motor being overtemperature.
bool overheat_
True if most has overheat, once set, will only clear when reset() is called.
double getWindingTemperature()
Gets current winding temperature estimate (for testing)
bool enforce_
0 if heating model should be not be enforced, 0 otherwise
double heating_energy_sum_
Sum of heat energy for last sample interval.
bool hasOverheated() const
Not thread save, should be called by same thread that calls update()
uint16_t minor_
Minor revision of this structure.
void update(const std::string &key, const XmlRpc::XmlRpcValue &v)
std::string save_directory_
Directory where temperature save files should be put.
boost::mutex mutex_
Lock around models list.
double winding_to_housing_thermal_resistance_
Thermal resistance between motor winding and motor housing : in C/Watt.
bool load_save_files_
If true, then class instances will attempt to load data from a saved temperature file.
realtime_tools::RealtimePublisher< ethercat_hardware::MotorTemperature > * publisher_
Sample interval for trace (in seconds)
std::vector< boost::shared_ptr< MotorHeatingModel > > models_
List of MotorHeatingModels that need to have file data saved.
double winding_thermal_mass_inverse_
Inverse of thermal mass for motor winding : in Joules/C.
static const unsigned EEPROM_PAGE
double duration_since_last_sample_
Time (in seconds) since late sample interval occurred.
MotorHeatingModelParameters motor_params_
std::string actuator_name_
name of actuator (ex. fl_caster_rotation_motor)
double housing_thermal_time_constant_
Thermal time constant of motor housing : in seconds.
double winding_temperature_
Temperature estimate of motor winding : in Celcius.
uint8_t pad2[204]
double max_winding_temperature_
temperature limit of motor windings : in Celcius
double housing_to_ambient_thermal_conductance_
Thermal conductance between motor housing and ambient : in Watt/C.
uint8_t pad1[3]
double housing_thermal_mass_inverse_
Inverse of thermal mass for motor housing : in Joules/C.
bool publish_temperature_
If true, each motor heating model with publish state information every 1 second.
double ambient_temperature_
Last recorded ambient temperature : in Celcius.
double winding_to_housing_thermal_conductance_
Thermal conductance between motor winding and housing : in Watt/C.
void generateCRC(void)
double getHousingTemperature()
Gets current winding temperature estimate (for testing)
double housing_to_ambient_thermal_resistance_
Thermal resistance between motor housing and ambient : in C/Watt.
ethercat_hardware::MotorHeatingModelCommon __attribute__
boost::thread save_thread_
thread that will periodically save temperature data
bool verifyCRC(void) const
double ambient_temperature_sum_
Sum of (abient heat * time) over last sample interval.
boost::mutex mutex_
mutex protects values updates by realtime thread and used by diagnostics thread
double housing_temperature_
Temperature estimate of motor housing : in Celcius.
uint32_t crc32_
CRC32 of first 256-4 bytes of structure.
std::string hwid_
Hardware ID of device (ex. 680500501000)


ethercat_hardware
Author(s): Rob Wheeler , Derek King
autogenerated on Tue Mar 28 2023 02:10:20