00001 // -*- mode: c++; indent-tabs-mode: t; tab-width: 4; c-basic-offset: 4; -*- 00002 /* 00003 * Copyright (c) 2008, AIST, the University of Tokyo and General Robotix Inc. 00004 * All rights reserved. This program is made available under the terms of the 00005 * Eclipse Public License v1.0 which accompanies this distribution, and is 00006 * available at http://www.eclipse.org/legal/epl-v10.html 00007 * Contributors: 00008 * National Institute of Advanced Industrial Science and Technology (AIST) 00009 * General Robotix Inc. 00010 */ 00019 #ifndef NEWSAMPLELF_H 00020 #define NEWSAMPLELF_H 00021 00022 #include <rtm/idl/BasicDataType.hh> 00023 #include <rtm/Manager.h> 00024 #include <rtm/DataFlowComponentBase.h> 00025 #include <rtm/CorbaPort.h> 00026 #include <rtm/DataInPort.h> 00027 #include <rtm/DataOutPort.h> 00028 #include <rtm/idl/BasicDataTypeSkel.h> 00029 #include <rtm/CORBA_SeqUtil.h> 00030 #include <vector> 00031 00032 // Service implementation headers 00033 // <rtc-template block="service_impl_h"> 00034 00035 // </rtc-template> 00036 00037 // Service Consumer stub headers 00038 // <rtc-template block="consumer_stub_h"> 00039 00040 // </rtc-template> 00041 00042 using namespace RTC; 00043 00044 class SampleLF 00045 : public RTC::DataFlowComponentBase 00046 { 00047 public: 00048 SampleLF(RTC::Manager* manager); 00049 ~SampleLF(); 00050 00051 // The initialize action (on CREATED->ALIVE transition) 00052 // formaer rtc_init_entry() 00053 virtual RTC::ReturnCode_t onInitialize(); 00054 00055 // The finalize action (on ALIVE->END transition) 00056 // formaer rtc_exiting_entry() 00057 // virtual RTC::ReturnCode_t onFinalize(); 00058 00059 // The startup action when ExecutionContext startup 00060 // former rtc_starting_entry() 00061 // virtual RTC::ReturnCode_t onStartup(RTC::UniqueId ec_id); 00062 00063 // The shutdown action when ExecutionContext stop 00064 // former rtc_stopping_entry() 00065 // virtual RTC::ReturnCode_t onShutdown(RTC::UniqueId ec_id); 00066 00067 // The activated action (Active state entry action) 00068 // former rtc_active_entry() 00069 virtual RTC::ReturnCode_t onActivated(RTC::UniqueId ec_id); 00070 00071 // The deactivated action (Active state exit action) 00072 // former rtc_active_exit() 00073 virtual RTC::ReturnCode_t onDeactivated(RTC::UniqueId ec_id); 00074 00075 // The execution action that is invoked periodically 00076 // former rtc_active_do() 00077 virtual RTC::ReturnCode_t onExecute(RTC::UniqueId ec_id); 00078 00079 // The aborting action when main logic error occurred. 00080 // former rtc_aborting_entry() 00081 // virtual RTC::ReturnCode_t onAborting(RTC::UniqueId ec_id); 00082 00083 // The error action in ERROR state 00084 // former rtc_error_do() 00085 // virtual RTC::ReturnCode_t onError(RTC::UniqueId ec_id); 00086 00087 // The reset action that is invoked resetting 00088 // This is same but different the former rtc_init_entry() 00089 // virtual RTC::ReturnCode_t onReset(RTC::UniqueId ec_id); 00090 00091 // The state update action that is invoked after onExecute() action 00092 // no corresponding operation exists in OpenRTm-aist-0.2.0 00093 // virtual RTC::ReturnCode_t onStateUpdate(RTC::UniqueId ec_id); 00094 00095 // The action that is invoked when execution context's rate is changed 00096 // no corresponding operation exists in OpenRTm-aist-0.2.0 00097 // virtual RTC::ReturnCode_t onRateChanged(RTC::UniqueId ec_id); 00098 00099 00100 protected: 00101 // Configuration variable declaration 00102 // <rtc-template block="config_declare"> 00103 00104 // </rtc-template> 00105 00106 // DataInPort declaration 00107 // <rtc-template block="inport_declare"> 00108 TimedDoubleSeq m_angle; 00109 InPort<TimedDoubleSeq> m_angleIn; 00110 00111 TimedDoubleSeq m_torqueL; 00112 InPort<TimedDoubleSeq> m_torqueInL; 00113 00114 TimedDoubleSeq m_torqueR; 00115 InPort<TimedDoubleSeq> m_torqueInR; 00116 00117 // </rtc-template> 00118 00119 // DataOutPort declaration 00120 // <rtc-template block="outport_declare"> 00121 TimedDoubleSeq m_torque; 00122 OutPort<TimedDoubleSeq> m_torqueOut; 00123 00124 00125 // </rtc-template> 00126 00127 // CORBA Port declaration 00128 // <rtc-template block="corbaport_declare"> 00129 00130 // </rtc-template> 00131 00132 // Service declaration 00133 // <rtc-template block="service_declare"> 00134 00135 // </rtc-template> 00136 00137 // Consumer declaration 00138 // <rtc-template block="consumer_declare"> 00139 00140 // </rtc-template> 00141 00142 private: 00143 int dummy; 00144 std::ifstream angle1, vel1, angle2, vel2, gain; 00145 bool check; 00146 int file; 00147 00148 double *Pgain; 00149 double *Dgain; 00150 std::vector<double> qold,qref_old; 00151 void openFiles(); 00152 void closeFiles(); 00153 }; 00154 00155 00156 extern "C" 00157 { 00158 DLL_EXPORT void SampleLFInit(RTC::Manager* manager); 00159 }; 00160 00161 #endif // NEWSAMPLELF_H