ThermoLimiter.h
Go to the documentation of this file.
00001 // -*- C++ -*-
00010 #ifndef THERMO_LIMITER_SERVICE_H
00011 #define THERMO_LIMITER_SERVICE_H
00012 
00013 #include <rtm/idl/BasicDataType.hh>
00014 #include <rtm/Manager.h>
00015 #include <rtm/DataFlowComponentBase.h>
00016 #include <rtm/CorbaPort.h>
00017 #include <rtm/DataInPort.h>
00018 #include <rtm/DataOutPort.h>
00019 #include <rtm/idl/BasicDataTypeSkel.h>
00020 
00021 #include <hrpModel/Body.h>
00022 #include <hrpModel/Link.h>
00023 #include <hrpModel/JointPath.h>
00024 
00025 #include "../ThermoEstimator/MotorHeatParam.h"
00026 
00027 // Service implementation headers
00028 // <rtc-template block="service_impl_h">
00029 #include "ThermoLimiterService_impl.h"
00030 #include "../SoftErrorLimiter/beep.h"
00031 
00032 // </rtc-template>
00033 
00034 // Service Consumer stub headers
00035 // <rtc-template block="consumer_stub_h">
00036 
00037 // </rtc-template>
00038 
00039 using namespace RTC;
00040 
00044 class ThermoLimiter
00045   : public RTC::DataFlowComponentBase
00046 {
00047  public:
00052   ThermoLimiter(RTC::Manager* manager);
00056   virtual ~ThermoLimiter();
00057 
00058   // The initialize action (on CREATED->ALIVE transition)
00059   // formaer rtc_init_entry()
00060   virtual RTC::ReturnCode_t onInitialize();
00061 
00062   // The finalize action (on ALIVE->END transition)
00063   // formaer rtc_exiting_entry()
00064   // virtual RTC::ReturnCode_t onFinalize();
00065 
00066   // The startup action when ExecutionContext startup
00067   // former rtc_starting_entry()
00068   // virtual RTC::ReturnCode_t onStartup(RTC::UniqueId ec_id);
00069 
00070   // The shutdown action when ExecutionContext stop
00071   // former rtc_stopping_entry()
00072   // virtual RTC::ReturnCode_t onShutdown(RTC::UniqueId ec_id);
00073 
00074   // The activated action (Active state entry action)
00075   // former rtc_active_entry()
00076   virtual RTC::ReturnCode_t onActivated(RTC::UniqueId ec_id);
00077 
00078   // The deactivated action (Active state exit action)
00079   // former rtc_active_exit()
00080   virtual RTC::ReturnCode_t onDeactivated(RTC::UniqueId ec_id);
00081 
00082   // The execution action that is invoked periodically
00083   // former rtc_active_do()
00084   virtual RTC::ReturnCode_t onExecute(RTC::UniqueId ec_id);
00085 
00086   // The aborting action when main logic error occurred.
00087   // former rtc_aborting_entry()
00088   // virtual RTC::ReturnCode_t onAborting(RTC::UniqueId ec_id);
00089 
00090   // The error action in ERROR state
00091   // former rtc_error_do()
00092   // virtual RTC::ReturnCode_t onError(RTC::UniqueId ec_id);
00093 
00094   // The reset action that is invoked resetting
00095   // This is same but different the former rtc_init_entry()
00096   // virtual RTC::ReturnCode_t onReset(RTC::UniqueId ec_id);
00097 
00098   // The state update action that is invoked after onExecute() action
00099   // no corresponding operation exists in OpenRTm-aist-0.2.0
00100   // virtual RTC::ReturnCode_t onStateUpdate(RTC::UniqueId ec_id);
00101 
00102   // The action that is invoked when execution context's rate is changed
00103   // no corresponding operation exists in OpenRTm-aist-0.2.0
00104   // virtual RTC::ReturnCode_t onRateChanged(RTC::UniqueId ec_id);
00105   bool setParameter(const OpenHRP::ThermoLimiterService::tlParam& i_tlp);
00106   bool getParameter(OpenHRP::ThermoLimiterService::tlParam& i_tlp);
00107 
00108 
00109  protected:
00110   // Configuration variable declaration
00111   // <rtc-template block="config_declare">
00112   
00113   // </rtc-template>
00114   TimedDoubleSeq m_tempIn;
00115   TimedDoubleSeq m_tauMaxOut;
00116   TimedLongSeq m_beepCommandOut;
00117   
00118   // DataInPort declaration
00119   // <rtc-template block="inport_declare">
00120   InPort<TimedDoubleSeq> m_tempInIn;
00121   
00122   // </rtc-template>
00123 
00124   // DataOutPort declaration
00125   // <rtc-template block="outport_declare">
00126   OutPort<TimedDoubleSeq> m_tauMaxOutOut;
00127   OutPort<TimedLongSeq> m_beepCommandOutOut;
00128   
00129   // </rtc-template>
00130 
00131   // CORBA Port declaration
00132   // <rtc-template block="corbaport_declare">
00133   
00134   // </rtc-template>
00135 
00136   // Service declaration
00137   // <rtc-template block="service_declare">
00138   RTC::CorbaPort m_ThermoLimiterServicePort;
00139   
00140   // </rtc-template>
00141 
00142   // Consumer declaration
00143   // <rtc-template block="consumer_declare">
00144   ThermoLimiterService_impl m_ThermoLimiterService;
00145   
00146   // </rtc-template>
00147 
00148  private:
00149   double m_dt;
00150   long long m_loop;
00151   unsigned int m_debugLevel, m_debug_print_freq;
00152   double m_alarmRatio;
00153   hrp::dvector m_motorTemperatureLimit;
00154   hrp::BodyPtr m_robot;
00155   std::vector<MotorHeatParam> m_motorHeatParams;
00156   coil::Mutex m_mutex;
00157   BeepClient bc;
00158 
00159   void calcMaxTorqueFromTemperature(hrp::dvector &tauMax);
00160   double calcEmergencyRatio(RTC::TimedDoubleSeq &current, hrp::dvector &max, double alarmRatio, std::string &prefix);
00161   void callBeep(double ratio, double alarmRatio);
00162   bool isDebug(int cycle = 200);
00163 };
00164 
00165 
00166 extern "C"
00167 {
00168   void ThermoLimiterInit(RTC::Manager* manager);
00169 };
00170 
00171 #endif // NULL_COMPONENT_H


hrpsys
Author(s): AIST, Fumio Kanehiro
autogenerated on Wed Sep 6 2017 02:35:56