67 g_get_ref_step_data_client = nh.
serviceClient<thormang3_walking_module_msgs::GetReferenceStepData>(
"/robotis/walking/get_reference_step_data");
68 g_add_step_data_array_client = nh.
serviceClient<thormang3_walking_module_msgs::AddStepDataArray>(
"/robotis/walking/add_step_data");
69 g_set_balance_param_client = nh.
serviceClient<thormang3_walking_module_msgs::SetBalanceParam>(
"/robotis/walking/set_balance_param");
70 g_is_running_client = nh.
serviceClient<thormang3_walking_module_msgs::IsRunning>(
"/robotis/walking/is_running");
82 if(msg->type == msg->STATUS_ERROR)
84 else if(msg->type == msg->STATUS_INFO)
86 else if(msg->type == msg->STATUS_WARN)
88 else if(msg->type == msg->STATUS_UNKNOWN)
102 && (
last_command.side_step_length == msg->side_step_length)
103 && (
last_command.step_angle_rad == msg->step_angle_rad))
108 ROS_ERROR(
"Receive same command in short time");
123 ROS_INFO(
"[Demo] : Walking Command");
131 if((msg->step_num == 0)
132 && (msg->command !=
"left kick")
133 && (msg->command !=
"right kick")
134 && (msg->command !=
"stop"))
138 if(msg->step_length < 0)
149 if(msg->side_step_length < 0)
160 if(msg->step_angle_rad < 0)
182 g_foot_stp_generator.
num_of_step_ = 2*(msg->step_num) + 2;
185 thormang3_walking_module_msgs::GetReferenceStepData get_ref_stp_data_srv;
186 thormang3_walking_module_msgs::StepData ref_step_data;
187 thormang3_walking_module_msgs::AddStepDataArray add_stp_data_srv;
191 if(g_get_ref_step_data_client.
call(get_ref_stp_data_srv) ==
false)
193 ROS_ERROR(
"Failed to get reference step data");
197 ref_step_data = get_ref_stp_data_srv.response.reference_step_data;
200 if(msg->command ==
"forward")
209 else if(msg->command ==
"backward")
218 else if(msg->command ==
"turn left")
227 else if(msg->command ==
"turn right")
236 else if(msg->command ==
"right")
245 else if(msg->command ==
"left")
254 else if(msg->command ==
"right kick")
259 g_foot_stp_generator.
calcRightKickStep( &add_stp_data_srv.request.step_data_array, ref_step_data);
262 else if(msg->command ==
"left kick")
267 g_foot_stp_generator.
calcLeftKickStep( &add_stp_data_srv.request.step_data_array, ref_step_data);
270 else if(msg->command ==
"stop")
286 add_stp_data_srv.request.auto_start =
true;
287 add_stp_data_srv.request.remove_existing_step_data =
true;
290 if(g_add_step_data_array_client.
call(add_stp_data_srv) ==
true)
292 int add_stp_data_srv_result = add_stp_data_srv.response.result;
293 if(add_stp_data_srv_result== thormang3_walking_module_msgs::AddStepDataArray::Response::NO_ERROR)
295 ROS_INFO(
"[Demo] : Succeed to add step data array");
299 ROS_ERROR(
"[Demo] : Failed to add step data array");
301 if(add_stp_data_srv_result & thormang3_walking_module_msgs::AddStepDataArray::Response::NOT_ENABLED_WALKING_MODULE)
302 ROS_ERROR(
"[Demo] : STEP_DATA_ERR::NOT_ENABLED_WALKING_MODULE");
303 if(add_stp_data_srv_result & thormang3_walking_module_msgs::AddStepDataArray::Response::PROBLEM_IN_POSITION_DATA)
304 ROS_ERROR(
"[Demo] : STEP_DATA_ERR::PROBLEM_IN_POSITION_DATA");
305 if(add_stp_data_srv_result & thormang3_walking_module_msgs::AddStepDataArray::Response::PROBLEM_IN_TIME_DATA)
306 ROS_ERROR(
"[Demo] : STEP_DATA_ERR::PROBLEM_IN_TIME_DATA");
307 if(add_stp_data_srv_result & thormang3_walking_module_msgs::AddStepDataArray::Response::TOO_MANY_STEP_DATA)
308 ROS_ERROR(
"[Demo] : STEP_DATA_ERR::TOO_MANY_STEP_DATA");
309 if(add_stp_data_srv_result & thormang3_walking_module_msgs::AddStepDataArray::Response::ROBOT_IS_WALKING_NOW)
310 ROS_ERROR(
"[Demo] : STEP_DATA_ERR::ROBOT_IS_WALKING_NOW");
319 ROS_ERROR(
"[Demo] : Failed to add step data array ");
329 thormang3_walking_module_msgs::GetReferenceStepData get_ref_stp_data_srv;
330 thormang3_walking_module_msgs::StepData ref_step_data;
331 thormang3_walking_module_msgs::AddStepDataArray add_stp_data_srv;
332 thormang3_walking_module_msgs::IsRunning is_running_srv;
339 if(g_get_ref_step_data_client.
call(get_ref_stp_data_srv) ==
false)
341 ROS_ERROR(
"[Demo] : Failed to get reference step data");
345 ref_step_data = get_ref_stp_data_srv.response.reference_step_data;
351 add_stp_data_srv.request.auto_start =
true;
352 add_stp_data_srv.request.remove_existing_step_data =
true;
355 if(g_add_step_data_array_client.
call(add_stp_data_srv) ==
true)
357 int add_stp_data_srv_result = add_stp_data_srv.response.result;
358 if(add_stp_data_srv_result== thormang3_walking_module_msgs::AddStepDataArray::Response::NO_ERROR)
359 ROS_INFO(
"[Demo] : Succeed to add step data array");
361 ROS_ERROR(
"[Demo] : Failed to add step data array");
363 if(add_stp_data_srv_result & thormang3_walking_module_msgs::AddStepDataArray::Response::NOT_ENABLED_WALKING_MODULE)
364 ROS_ERROR(
"[Demo] : STEP_DATA_ERR::NOT_ENABLED_WALKING_MODULE");
365 if(add_stp_data_srv_result & thormang3_walking_module_msgs::AddStepDataArray::Response::PROBLEM_IN_POSITION_DATA)
366 ROS_ERROR(
"[Demo] : STEP_DATA_ERR::PROBLEM_IN_POSITION_DATA");
367 if(add_stp_data_srv_result & thormang3_walking_module_msgs::AddStepDataArray::Response::PROBLEM_IN_TIME_DATA)
368 ROS_ERROR(
"[Demo] : STEP_DATA_ERR::PROBLEM_IN_TIME_DATA");
369 if(add_stp_data_srv_result & thormang3_walking_module_msgs::AddStepDataArray::Response::ROBOT_IS_WALKING_NOW)
370 ROS_ERROR(
"[Demo] : STEP_DATA_ERR::ROBOT_IS_WALKING_NOW");
377 ROS_ERROR(
"[Demo] : Failed to add step data array ");
384 thormang3_walking_module_msgs::IsRunning is_running_srv;
385 if(g_is_running_client.
call(is_running_srv) ==
false)
387 ROS_ERROR(
"[Demo] : Failed to Walking Status");
392 if(is_running_srv.response.is_running ==
true)
394 ROS_ERROR(
"[Demo] : STEP_DATA_ERR::ROBOT_IS_WALKING_NOW");
double g_last_command_time
ros::Subscriber g_footsteps_2d_sub
ServiceClient serviceClient(const std::string &service_name, bool persistent=false, const M_string &header_values=M_string())
ros::Subscriber g_walking_module_status_msg_sub
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
ros::ServiceClient g_get_ref_step_data_client
ros::Subscriber g_walking_command_sub
ros::ServiceClient g_set_balance_param_client
bool call(MReq &req, MRes &res)
ros::Subscriber g_balance_command_sub
void step2DArrayCallback(const thormang3_foot_step_generator::Step2DArray::ConstPtr &msg)
thormang3_walking_module_msgs::AddStepDataArray add_step_data_array_srv
void walkingModuleStatusMSGCallback(const robotis_controller_msgs::StatusMsg::ConstPtr &msg)
thormang3_foot_step_generator::FootStepCommand last_command
#define ROS_WARN_STREAM(args)
thormang3::FootStepGenerator g_foot_stp_generator
ros::ServiceClient g_is_running_client
bool g_is_running_check_needed
#define ROS_INFO_STREAM(args)
#define ROS_ERROR_STREAM(args)
void walkingCommandCallback(const thormang3_foot_step_generator::FootStepCommand::ConstPtr &msg)
ros::ServiceClient g_add_step_data_array_client