SampleController.h
Go to the documentation of this file.
00001 // -*- C++ -*-
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 SAMPLECONTROLLER_H
00020 #define SAMPLECONTROLLER_H
00021 #define DOF (29)
00022 
00023 #include <rtm/idl/BasicDataType.hh>
00024 #include <rtm/Manager.h>
00025 #include <rtm/DataFlowComponentBase.h>
00026 #include <rtm/CorbaPort.h>
00027 #include <rtm/DataInPort.h>
00028 #include <rtm/DataOutPort.h>
00029 #include <rtm/idl/BasicDataTypeSkel.h>
00030 
00031 // Service implementation headers
00032 // <rtc-template block="service_impl_h">
00033 
00034 // </rtc-template>
00035 
00036 // Service Consumer stub headers
00037 // <rtc-template block="consumer_stub_h">
00038 
00039 // </rtc-template>
00040 
00041 using namespace RTC;
00042 
00043 class SampleController
00044   : public RTC::DataFlowComponentBase
00045 {
00046  public:
00047   SampleController(RTC::Manager* manager);
00048   ~SampleController();
00049 
00050   // The initialize action (on CREATED->ALIVE transition)
00051   // formaer rtc_init_entry() 
00052  virtual RTC::ReturnCode_t onInitialize();
00053 
00054   // The finalize action (on ALIVE->END transition)
00055   // formaer rtc_exiting_entry()
00056    virtual RTC::ReturnCode_t onFinalize();
00057 
00058   // The startup action when ExecutionContext startup
00059   // former rtc_starting_entry()
00060   // virtual RTC::ReturnCode_t onStartup(RTC::UniqueId ec_id);
00061 
00062   // The shutdown action when ExecutionContext stop
00063   // former rtc_stopping_entry()
00064   // virtual RTC::ReturnCode_t onShutdown(RTC::UniqueId ec_id);
00065 
00066   // The activated action (Active state entry action)
00067   // former rtc_active_entry()
00068    virtual RTC::ReturnCode_t onActivated(RTC::UniqueId ec_id);
00069 
00070   // The deactivated action (Active state exit action)
00071   // former rtc_active_exit()
00072    virtual RTC::ReturnCode_t onDeactivated(RTC::UniqueId ec_id);
00073 
00074   // The execution action that is invoked periodically
00075   // former rtc_active_do()
00076   virtual RTC::ReturnCode_t onExecute(RTC::UniqueId ec_id);
00077 
00078   // The aborting action when main logic error occurred.
00079   // former rtc_aborting_entry()
00080   // virtual RTC::ReturnCode_t onAborting(RTC::UniqueId ec_id);
00081 
00082   // The error action in ERROR state
00083   // former rtc_error_do()
00084   // virtual RTC::ReturnCode_t onError(RTC::UniqueId ec_id);
00085 
00086   // The reset action that is invoked resetting
00087   // This is same but different the former rtc_init_entry()
00088   // virtual RTC::ReturnCode_t onReset(RTC::UniqueId ec_id);
00089   
00090   // The state update action that is invoked after onExecute() action
00091   // no corresponding operation exists in OpenRTm-aist-0.2.0
00092   // virtual RTC::ReturnCode_t onStateUpdate(RTC::UniqueId ec_id);
00093 
00094   // The action that is invoked when execution context's rate is changed
00095   // no corresponding operation exists in OpenRTm-aist-0.2.0
00096   // virtual RTC::ReturnCode_t onRateChanged(RTC::UniqueId ec_id);
00097 
00098 
00099  protected:
00100   // Configuration variable declaration
00101   // <rtc-template block="config_declare">
00102   
00103   // </rtc-template>
00104 
00105   // DataInPort declaration
00106   // <rtc-template block="inport_declare">
00107   TimedDoubleSeq m_angle;
00108   InPort<TimedDoubleSeq> m_angleIn;
00109   TimedDoubleSeq m_rhsensor;
00110   InPort<TimedDoubleSeq> m_rhsensorIn;
00111   
00112   // </rtc-template>
00113 
00114   // DataOutPort declaration
00115   // <rtc-template block="outport_declare">
00116   TimedDoubleSeq m_torque;
00117   OutPort<TimedDoubleSeq> m_torqueOut;
00118   //TimedDoubleSeq m_q;
00119   //OutPort<TimedDoubleSeq> m_qOut;
00120   //TimedDoubleSeq m_dq;
00121   //OutPort<TimedDoubleSeq> m_dqOut;
00122   //TimedDoubleSeq m_ddq;
00123   //OutPort<TimedDoubleSeq> m_ddqOut;
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 angle, vel;
00145   double *Pgain;
00146   double *Dgain;
00147   double* qold;
00148 
00149   bool goal_set;
00150   bool pattern;
00151   double q_ref[DOF], dq_ref[DOF];
00152   double remain_t;
00153   double q_goal[DOF], dq_goal[DOF];
00154   int step;
00155   std::ofstream out;
00156   void openFiles();
00157   void closeFiles();
00158 
00159 };
00160 
00161 
00162 extern "C"
00163 {
00164   DLL_EXPORT void SampleControllerInit(RTC::Manager* manager);
00165 };
00166 
00167 #endif // SAMPLECONTROLLER_H


openhrp3
Author(s): AIST, General Robotix Inc., Nakamura Lab of Dept. of Mechano Informatics at University of Tokyo
autogenerated on Sun Apr 2 2017 03:43:56