-
Notifications
You must be signed in to change notification settings - Fork 1
/
sony.h
188 lines (150 loc) · 5.4 KB
/
sony.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
// -*- C++ -*-
/*!
* @file sony.h * @brief sonyComponent * @date $Date$
*
* $Id$
*/
#ifndef SONY_H
#define SONY_H
#include <rtm/idl/BasicDataTypeSkel.h>
#include <rtm/Manager.h>
#include <rtm/DataFlowComponentBase.h>
#include <rtm/CorbaPort.h>
#include <rtm/DataInPort.h>
#include <rtm/DataOutPort.h>
//add
#include <rtm/CorbaNaming.h>
#include "hrp2Base.h"
// Service implementation headers
// <rtc-template block="service_impl_h">
#include "sonyService_impl.h"
// </rtc-template>
// Service Consumer stub headers
// <rtc-template block="consumer_stub_h">
// </rtc-template>
using namespace RTC;
class sony : public hrp2Base
{
public:
sony(RTC::Manager* manager);
~sony();
// The initialize action (on CREATED->ALIVE transition)
// formaer rtc_init_entry()
virtual RTC::ReturnCode_t onInitialize();
// The finalize action (on ALIVE->END transition)
// formaer rtc_exiting_entry()
// virtual RTC::ReturnCode_t onFinalize();
// The startup action when ExecutionContext startup
// former rtc_starting_entry()
// virtual RTC::ReturnCode_t onStartup(RTC::UniqueId ec_id);
// The shutdown action when ExecutionContext stop
// former rtc_stopping_entry()
// virtual RTC::ReturnCode_t onShutdown(RTC::UniqueId ec_id);
// The activated action (Active state entry action)
// former rtc_active_entry()
// virtual RTC::ReturnCode_t onActivated(RTC::UniqueId ec_id);
// The deactivated action (Active state exit action)
// former rtc_active_exit()
// virtual RTC::ReturnCode_t onDeactivated(RTC::UniqueId ec_id);
// The execution action that is invoked periodically
// former rtc_active_do()
virtual RTC::ReturnCode_t onExecute(RTC::UniqueId ec_id);
// The aborting action when main logic error occurred.
// former rtc_aborting_entry()
// virtual RTC::ReturnCode_t onAborting(RTC::UniqueId ec_id);
// The error action in ERROR state
// former rtc_error_do()
// virtual RTC::ReturnCode_t onError(RTC::UniqueId ec_id);
// The reset action that is invoked resetting
// This is same but different the former rtc_init_entry()
// virtual RTC::ReturnCode_t onReset(RTC::UniqueId ec_id);
// The state update action that is invoked after onExecute() action
// no corresponding operation exists in OpenRTm-aist-0.2.0
// virtual RTC::ReturnCode_t onStateUpdate(RTC::UniqueId ec_id);
// The action that is invoked when execution context's rate is changed
// no corresponding operation exists in OpenRTm-aist-0.2.0
// virtual RTC::ReturnCode_t onRateChanged(RTC::UniqueId ec_id);
//function
inline void rzmp2st();
inline void calcWholeIVK();
inline void zmpHandler();
inline void getInvResult();
inline void object_operate();
inline void calcRefLeg();
inline void prmGenerator(bool &calczmpflag);
int stepLength(FootType FT, ZmpPlaner *zmpP);
void waitingMotion(Vector3 &cm_ref, PreviewControl *PC);
void start2walk(BodyPtr m_robot, ZmpPlaner *zmpP, PreviewControl *PC, bool &stopflag, Vector3 cm_ref);
void prm2Planzmp(FootType FT, Vector3 *p_ref, Matrix3 *R_ref, Vector3 RLEG_ref_p, Vector3 LLEG_ref_p, Matrix3 LEG_ref_R, std::deque<vector2> &rfzmp, ZmpPlaner *zmpP);
void walkingMotion(BodyPtr m_robot, FootType FT, Vector3 &cm_ref, Vector3 &absZMP, Vector3 *p_Init, Vector3 *p_ref, Matrix3 *R_ref, std::deque<vector2> &rfzmp, PreviewControl *PC, ZmpPlaner *zmpP, int &count);
bool ChangeSupLeg(BodyPtr m_robot, FootType &FT, int &count, ZmpPlaner *zmpP, PreviewControl *PC, bool &stopflag, int &CommandIn, Vector3 *p_now, Vector3 *p_Init, Matrix3 *R_now, Matrix3 *R_Init);
void IniNewStep(BodyPtr m_robot, FootType &FT, int &count, ZmpPlaner *zmpP, PreviewControl *PC, bool &stopflag, int &CommandIn, Vector3 *p_ref, Vector3 *p_Init, Matrix3 *R_ref, Matrix3 *R_Init);
//service port
void start();
void testMove();
void stepping();
void setObjectV(double x, double y, double z, double roll, double pitch, double yaw);
protected:
// DataInPort declaration
RTC::TimedFloatSeq m_axes;
RTC::InPort<RTC::TimedFloatSeq> m_axesIn;
RTC::TimedBooleanSeq m_buttons;
RTC::InPort<RTC::TimedBooleanSeq> m_buttonsIn;
// DataOutPort declaration
RTC::TimedBooleanSeq m_light;
RTC::OutPort<RTC::TimedBooleanSeq> m_lightOut;
RTC::TimedDoubleSeq m_localEEpos;
RTC::OutPort<RTC::TimedDoubleSeq> m_localEEposOut;
// CORBA Port declaration
// <rtc-template block="corbaport_declare">
RTC::CorbaPort m_sonyServicePort;
// </rtc-template>
// Service declaration
// <rtc-template block="service_declare">
sonyService_impl m_service0;
// </rtc-template>
// Consumer declaration
// <rtc-template block="consumer_declare">
// </rtc-template>
private:
bool playflag;
bool stopflag;
int count;
int m_nStep;
int step_counter;
bool flagcalczmp;
int CommandIn;
double time2Neutral;
//Path planning
Vector3 p_obj2RLEG,p_obj2LLEG;
Matrix3 R_LEG_ini;
Vector3 RLEG_ref_p,LLEG_ref_p;
Matrix3 LEG_ref_R;
vector6 velobj;
Link* object_ref;
double yawTotal;
Matrix3 rotRTemp;
Vector3 pivot_localposIni;
bool step;
//test para
std::deque<vector32> bodyDeque;
vector32 body_cur;
vector32 body_ref;
Link* pt;
Link* pt_L;
Link* pt_R;
JointPathPtr s2sw_R;
JointPathPtr s2sw_L;
Vector3 p_ref_toe[LINKNUM];
Matrix3 R_ref_toe[LINKNUM];
bool usePivot;
double cm_offset_x;
//Eigen::MatrixXd gh;
//for joystick
bool buttom_accept;
};
extern "C"
{
DLL_EXPORT void sonyInit(RTC::Manager* manager);
};
#endif // SONY_H