@@ -45,17 +45,16 @@ int main(int argc, char const *argv[]) {
45
45
}
46
46
}
47
47
48
- unitree::robot::ChannelFactory::Instance ()->Init (0 ,
49
- args[" network_interface" ]);
48
+ unitree::robot::ChannelFactory::Instance ()->Init (0 , args[" network_interface" ]);
50
49
51
50
unitree::robot::h1::LocoClient client;
52
51
53
52
client.Init ();
54
53
client.SetTimeout (10 .f );
55
54
56
55
for (const auto &arg_pair : args) {
57
- std::cout << " Processing command: [" << arg_pair.first << " ] with param: ["
58
- << arg_pair. second << " ] ... " << std::endl;
56
+ std::cout << " Processing command: [" << arg_pair.first << " ] with param: [" << arg_pair. second << " ] ... "
57
+ << std::endl;
59
58
if (arg_pair.first == " network_interface" ) {
60
59
continue ;
61
60
}
@@ -100,6 +99,24 @@ int main(int argc, char const *argv[]) {
100
99
std::cout << " )" << std::endl;
101
100
}
102
101
102
+ if (arg_pair.first == " enable_odom" ) {
103
+ float x, y, yaw;
104
+ client.EnableOdom ();
105
+ std::cout << " Send enable odom signal" << std::endl;
106
+ }
107
+
108
+ if (arg_pair.first == " disable_odom" ) {
109
+ float x, y, yaw;
110
+ client.DisableOdom ();
111
+ std::cout << " Send disable odom signal" << std::endl;
112
+ }
113
+
114
+ if (arg_pair.first == " get_odom" ) {
115
+ float x, y, yaw;
116
+ client.GetOdom (x, y, yaw);
117
+ std::cout << " Get Odom: (" << x << " , " << y << " , " << yaw << " )" << std::endl;
118
+ }
119
+
103
120
if (arg_pair.first == " set_fsm_id" ) {
104
121
int fsm_id = std::stoi (arg_pair.second );
105
122
client.SetFsmId (fsm_id);
@@ -139,8 +156,7 @@ int main(int argc, char const *argv[]) {
139
156
omega = param.at (2 );
140
157
duration = param.at (3 );
141
158
} else {
142
- std::cerr << " Invalid param size for method SetVelocity: " << param_size
143
- << std::endl;
159
+ std::cerr << " Invalid param size for method SetVelocity: " << param_size << std::endl;
144
160
return 1 ;
145
161
}
146
162
@@ -155,12 +171,23 @@ int main(int argc, char const *argv[]) {
155
171
client.SetPhase (param);
156
172
std::cout << " set phase to " << arg_pair.second << std::endl;
157
173
} else {
158
- std::cerr << " Invalid param size for method SetPhase: " << param_size
159
- << std::endl;
174
+ std::cerr << " Invalid param size for method SetPhase: " << param_size << std::endl;
160
175
return 1 ;
161
176
}
162
177
}
163
178
179
+ if (arg_pair.first == " set_target_pos" ) {
180
+ std::vector<float > param = stringToFloatVector (arg_pair.second );
181
+ client.SetTargetPos (param.at (0 ), param.at (1 ), param.at (2 ), false );
182
+ std::cout << " set_target_pos: " << arg_pair.second << std::endl;
183
+ }
184
+
185
+ if (arg_pair.first == " set_target_pos_relative" ) {
186
+ std::vector<float > param = stringToFloatVector (arg_pair.second );
187
+ client.SetTargetPos (param.at (0 ), param.at (1 ), param.at (2 ));
188
+ std::cout << " set_target_pos: " << arg_pair.second << std::endl;
189
+ }
190
+
164
191
if (arg_pair.first == " damp" ) {
165
192
client.Damp ();
166
193
}
@@ -228,8 +255,7 @@ int main(int argc, char const *argv[]) {
228
255
vy = param.at (1 );
229
256
omega = param.at (2 );
230
257
} else {
231
- std::cerr << " Invalid param size for method SetVelocity: " << param_size
232
- << std::endl;
258
+ std::cerr << " Invalid param size for method SetVelocity: " << param_size << std::endl;
233
259
return 1 ;
234
260
}
235
261
client.Move (vx, vy, omega);
@@ -246,8 +272,28 @@ int main(int argc, char const *argv[]) {
246
272
return 1 ;
247
273
}
248
274
client.SetNextFoot (flag);
249
- std::cout << " Done!" << std::endl;
250
275
}
276
+
277
+ if (arg_pair.first == " set_task_id" ) {
278
+ int task_id = std::stoi (arg_pair.second );
279
+ client.SetTaskId (task_id);
280
+ std::cout << " set task_id to " << task_id << std::endl;
281
+ }
282
+
283
+ if (arg_pair.first == " shake_hand" ) {
284
+ client.ShakeHand (0 );
285
+ std::cout << " Shake hand starts! Waiting for 10 s for ending" << std::endl;
286
+ std::this_thread::sleep_for (std::chrono::seconds (10 ));
287
+ std::cout << " Shake hand ends!" << std::endl;
288
+ client.ShakeHand (1 );
289
+ }
290
+
291
+ if (arg_pair.first == " wave_hand" ) {
292
+ client.WaveHand ();
293
+ std::cout << " wave hand" << std::endl;
294
+ }
295
+
296
+ std::cout << " Done!" << std::endl;
251
297
}
252
298
253
299
return 0 ;
0 commit comments