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 
45 {
46  public:
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;
109  TimedDoubleSeq m_rhsensor;
111 
112  // </rtc-template>
113 
114  // DataOutPort declaration
115  // <rtc-template block="outport_declare">
116  TimedDoubleSeq m_torque;
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 {
165 };
166 
167 #endif // SAMPLECONTROLLER_H
ec_id
InPort< TimedDoubleSeq > m_rhsensorIn
manager
OutPort< TimedDoubleSeq > m_torqueOut
#define DOF
TimedDoubleSeq m_angle
std::ifstream vel
DLL_EXPORT void SampleControllerInit(RTC::Manager *manager)
ExecutionContextHandle_t UniqueId
TimedDoubleSeq m_rhsensor
std::ofstream out
TimedDoubleSeq m_torque
InPort< TimedDoubleSeq > m_angleIn
#define DLL_EXPORT


openhrp3
Author(s): AIST, General Robotix Inc., Nakamura Lab of Dept. of Mechano Informatics at University of Tokyo
autogenerated on Sat May 8 2021 02:42:40