54 g_wholebody_ini_pose_pub = nh.
advertise<std_msgs::String>(
"/robotis/base/ini_pose", 0);
55 g_enable_ctrl_module_pub = nh.
advertise<std_msgs::String>(
"/robotis/enable_ctrl_module", 0);
57 g_get_ref_step_data_client = nh.
serviceClient<thormang3_walking_module_msgs::GetReferenceStepData>(
"/robotis/walking/get_reference_step_data");
58 g_add_step_data_array_client = nh.
serviceClient<thormang3_walking_module_msgs::AddStepDataArray>(
"/robotis/walking/add_step_data");
59 g_is_running_client = nh.
serviceClient<thormang3_walking_module_msgs::IsRunning>(
"/robotis/walking/is_running");
61 g_set_balance_param_client = nh.
serviceClient<thormang3_walking_module_msgs::SetBalanceParam>(
"/robotis/walking/set_balance_param");
62 g_set_feedback_gain_client = nh.
serviceClient<thormang3_walking_module_msgs::SetJointFeedBackGain>(
"/robotis/walking/joint_feedback_gain");
69 std_msgs::String str_msg;
70 str_msg.data =
"ini_pose";
72 g_wholebody_ini_pose_pub.
publish( str_msg );
77 std_msgs::String set_ctrl_mode_msg;
78 set_ctrl_mode_msg.data =
"walking_module";
79 g_enable_ctrl_module_pub.
publish( set_ctrl_mode_msg );
85 std::string balance_yaml_path =
"";
92 doc = YAML::LoadFile(balance_yaml_path.c_str());
94 catch(
const std::exception& e)
96 ROS_ERROR(
"Failed to load balance param yaml file.");
100 double cob_x_offset_m = doc[
"cob_x_offset_m"].as<
double>();
101 double cob_y_offset_m = doc[
"cob_y_offset_m"].as<
double>();
103 double hip_roll_swap_angle_rad = doc[
"hip_roll_swap_angle_rad"].as<
double>();
105 double foot_roll_gyro_p_gain = doc[
"foot_roll_gyro_p_gain"].as<
double>();
106 double foot_roll_gyro_d_gain = doc[
"foot_roll_gyro_d_gain"].as<
double>();
107 double foot_pitch_gyro_p_gain = doc[
"foot_pitch_gyro_p_gain"].as<
double>();
108 double foot_pitch_gyro_d_gain = doc[
"foot_pitch_gyro_d_gain"].as<
double>();
110 double foot_roll_angle_p_gain = doc[
"foot_roll_angle_p_gain"].as<
double>();
111 double foot_roll_angle_d_gain = doc[
"foot_roll_angle_d_gain"].as<
double>();
112 double foot_pitch_angle_p_gain = doc[
"foot_pitch_angle_p_gain"].as<
double>();
113 double foot_pitch_angle_d_gain = doc[
"foot_pitch_angle_d_gain"].as<
double>();
115 double foot_x_force_p_gain = doc[
"foot_x_force_p_gain"].as<
double>();
116 double foot_x_force_d_gain = doc[
"foot_x_force_d_gain"].as<
double>();
117 double foot_y_force_p_gain = doc[
"foot_y_force_p_gain"].as<
double>();
118 double foot_y_force_d_gain = doc[
"foot_y_force_d_gain"].as<
double>();
119 double foot_z_force_p_gain = doc[
"foot_z_force_p_gain"].as<
double>();
120 double foot_z_force_d_gain = doc[
"foot_z_force_d_gain"].as<
double>();
121 double foot_roll_torque_p_gain = doc[
"foot_roll_torque_p_gain"].as<
double>();
122 double foot_roll_torque_d_gain = doc[
"foot_roll_torque_d_gain"].as<
double>();
123 double foot_pitch_torque_p_gain = doc[
"foot_pitch_torque_p_gain"].as<
double>();
124 double foot_pitch_torque_d_gain = doc[
"foot_pitch_torque_d_gain"].as<
double>();
126 double roll_gyro_cut_off_frequency = doc[
"roll_gyro_cut_off_frequency"].as<
double>();
127 double pitch_gyro_cut_off_frequency = doc[
"pitch_gyro_cut_off_frequency"].as<
double>();
128 double roll_angle_cut_off_frequency = doc[
"roll_angle_cut_off_frequency"].as<
double>();
129 double pitch_angle_cut_off_frequency = doc[
"pitch_angle_cut_off_frequency"].as<
double>();
130 double foot_x_force_cut_off_frequency = doc[
"foot_x_force_cut_off_frequency"].as<
double>();
131 double foot_y_force_cut_off_frequency = doc[
"foot_y_force_cut_off_frequency"].as<
double>();
132 double foot_z_force_cut_off_frequency = doc[
"foot_z_force_cut_off_frequency"].as<
double>();
133 double foot_roll_torque_cut_off_frequency = doc[
"foot_roll_torque_cut_off_frequency"].as<
double>();
134 double foot_pitch_torque_cut_off_frequency = doc[
"foot_pitch_torque_cut_off_frequency"].as<
double>();
136 set_param.request.balance_param.cob_x_offset_m = cob_x_offset_m;
137 set_param.request.balance_param.cob_y_offset_m = cob_y_offset_m;
138 set_param.request.balance_param.hip_roll_swap_angle_rad = hip_roll_swap_angle_rad;
139 set_param.request.balance_param.foot_roll_gyro_p_gain = foot_roll_gyro_p_gain;
140 set_param.request.balance_param.foot_roll_gyro_d_gain = foot_roll_gyro_d_gain;
141 set_param.request.balance_param.foot_pitch_gyro_p_gain = foot_pitch_gyro_p_gain;
142 set_param.request.balance_param.foot_pitch_gyro_d_gain = foot_pitch_gyro_d_gain;
143 set_param.request.balance_param.foot_roll_angle_p_gain = foot_roll_angle_p_gain;
144 set_param.request.balance_param.foot_roll_angle_d_gain = foot_roll_angle_d_gain;
145 set_param.request.balance_param.foot_pitch_angle_p_gain = foot_pitch_angle_p_gain;
146 set_param.request.balance_param.foot_pitch_angle_d_gain = foot_pitch_angle_d_gain;
147 set_param.request.balance_param.foot_x_force_p_gain = foot_x_force_p_gain;
148 set_param.request.balance_param.foot_x_force_d_gain = foot_x_force_d_gain;
149 set_param.request.balance_param.foot_y_force_p_gain = foot_y_force_p_gain;
150 set_param.request.balance_param.foot_y_force_d_gain = foot_y_force_d_gain;
151 set_param.request.balance_param.foot_z_force_p_gain = foot_z_force_p_gain;
152 set_param.request.balance_param.foot_z_force_d_gain = foot_z_force_d_gain;
153 set_param.request.balance_param.foot_roll_torque_p_gain = foot_roll_torque_p_gain;
154 set_param.request.balance_param.foot_roll_torque_d_gain = foot_roll_torque_d_gain;
155 set_param.request.balance_param.foot_pitch_torque_p_gain = foot_pitch_torque_p_gain;
156 set_param.request.balance_param.foot_pitch_torque_d_gain = foot_pitch_torque_d_gain;
157 set_param.request.balance_param.roll_gyro_cut_off_frequency = roll_gyro_cut_off_frequency;
158 set_param.request.balance_param.pitch_gyro_cut_off_frequency = pitch_gyro_cut_off_frequency;
159 set_param.request.balance_param.roll_angle_cut_off_frequency = roll_angle_cut_off_frequency;
160 set_param.request.balance_param.pitch_angle_cut_off_frequency = pitch_angle_cut_off_frequency;
161 set_param.request.balance_param.foot_x_force_cut_off_frequency = foot_x_force_cut_off_frequency;
162 set_param.request.balance_param.foot_y_force_cut_off_frequency = foot_y_force_cut_off_frequency;
163 set_param.request.balance_param.foot_z_force_cut_off_frequency = foot_z_force_cut_off_frequency;
164 set_param.request.balance_param.foot_roll_torque_cut_off_frequency = foot_roll_torque_cut_off_frequency;
165 set_param.request.balance_param.foot_pitch_torque_cut_off_frequency = foot_pitch_torque_cut_off_frequency;
173 std::string feedback_gain_yaml_path =
"";
174 feedback_gain_yaml_path =
ros::package::getPath(
"thormang3_walking_demo") +
"/data/joint_feedback_gain.yaml";
180 doc = YAML::LoadFile(feedback_gain_yaml_path.c_str());
182 catch(
const std::exception& e)
184 ROS_ERROR(
"Failed to load feedback gain yaml file.");
188 double r_leg_hip_y_p_gain = doc[
"r_leg_hip_y_p_gain"].as<
double>();
189 double r_leg_hip_y_d_gain = doc[
"r_leg_hip_y_d_gain"].as<
double>();
190 double r_leg_hip_r_p_gain = doc[
"r_leg_hip_r_p_gain"].as<
double>();
191 double r_leg_hip_r_d_gain = doc[
"r_leg_hip_r_d_gain"].as<
double>();
192 double r_leg_hip_p_p_gain = doc[
"r_leg_hip_p_p_gain"].as<
double>();
193 double r_leg_hip_p_d_gain = doc[
"r_leg_hip_p_d_gain"].as<
double>();
194 double r_leg_kn_p_p_gain = doc[
"r_leg_kn_p_p_gain"].as<
double>();
195 double r_leg_kn_p_d_gain = doc[
"r_leg_kn_p_d_gain"].as<
double>();
196 double r_leg_an_p_p_gain = doc[
"r_leg_an_p_p_gain"].as<
double>();
197 double r_leg_an_p_d_gain = doc[
"r_leg_an_p_d_gain"].as<
double>();
198 double r_leg_an_r_p_gain = doc[
"r_leg_an_r_p_gain"].as<
double>();
199 double r_leg_an_r_d_gain = doc[
"r_leg_an_r_d_gain"].as<
double>();
200 double l_leg_hip_y_p_gain = doc[
"l_leg_hip_y_p_gain"].as<
double>();
201 double l_leg_hip_y_d_gain = doc[
"l_leg_hip_y_d_gain"].as<
double>();
202 double l_leg_hip_r_p_gain = doc[
"l_leg_hip_r_p_gain"].as<
double>();
203 double l_leg_hip_r_d_gain = doc[
"l_leg_hip_r_d_gain"].as<
double>();
204 double l_leg_hip_p_p_gain = doc[
"l_leg_hip_p_p_gain"].as<
double>();
205 double l_leg_hip_p_d_gain = doc[
"l_leg_hip_p_d_gain"].as<
double>();
206 double l_leg_kn_p_p_gain = doc[
"l_leg_kn_p_p_gain"].as<
double>();
207 double l_leg_kn_p_d_gain = doc[
"l_leg_kn_p_d_gain"].as<
double>();
208 double l_leg_an_p_p_gain = doc[
"l_leg_an_p_p_gain"].as<
double>();
209 double l_leg_an_p_d_gain = doc[
"l_leg_an_p_d_gain"].as<
double>();
210 double l_leg_an_r_p_gain = doc[
"l_leg_an_r_p_gain"].as<
double>();
211 double l_leg_an_r_d_gain = doc[
"l_leg_an_r_d_gain"].as<
double>();
213 set_gain.request.feedback_gain.r_leg_hip_y_p_gain = r_leg_hip_y_p_gain;
214 set_gain.request.feedback_gain.r_leg_hip_y_d_gain = r_leg_hip_y_d_gain;
215 set_gain.request.feedback_gain.r_leg_hip_r_p_gain = r_leg_hip_r_p_gain;
216 set_gain.request.feedback_gain.r_leg_hip_r_d_gain = r_leg_hip_r_d_gain;
217 set_gain.request.feedback_gain.r_leg_hip_p_p_gain = r_leg_hip_p_p_gain;
218 set_gain.request.feedback_gain.r_leg_hip_p_d_gain = r_leg_hip_p_d_gain;
219 set_gain.request.feedback_gain.r_leg_kn_p_p_gain = r_leg_kn_p_p_gain ;
220 set_gain.request.feedback_gain.r_leg_kn_p_d_gain = r_leg_kn_p_d_gain ;
221 set_gain.request.feedback_gain.r_leg_an_p_p_gain = r_leg_an_p_p_gain ;
222 set_gain.request.feedback_gain.r_leg_an_p_d_gain = r_leg_an_p_d_gain ;
223 set_gain.request.feedback_gain.r_leg_an_r_p_gain = r_leg_an_r_p_gain ;
224 set_gain.request.feedback_gain.r_leg_an_r_d_gain = r_leg_an_r_d_gain ;
225 set_gain.request.feedback_gain.l_leg_hip_y_p_gain = l_leg_hip_y_p_gain;
226 set_gain.request.feedback_gain.l_leg_hip_y_d_gain = l_leg_hip_y_d_gain;
227 set_gain.request.feedback_gain.l_leg_hip_r_p_gain = l_leg_hip_r_p_gain;
228 set_gain.request.feedback_gain.l_leg_hip_r_d_gain = l_leg_hip_r_d_gain;
229 set_gain.request.feedback_gain.l_leg_hip_p_p_gain = l_leg_hip_p_p_gain;
230 set_gain.request.feedback_gain.l_leg_hip_p_d_gain = l_leg_hip_p_d_gain;
231 set_gain.request.feedback_gain.l_leg_kn_p_p_gain = l_leg_kn_p_p_gain ;
232 set_gain.request.feedback_gain.l_leg_kn_p_d_gain = l_leg_kn_p_d_gain ;
233 set_gain.request.feedback_gain.l_leg_an_p_p_gain = l_leg_an_p_p_gain ;
234 set_gain.request.feedback_gain.l_leg_an_p_d_gain = l_leg_an_p_d_gain ;
235 set_gain.request.feedback_gain.l_leg_an_r_p_gain = l_leg_an_r_p_gain ;
236 set_gain.request.feedback_gain.l_leg_an_r_d_gain = l_leg_an_r_d_gain ;
245 thormang3_walking_module_msgs::SetBalanceParam set_balance_param_srv;
246 set_balance_param_srv.request.updating_duration = 2.0*1.0;
250 ROS_ERROR(
"[Demo] : Failed to Load Balance YAML");
255 if(g_set_balance_param_client.
call(set_balance_param_srv) ==
true)
257 int set_balance_param_srv_result = set_balance_param_srv.response.result;
258 if( set_balance_param_srv_result == thormang3_walking_module_msgs::SetBalanceParam::Response::NO_ERROR)
259 ROS_INFO(
"[Demo] : Succeed to set balance param");
262 if(set_balance_param_srv_result & thormang3_walking_module_msgs::SetBalanceParam::Response::NOT_ENABLED_WALKING_MODULE)
263 ROS_ERROR(
"[Demo] : BALANCE_PARAM_ERR::NOT_ENABLED_WALKING_MODULE");
264 if(set_balance_param_srv_result & thormang3_walking_module_msgs::SetBalanceParam::Response::PREV_REQUEST_IS_NOT_FINISHED)
265 ROS_ERROR(
"[Demo] : BALANCE_PARAM_ERR::PREV_REQUEST_IS_NOT_FINISHED");
272 ROS_ERROR(
"[Demo] : Failed to set balance param ");
276 thormang3_walking_module_msgs::SetJointFeedBackGain set_feedback_gain_srv;
277 set_feedback_gain_srv.request.updating_duration = 2.0*1.0;
281 ROS_ERROR(
"[Demo] : Failed to Load Balance YAML");
286 if(g_set_feedback_gain_client.
call(set_feedback_gain_srv) ==
true)
288 int set_feedback_gain_srv_result = set_feedback_gain_srv.response.result;
289 if( set_feedback_gain_srv_result == thormang3_walking_module_msgs::SetJointFeedBackGain::Response::NO_ERROR)
290 ROS_INFO(
"[Demo] : Succeed to set joint feedback gain");
293 if(set_feedback_gain_srv_result & thormang3_walking_module_msgs::SetJointFeedBackGain::Response::NOT_ENABLED_WALKING_MODULE)
294 ROS_ERROR(
"[Demo] : FEEDBACK_GAIN_ERR::NOT_ENABLED_WALKING_MODULE");
295 if(set_feedback_gain_srv_result & thormang3_walking_module_msgs::SetJointFeedBackGain::Response::PREV_REQUEST_IS_NOT_FINISHED)
296 ROS_ERROR(
"[Demo] : FEEDBACK_GAIN_ERR::PREV_REQUEST_IS_NOT_FINISHED");
301 ROS_ERROR(
"[Demo] : Failed to set joint feedback gain");
307 thormang3_walking_module_msgs::SetBalanceParam set_balance_param_srv;
308 set_balance_param_srv.request.updating_duration = 1.0;
312 ROS_ERROR(
"[Demo] : Failed to Load Balance YAML");
316 set_balance_param_srv.request.balance_param.hip_roll_swap_angle_rad = 0;
317 set_balance_param_srv.request.balance_param.foot_roll_gyro_p_gain = 0;
318 set_balance_param_srv.request.balance_param.foot_roll_gyro_d_gain = 0;
319 set_balance_param_srv.request.balance_param.foot_pitch_gyro_p_gain = 0;
320 set_balance_param_srv.request.balance_param.foot_pitch_gyro_d_gain = 0;
321 set_balance_param_srv.request.balance_param.foot_roll_angle_p_gain = 0;
322 set_balance_param_srv.request.balance_param.foot_roll_angle_d_gain = 0;
323 set_balance_param_srv.request.balance_param.foot_pitch_angle_p_gain = 0;
324 set_balance_param_srv.request.balance_param.foot_pitch_angle_d_gain = 0;
325 set_balance_param_srv.request.balance_param.foot_x_force_p_gain = 0;
326 set_balance_param_srv.request.balance_param.foot_x_force_d_gain = 0;
327 set_balance_param_srv.request.balance_param.foot_y_force_p_gain = 0;
328 set_balance_param_srv.request.balance_param.foot_y_force_d_gain = 0;
329 set_balance_param_srv.request.balance_param.foot_z_force_p_gain = 0;
330 set_balance_param_srv.request.balance_param.foot_z_force_d_gain = 0;
331 set_balance_param_srv.request.balance_param.foot_roll_torque_p_gain = 0;
332 set_balance_param_srv.request.balance_param.foot_roll_torque_d_gain = 0;
333 set_balance_param_srv.request.balance_param.foot_pitch_torque_p_gain = 0;
334 set_balance_param_srv.request.balance_param.foot_pitch_torque_d_gain = 0;
336 if(g_set_balance_param_client.
call(set_balance_param_srv) ==
true)
338 int set_balance_param_srv_result = set_balance_param_srv.response.result;
339 if( set_balance_param_srv_result == thormang3_walking_module_msgs::SetBalanceParam::Response::NO_ERROR)
340 ROS_INFO(
"[Demo] : Succeed to set balance param");
343 if(set_balance_param_srv_result & thormang3_walking_module_msgs::SetBalanceParam::Response::NOT_ENABLED_WALKING_MODULE)
344 ROS_ERROR(
"[Demo] : BALANCE_PARAM_ERR::NOT_ENABLED_WALKING_MODULE");
345 if(set_balance_param_srv_result & thormang3_walking_module_msgs::SetBalanceParam::Response::PREV_REQUEST_IS_NOT_FINISHED)
346 ROS_ERROR(
"[Demo] : BALANCE_PARAM_ERR::PREV_REQUEST_IS_NOT_FINISHED");
353 ROS_ERROR(
"[Demo] : Failed to set balance param ");
359 thormang3_walking_module_msgs::GetReferenceStepData get_ref_stp_data_srv;
360 thormang3_walking_module_msgs::AddStepDataArray add_stp_data_srv;
361 thormang3_walking_module_msgs::IsRunning is_running_srv;
362 thormang3_walking_module_msgs::StepData stp_data_msg;
364 if(g_is_running_client.
call(is_running_srv) ==
false)
366 ROS_ERROR(
"Failed to get walking_module status");
370 if(is_running_srv.response.is_running ==
true)
372 ROS_ERROR(
"[Demo] : ROBOT_IS_WALKING_NOW");
377 if(g_get_ref_step_data_client.
call(get_ref_stp_data_srv) ==
false)
378 ROS_ERROR(
"Failed to get reference step data");
380 stp_data_msg = get_ref_stp_data_srv.response.reference_step_data;
382 stp_data_msg.time_data.walking_state = thormang3_walking_module_msgs::StepTimeData::IN_WALKING_STARTING;
383 stp_data_msg.time_data.dsp_ratio = 0.2;
385 stp_data_msg.position_data.moving_foot = thormang3_walking_module_msgs::StepPositionData::STANDING;
386 stp_data_msg.position_data.body_z_swap = 0;
387 add_stp_data_srv.request.step_data_array.push_back(stp_data_msg);
389 stp_data_msg.time_data.walking_state = thormang3_walking_module_msgs::StepTimeData::IN_WALKING;
390 stp_data_msg.time_data.abs_step_time +=
g_step_time;
391 stp_data_msg.position_data.moving_foot = thormang3_walking_module_msgs::StepPositionData::RIGHT_FOOT_SWING;
394 stp_data_msg.position_data.right_foot_pose.x +=
g_step_length;
395 add_stp_data_srv.request.step_data_array.push_back(stp_data_msg);
397 stp_data_msg.time_data.walking_state = thormang3_walking_module_msgs::StepTimeData::IN_WALKING;
398 stp_data_msg.time_data.abs_step_time +=
g_step_time;
399 stp_data_msg.position_data.moving_foot = thormang3_walking_module_msgs::StepPositionData::LEFT_FOOT_SWING;
402 stp_data_msg.position_data.left_foot_pose.x +=
g_step_length;
403 add_stp_data_srv.request.step_data_array.push_back(stp_data_msg);
405 stp_data_msg.time_data.walking_state = thormang3_walking_module_msgs::StepTimeData::IN_WALKING_ENDING;
407 stp_data_msg.position_data.moving_foot = thormang3_walking_module_msgs::StepPositionData::STANDING;
408 stp_data_msg.position_data.body_z_swap = 0;
409 stp_data_msg.position_data.foot_z_swap = 0;
410 add_stp_data_srv.request.step_data_array.push_back(stp_data_msg);
412 add_stp_data_srv.request.auto_start =
true;
413 add_stp_data_srv.request.remove_existing_step_data =
true;
415 if(g_add_step_data_array_client.
call(add_stp_data_srv) ==
true)
417 int add_stp_data_srv_result = add_stp_data_srv.response.result;
418 if(add_stp_data_srv_result== thormang3_walking_module_msgs::AddStepDataArray::Response::NO_ERROR)
419 ROS_INFO(
"[Demo] : Succeed to add step data array");
422 ROS_ERROR(
"[Demo] : Failed to add step data array");
423 if(add_stp_data_srv_result & thormang3_walking_module_msgs::AddStepDataArray::Response::NOT_ENABLED_WALKING_MODULE)
424 ROS_ERROR(
"[Demo] : STEP_DATA_ERR::NOT_ENABLED_WALKING_MODULE");
425 if(add_stp_data_srv_result & thormang3_walking_module_msgs::AddStepDataArray::Response::PROBLEM_IN_POSITION_DATA)
426 ROS_ERROR(
"[Demo] : STEP_DATA_ERR::PROBLEM_IN_POSITION_DATA");
427 if(add_stp_data_srv_result & thormang3_walking_module_msgs::AddStepDataArray::Response::PROBLEM_IN_TIME_DATA)
428 ROS_ERROR(
"[Demo] : STEP_DATA_ERR::PROBLEM_IN_TIME_DATA");
429 if(add_stp_data_srv_result & thormang3_walking_module_msgs::AddStepDataArray::Response::ROBOT_IS_WALKING_NOW)
430 ROS_ERROR(
"[Demo] : STEP_DATA_ERR::ROBOT_IS_WALKING_NOW");
435 ROS_ERROR(
"[Demo] : Failed to add step data array ");
441 thormang3_walking_module_msgs::GetReferenceStepData get_ref_stp_data_srv;
442 thormang3_walking_module_msgs::AddStepDataArray add_stp_data_srv;
443 thormang3_walking_module_msgs::IsRunning is_running_srv;
444 thormang3_walking_module_msgs::StepData stp_data_msg;
446 if(g_is_running_client.
call(is_running_srv) ==
false)
448 ROS_ERROR(
"Failed to get walking_module status");
452 if(is_running_srv.response.is_running ==
true)
454 ROS_ERROR(
"[Demo] : ROBOT_IS_WALKING_NOW");
459 g_get_ref_step_data_client.
call(get_ref_stp_data_srv);
461 stp_data_msg = get_ref_stp_data_srv.response.reference_step_data;
463 stp_data_msg.time_data.walking_state = thormang3_walking_module_msgs::StepTimeData::IN_WALKING_STARTING;
464 stp_data_msg.time_data.dsp_ratio = 0.2;
466 stp_data_msg.position_data.moving_foot = thormang3_walking_module_msgs::StepPositionData::STANDING;
467 stp_data_msg.position_data.body_z_swap = 0;
468 add_stp_data_srv.request.step_data_array.push_back(stp_data_msg);
471 stp_data_msg.time_data.walking_state = thormang3_walking_module_msgs::StepTimeData::IN_WALKING;
472 stp_data_msg.time_data.abs_step_time +=
g_step_time;
473 stp_data_msg.position_data.moving_foot = thormang3_walking_module_msgs::StepPositionData::RIGHT_FOOT_SWING;
476 stp_data_msg.position_data.right_foot_pose.x -=
g_step_length;
477 add_stp_data_srv.request.step_data_array.push_back(stp_data_msg);
480 stp_data_msg.time_data.walking_state = thormang3_walking_module_msgs::StepTimeData::IN_WALKING;
481 stp_data_msg.time_data.abs_step_time +=
g_step_time;
482 stp_data_msg.position_data.moving_foot = thormang3_walking_module_msgs::StepPositionData::LEFT_FOOT_SWING;
485 stp_data_msg.position_data.left_foot_pose.x -=
g_step_length;
486 add_stp_data_srv.request.step_data_array.push_back(stp_data_msg);
489 stp_data_msg.time_data.walking_state = thormang3_walking_module_msgs::StepTimeData::IN_WALKING_ENDING;
491 stp_data_msg.position_data.moving_foot = thormang3_walking_module_msgs::StepPositionData::STANDING;
492 stp_data_msg.position_data.body_z_swap = 0;
493 stp_data_msg.position_data.foot_z_swap = 0;
494 add_stp_data_srv.request.step_data_array.push_back(stp_data_msg);
497 add_stp_data_srv.request.auto_start =
true;
498 add_stp_data_srv.request.remove_existing_step_data =
true;
500 if(g_add_step_data_array_client.
call(add_stp_data_srv) ==
true)
502 int add_stp_data_srv_result = add_stp_data_srv.response.result;
503 if(add_stp_data_srv_result== thormang3_walking_module_msgs::AddStepDataArray::Response::NO_ERROR)
504 ROS_INFO(
"[Demo] : Succeed to add step data array");
507 ROS_ERROR(
"[Demo] : Failed to add step data array");
508 if(add_stp_data_srv_result & thormang3_walking_module_msgs::AddStepDataArray::Response::NOT_ENABLED_WALKING_MODULE)
509 ROS_ERROR(
"[Demo] : STEP_DATA_ERR::NOT_ENABLED_WALKING_MODULE");
510 if(add_stp_data_srv_result & thormang3_walking_module_msgs::AddStepDataArray::Response::PROBLEM_IN_POSITION_DATA)
511 ROS_ERROR(
"[Demo] : STEP_DATA_ERR::PROBLEM_IN_POSITION_DATA");
512 if(add_stp_data_srv_result & thormang3_walking_module_msgs::AddStepDataArray::Response::PROBLEM_IN_TIME_DATA)
513 ROS_ERROR(
"[Demo] : STEP_DATA_ERR::PROBLEM_IN_TIME_DATA");
514 if(add_stp_data_srv_result & thormang3_walking_module_msgs::AddStepDataArray::Response::ROBOT_IS_WALKING_NOW)
515 ROS_ERROR(
"[Demo] : STEP_DATA_ERR::ROBOT_IS_WALKING_NOW");
520 ROS_ERROR(
"[Demo] : Failed to add step data array ");
ServiceClient serviceClient(const std::string &service_name, bool persistent=false, const M_string &header_values=M_string())
void publish(const boost::shared_ptr< M > &message) const
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
bool call(MReq &req, MRes &res)
ros::ServiceClient g_get_ref_step_data_client
void walkingModuleStatusMSGCallback(const robotis_controller_msgs::StatusMsg::ConstPtr &msg)
ros::ServiceClient g_is_running_client
ros::ServiceClient g_add_step_data_array_client
bool loadFeedBackGain(thormang3_walking_module_msgs::SetJointFeedBackGain &set_gain)
ros::Publisher g_enable_ctrl_module_pub
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
ros::ServiceClient g_set_balance_param_client
ROSLIB_DECL std::string getPath(const std::string &package_name)
ros::Publisher g_wholebody_ini_pose_pub
ros::Subscriber g_walking_module_status_msg_sub
#define ROS_INFO_STREAM(args)
bool loadBalanceParam(thormang3_walking_module_msgs::SetBalanceParam &set_param)
ros::ServiceClient g_set_feedback_gain_client