SampleController.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 /*
3  * Copyright (c) 2008, AIST, the University of Tokyo and General Robotix Inc.
4  * All rights reserved. This program is made available under the terms of the
5  * Eclipse Public License v1.0 which accompanies this distribution, and is
6  * available at http://www.eclipse.org/legal/epl-v10.html
7  * Contributors:
8  * National Institute of Advanced Industrial Science and Technology (AIST)
9  * General Robotix Inc.
10  */
19 #ifndef SAMPLECONTROLLER_H
20 #define SAMPLECONTROLLER_H
21 #define DOF (29)
22 
23 #include <rtm/idl/BasicDataType.hh>
24 #include <rtm/Manager.h>
25 #include <rtm/DataFlowComponentBase.h>
26 #include <rtm/CorbaPort.h>
27 #include <rtm/DataInPort.h>
28 #include <rtm/DataOutPort.h>
29 #include <rtm/idl/BasicDataTypeSkel.h>
30 
31 // Service implementation headers
32 // <rtc-template block="service_impl_h">
33 
34 // </rtc-template>
35 
36 // Service Consumer stub headers
37 // <rtc-template block="consumer_stub_h">
38 
39 // </rtc-template>
40 
41 using namespace RTC;
42 
44  : public RTC::DataFlowComponentBase
45 {
46  public:
47  SampleController(RTC::Manager* manager);
49 
50  // The initialize action (on CREATED->ALIVE transition)
51  // formaer rtc_init_entry()
52  virtual RTC::ReturnCode_t onInitialize();
53 
54  // The finalize action (on ALIVE->END transition)
55  // formaer rtc_exiting_entry()
56  virtual RTC::ReturnCode_t onFinalize();
57 
58  // The startup action when ExecutionContext startup
59  // former rtc_starting_entry()
60  // virtual RTC::ReturnCode_t onStartup(RTC::UniqueId ec_id);
61 
62  // The shutdown action when ExecutionContext stop
63  // former rtc_stopping_entry()
64  // virtual RTC::ReturnCode_t onShutdown(RTC::UniqueId ec_id);
65 
66  // The activated action (Active state entry action)
67  // former rtc_active_entry()
68  virtual RTC::ReturnCode_t onActivated(RTC::UniqueId ec_id);
69 
70  // The deactivated action (Active state exit action)
71  // former rtc_active_exit()
72  virtual RTC::ReturnCode_t onDeactivated(RTC::UniqueId ec_id);
73 
74  // The execution action that is invoked periodically
75  // former rtc_active_do()
76  virtual RTC::ReturnCode_t onExecute(RTC::UniqueId ec_id);
77 
78  // The aborting action when main logic error occurred.
79  // former rtc_aborting_entry()
80  // virtual RTC::ReturnCode_t onAborting(RTC::UniqueId ec_id);
81 
82  // The error action in ERROR state
83  // former rtc_error_do()
84  // virtual RTC::ReturnCode_t onError(RTC::UniqueId ec_id);
85 
86  // The reset action that is invoked resetting
87  // This is same but different the former rtc_init_entry()
88  // virtual RTC::ReturnCode_t onReset(RTC::UniqueId ec_id);
89 
90  // The state update action that is invoked after onExecute() action
91  // no corresponding operation exists in OpenRTm-aist-0.2.0
92  // virtual RTC::ReturnCode_t onStateUpdate(RTC::UniqueId ec_id);
93 
94  // The action that is invoked when execution context's rate is changed
95  // no corresponding operation exists in OpenRTm-aist-0.2.0
96  // virtual RTC::ReturnCode_t onRateChanged(RTC::UniqueId ec_id);
97 
98 
99  protected:
100  // Configuration variable declaration
101  // <rtc-template block="config_declare">
102 
103  // </rtc-template>
104 
105  // DataInPort declaration
106  // <rtc-template block="inport_declare">
107  TimedDoubleSeq m_angle;
108  InPort<TimedDoubleSeq> m_angleIn;
109  TimedDoubleSeq m_rhsensor;
110  InPort<TimedDoubleSeq> m_rhsensorIn;
111 
112  // </rtc-template>
113 
114  // DataOutPort declaration
115  // <rtc-template block="outport_declare">
116  TimedDoubleSeq m_torque;
117  OutPort<TimedDoubleSeq> m_torqueOut;
118  //TimedDoubleSeq m_q;
119  //OutPort<TimedDoubleSeq> m_qOut;
120  //TimedDoubleSeq m_dq;
121  //OutPort<TimedDoubleSeq> m_dqOut;
122  //TimedDoubleSeq m_ddq;
123  //OutPort<TimedDoubleSeq> m_ddqOut;
124 
125  // </rtc-template>
126 
127  // CORBA Port declaration
128  // <rtc-template block="corbaport_declare">
129 
130  // </rtc-template>
131 
132  // Service declaration
133  // <rtc-template block="service_declare">
134 
135  // </rtc-template>
136 
137  // Consumer declaration
138  // <rtc-template block="consumer_declare">
139 
140  // </rtc-template>
141 
142  private:
143  int dummy;
144  std::ifstream angle, vel;
145  double *Pgain;
146  double *Dgain;
147  double* qold;
148 
149  bool goal_set;
150  bool pattern;
151  double q_ref[DOF], dq_ref[DOF];
152  double remain_t;
153  double q_goal[DOF], dq_goal[DOF];
154  int step;
155  std::ofstream out;
156  void openFiles();
157  void closeFiles();
158 
159 };
160 
161 
162 extern "C"
163 {
164  DLL_EXPORT void SampleControllerInit(RTC::Manager* manager);
165 };
166 
167 #endif // SAMPLECONTROLLER_H
SampleController::qold
double * qold
Definition: SampleController.h:147
SampleController::vel
std::ifstream vel
Definition: SampleController.h:144
SampleController::remain_t
double remain_t
Definition: SampleController.h:152
SampleControllerInit
DLL_EXPORT void SampleControllerInit(RTC::Manager *manager)
Definition: SampleController.cpp:385
SampleController::goal_set
bool goal_set
Definition: SampleController.h:149
SampleController::m_torqueOut
OutPort< TimedDoubleSeq > m_torqueOut
Definition: SampleController.h:117
SampleController::m_angleIn
InPort< TimedDoubleSeq > m_angleIn
Definition: SampleController.h:108
SampleController::dummy
int dummy
Definition: SampleController.h:143
DOF
#define DOF
Definition: SampleController.h:21
DLL_EXPORT
#define DLL_EXPORT
Definition: bush_customizer.cpp:20
SampleController::Dgain
double * Dgain
Definition: SampleController.h:146
SampleController
Definition: SampleController.h:43
SampleController::Pgain
double * Pgain
Definition: SampleController.h:145
SampleController::m_rhsensorIn
InPort< TimedDoubleSeq > m_rhsensorIn
Definition: SampleController.h:110
SampleController::m_rhsensor
TimedDoubleSeq m_rhsensor
Definition: SampleController.h:109
SampleController::step
int step
Definition: SampleController.h:154
SampleController::out
std::ofstream out
Definition: SampleController.h:155
SampleController::m_angle
TimedDoubleSeq m_angle
Definition: SampleController.h:107
SampleController::m_torque
TimedDoubleSeq m_torque
Definition: SampleController.h:116
RTC
Definition: SimulationExecutionContext.cpp:7
SampleController::pattern
bool pattern
Definition: SampleController.h:150


openhrp3
Author(s): AIST, General Robotix Inc., Nakamura Lab of Dept. of Mechano Informatics at University of Tokyo
autogenerated on Wed Sep 7 2022 02:51:04