@@ -45,17 +45,16 @@ int main(int argc, char const *argv[]) {
4545 }
4646 }
4747
48- unitree::robot::ChannelFactory::Instance ()->Init (0 ,
49- args[" network_interface" ]);
48+ unitree::robot::ChannelFactory::Instance ()->Init (0 , args[" network_interface" ]);
5049
5150 unitree::robot::h1::LocoClient client;
5251
5352 client.Init ();
5453 client.SetTimeout (10 .f );
5554
5655 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;
5958 if (arg_pair.first == " network_interface" ) {
6059 continue ;
6160 }
@@ -100,6 +99,24 @@ int main(int argc, char const *argv[]) {
10099 std::cout << " )" << std::endl;
101100 }
102101
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+
103120 if (arg_pair.first == " set_fsm_id" ) {
104121 int fsm_id = std::stoi (arg_pair.second );
105122 client.SetFsmId (fsm_id);
@@ -139,8 +156,7 @@ int main(int argc, char const *argv[]) {
139156 omega = param.at (2 );
140157 duration = param.at (3 );
141158 } 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;
144160 return 1 ;
145161 }
146162
@@ -155,12 +171,23 @@ int main(int argc, char const *argv[]) {
155171 client.SetPhase (param);
156172 std::cout << " set phase to " << arg_pair.second << std::endl;
157173 } 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;
160175 return 1 ;
161176 }
162177 }
163178
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+
164191 if (arg_pair.first == " damp" ) {
165192 client.Damp ();
166193 }
@@ -228,8 +255,7 @@ int main(int argc, char const *argv[]) {
228255 vy = param.at (1 );
229256 omega = param.at (2 );
230257 } 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;
233259 return 1 ;
234260 }
235261 client.Move (vx, vy, omega);
@@ -246,8 +272,28 @@ int main(int argc, char const *argv[]) {
246272 return 1 ;
247273 }
248274 client.SetNextFoot (flag);
249- std::cout << " Done!" << std::endl;
250275 }
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;
251297 }
252298
253299 return 0 ;
0 commit comments