23 #include "../include/thormang3_demo/qnode.hpp" 39 marker_name_(
"THORMANG3_demo_marker"),
40 frame_id_(
"pelvis_link")
47 std::string debug_code(argv[1]);
48 if (debug_code ==
"debug")
89 "/robotis/get_present_joint_ctrl_modules");
109 "/robotis/manipulation/joint_pose_msg", 0);
111 "/robotis/manipulation/kinematics_pose_msg", 0);
114 "/robotis/manipulation/get_joint_pose");
116 "/robotis/manipulation/get_kinematics_pose");
121 "/robotis/walking/set_balance_param");
124 "/robotis/thormang3_foot_step_generator/walking_command", 0);
126 "/robotis/thormang3_foot_step_generator/footsteps_2d", 0);
130 marker_pub_ = nh.
advertise<visualization_msgs::MarkerArray>(
"/robotis/demo/foot_step_marker", 0);
141 std::string default_config_path =
ros::package::getPath(
"thormang3_demo") +
"/config/demo_config.yaml";
142 std::string config_path = nh.
param<std::string>(
"demo_config", default_config_path);
169 std::cout <<
"Ros shutdown, proceeding to close the gui." << std::endl;
179 doc = YAML::LoadFile(path.c_str());
180 }
catch (
const std::exception& e)
182 ROS_ERROR(
"Fail to load id_joint table yaml.");
187 YAML::Node id_sub_node = doc[
"id_joint"];
188 for (YAML::iterator yaml_it = id_sub_node.begin(); yaml_it != id_sub_node.end(); ++yaml_it)
191 std::string joint_name;
193 id = yaml_it->first.as<
int>();
194 joint_name = yaml_it->second.as<std::string>();
203 std::vector<std::string> modules = doc[
"module_list"].as<std::vector<std::string> >();
205 int module_index = 0;
206 for (std::vector<std::string>::iterator module_it = modules.begin(); module_it != modules.end(); ++module_it)
208 std::string module_name = *module_it;
217 YAML::Node sub_node = doc[
"module_button"];
218 for (YAML::iterator button_it = sub_node.begin(); button_it != sub_node.end(); ++button_it)
221 std::string module_name;
223 key = button_it->first.as<
int>();
224 module_name = button_it->second.as<std::string>();
238 doc = YAML::LoadFile(path.c_str());
239 }
catch (
const std::exception& e)
246 YAML::Node motion_sub_node = doc[
"motion"];
247 for (YAML::iterator motion_it = motion_sub_node.begin(); motion_it != motion_sub_node.end(); ++motion_it)
250 std::string motion_name;
252 motion_index = motion_it->first.as<
int>();
253 motion_name = motion_it->second.as<std::string>();
264 std::map<int, std::string>::iterator map_it;
270 joint_name = map_it->second;
277 std::map<std::string, int>::iterator map_it;
290 std::map<int, std::string>::iterator map_it;
298 joint_name = map_it->second;
309 std::string mode =
"";
313 mode = map_it->second;
325 mode_index = map_it->second;
346 map_it->second =
false;
351 std::map<std::string, bool>::iterator map_it =
using_mode_table_.find(module_name);
356 return map_it->second;
370 init_msg.data =
"ini_pose";
374 log(
Info,
"Go to robot initial pose.");
379 std_msgs::String ft_msg;
380 ft_msg.data = command;
388 std_msgs::String lidar_msg;
389 lidar_msg.data =
"start";
392 log(
Info,
"Publish move_lidar topic");
398 std_msgs::String msg;
403 std::stringstream ss;
404 ss <<
"Set Mode : " << mode;
411 robotis_controller_msgs::GetJointModule get_joint;
412 std::map<std::string, int> service_map;
415 std::map<int, std::string>::iterator map_it;
419 get_joint.request.joint_name.push_back(map_it->second);
420 service_map[map_it->second] = index;
426 std::vector<int> modules;
432 for (
int ix = 0; ix < get_joint.response.joint_name.size(); ix++)
434 std::string joint_name = get_joint.response.joint_name[ix];
435 std::string module_name = get_joint.response.module_name[ix];
437 std::map<std::string, int>::iterator service_iter = service_map.find(joint_name);
438 if (service_iter == service_map.end())
441 index = service_iter->second;
449 modules.at(index) = service_iter->second;
451 std::map<std::string, bool>::iterator module_iter =
using_mode_table_.find(module_name);
453 module_iter->second =
true;
461 log(
Error,
"Fail to get current joint control module.");
466 ROS_INFO(
"set current joint module");
468 std::vector<int> modules;
471 std::map<std::string, int> joint_module;
476 for (
int ix = 0; ix < msg->joint_name.size(); ix++)
478 std::string joint_name = msg->joint_name[ix];
479 std::string module_name = msg->module_name[ix];
483 std::map<std::string, bool>::iterator module_iter =
using_mode_table_.find(module_name);
485 module_iter->second =
true;
491 std::string joint_name =
"";
496 std::map<std::string, int>::iterator module_iter = joint_module.find(joint_name);
497 if (module_iter == joint_module.end())
501 modules.at(ix) = module_iter->second;
507 log(
Info,
"Applied Mode",
"Manager");
512 double head_pan, head_tilt;
513 int count_getting_joint = 0;
515 for (
int ix = 0; ix < msg->name.size(); ix++)
517 if (msg->name[ix] ==
"head_y")
519 head_pan = -msg->position[ix];
520 count_getting_joint += 1;
522 else if (msg->name[ix] ==
"head_p")
524 head_tilt = -msg->position[ix];
525 count_getting_joint += 1;
528 if (count_getting_joint == 2)
532 if (count_getting_joint > 0)
538 std::stringstream ss;
539 ss <<
"Type : " << msg->name << std::endl;
540 ss <<
" - Right - " << std::endl << msg->right << std::endl;
541 ss <<
" - Left - " << std::endl << msg->left;
548 sensor_msgs::JointState head_angle_msg;
550 head_angle_msg.name.push_back(
"head_y");
551 head_angle_msg.name.push_back(
"head_p");
553 head_angle_msg.position.push_back(-pan);
554 head_angle_msg.position.push_back(-tilt);
571 log(
Info,
"Set Des. Joint Vale");
573 std::stringstream log_msg;
575 log_msg <<
" \n " <<
"joint name : " << msg.name <<
" \n " <<
"joint value : " << msg.value *
RADIAN2DEGREE <<
" \n ";
584 log(
Info,
"Solve Inverse Kinematics");
585 log(
Info,
"Set Des. End Effector's Pose : ");
587 std::stringstream log_msgs;
589 log_msgs <<
" \n " <<
"group name : " << msg.name <<
" \n " <<
"des. pos. x : " << msg.pose.position.x <<
" \n " 590 <<
"des. pos. y : " << msg.pose.position.y <<
" \n " <<
"des. pos. z : " << msg.pose.position.z <<
" \n " 591 <<
"des. ori. x : " << msg.pose.orientation.x <<
" \n " <<
"des. ori. y : " << msg.pose.orientation.y
592 <<
" \n " <<
"des. ori. z : " << msg.pose.orientation.z <<
" \n " <<
"des. ori. w : " 593 << msg.pose.orientation.w <<
" \n ";
606 thormang3_manipulation_module_msgs::GetJointPose get_joint_pose;
609 get_joint_pose.request.joint_name = joint_name;
611 log(
Info,
"Get Curr. Joint Value");
613 std::stringstream log_msg;
615 log_msg <<
" \n " <<
"joint name : " << joint_name <<
" \n ";
622 double joint_value = get_joint_pose.response.joint_value;
624 log(
Info,
"Joint Curr. Value");
626 std::stringstream log_msg;
628 log_msg <<
" \n " <<
"curr. value : " << joint_value <<
" \n ";
635 log(
Error,
"fail to get joint pose.");
640 thormang3_manipulation_module_msgs::GetKinematicsPose get_kinematics_pose;
643 get_kinematics_pose.request.group_name = group_name;
645 log(
Info,
"Solve Forward Kinematics");
647 log(
Info,
"Get Curr. End Effector's Pose");
649 std::stringstream log_msg;
651 log_msg <<
" \n " <<
"group name : " << group_name <<
" \n ";
658 double pos_x = get_kinematics_pose.response.group_pose.position.x;
659 double pos_y = get_kinematics_pose.response.group_pose.position.y;
660 double pos_z = get_kinematics_pose.response.group_pose.position.z;
662 double ori_x = get_kinematics_pose.response.group_pose.orientation.x;
663 double ori_y = get_kinematics_pose.response.group_pose.orientation.y;
664 double ori_z = get_kinematics_pose.response.group_pose.orientation.z;
665 double ori_w = get_kinematics_pose.response.group_pose.orientation.w;
667 log(
Info,
"End Effector Curr. Pose : ");
669 std::stringstream log_msg;
671 log_msg <<
" \n " <<
"curr. pos. x : " << pos_x <<
" \n " <<
"curr. pos. y : " << pos_y <<
" \n " 672 <<
"curr. pos. z : " << pos_z <<
" \n " <<
"curr. ori. w : " << ori_w <<
" \n " <<
"curr. ori. x : " 673 << ori_x <<
" \n " <<
"curr. ori. y : " << ori_y <<
" \n " <<
"curr. ori. z : " << ori_z <<
" \n ";
681 log(
Error,
"fail to get kinematics pose.");
686 double z_offset = 0.801;
687 Q_EMIT
updateCurrPos(msg->position.x, msg->position.y, msg->position.z + z_offset);
688 Q_EMIT
updateCurrOri(msg->orientation.x, msg->orientation.y, msg->orientation.z, msg->orientation.w);
696 std::stringstream ss;
697 ss <<
"Set Walking Command : " << msg.command << std::endl;
698 ss <<
"- Number of Step : " << msg.step_num << std::endl;
699 ss <<
"- Step Length : " << msg.step_length << std::endl;
700 ss <<
"- Side Step Length : " << msg.side_step_length << std::endl;
701 ss <<
"- Rotation Angle : " << msg.step_angle_rad << std::endl;
708 if (on_command ==
true)
715 const double &imu_time_const,
const double &ft_time_const)
748 log(
Error,
"Footsteps are corrupted.");
757 thormang3_foot_step_generator::Step2DArray footsteps;
761 thormang3_foot_step_generator::Step2D
step;
764 if (type == humanoid_nav_msgs::StepTarget::right)
765 step.moving_foot = thormang3_foot_step_generator::Step2D::RIGHT_FOOT_SWING;
766 else if (type == humanoid_nav_msgs::StepTarget::left)
767 step.moving_foot = thormang3_foot_step_generator::Step2D::LEFT_FOOT_SWING;
769 step.moving_foot = thormang3_foot_step_generator::Step2D::STANDING;
773 footsteps.footsteps_2d.push_back(step);
778 log(
Info,
"Set command to walk using footsteps");
800 humanoid_nav_msgs::PlanFootsteps get_step;
802 geometry_msgs::Pose2D
start;
803 geometry_msgs::Pose2D
goal;
804 goal.x = target_foot_pose.position.x;
805 goal.y = target_foot_pose.position.y;
807 Eigen::Quaterniond goal_orientation;
810 Eigen::Vector3d forward, f_x(1, 0, 0);
811 forward = goal_orientation.toRotationMatrix() * f_x;
812 double theta = forward.y() > 0 ?
acos(forward.x()) : -
acos(forward.x());
815 get_step.request.start = start;
816 get_step.request.goal = goal;
818 std::stringstream call_msg;
819 call_msg <<
"Start [" << start.x <<
", " << start.y <<
" | " << start.theta <<
"]" <<
" , Goal [" << goal.x <<
", " 820 << goal.y <<
" | " << goal.theta <<
"]";
832 if (get_step.response.result)
834 for (
int ix = 0; ix < get_step.response.footsteps.size(); ix++)
837 std::stringstream msg_stream;
838 int foot_type = get_step.response.footsteps[ix].leg;
839 std::string foot = (foot_type == humanoid_nav_msgs::StepTarget::right) ?
"right" :
"left";
840 geometry_msgs::Pose2D foot_pose = get_step.response.footsteps[ix].pose;
843 msg_stream <<
"Foot Step #" << ix + 1 <<
" [ " << foot <<
"] - [" << foot_pose.x <<
", " << foot_pose.y <<
" | " 856 log(
Info,
"fail to get foot step from planner");
874 visualization_msgs::MarkerArray marker_array;
876 visualization_msgs::Marker rviz_marker;
878 rviz_marker.header.frame_id =
"pelvis_link";
879 rviz_marker.header.stamp = now;
880 rviz_marker.ns =
"foot_step_marker";
883 rviz_marker.type = visualization_msgs::Marker::CUBE;
884 rviz_marker.action = (clear ==
false) ? visualization_msgs::Marker::ADD : visualization_msgs::Marker::DELETE;
886 rviz_marker.scale.x = 0.216;
887 rviz_marker.scale.y = 0.144;
888 rviz_marker.scale.z = 0.01;
891 double height = -0.723;
896 rviz_marker.id += 10;
901 Eigen::Vector3d marker_position_offset;
905 Eigen::Quaterniond marker_orientation(Eigen::Quaterniond::FromTwoVectors(toward, direction));
909 std::stringstream msg;
910 msg <<
"Foot Step #" << ix <<
" [ " <<
preview_foot_types_[ix] <<
"] - [" << rviz_marker.pose.position.x <<
", " 911 << rviz_marker.pose.position.y <<
"]";
919 rviz_marker.color.r = 0.0;
920 rviz_marker.color.g = 0.0;
921 rviz_marker.color.b = 1.0;
922 rviz_marker.color.a = alpha + 0.3;
924 Eigen::Vector3d offset_y(0, 0.015, 0);
925 marker_position_offset = marker_orientation.toRotationMatrix() * offset_y;
930 rviz_marker.color.r = 1.0;
931 rviz_marker.color.g = 0.0;
932 rviz_marker.color.b = 0.0;
933 rviz_marker.color.a = alpha + 0.3;
935 Eigen::Vector3d offset_y(0, -0.015, 0);
936 marker_position_offset = marker_orientation.toRotationMatrix() * offset_y;
939 marker_position = marker_position_offset + marker_position;
947 marker_array.markers.push_back(rviz_marker);
952 log(
Info,
"Visualize Preview Footstep Marker Array");
954 log(
Info,
"Clear Visualize Preview Footstep Marker Array");
961 bool service_result =
false;
965 if (service_result ==
true)
968 if (_result == thormang3_walking_module_msgs::SetBalanceParam::Response::NO_ERROR)
970 ROS_INFO(
"[Demo] : Succeed to set balance param");
971 ROS_INFO(
"[Demo] : Please wait 2 sec for turning on balance");
972 log(
Info,
"Set Walking Balance parameters");
976 if (_result & thormang3_walking_module_msgs::SetBalanceParam::Response::NOT_ENABLED_WALKING_MODULE)
977 ROS_ERROR(
"[Demo] : BALANCE_PARAM_ERR::NOT_ENABLED_WALKING_MODULE");
978 if (_result & thormang3_walking_module_msgs::SetBalanceParam::Response::PREV_REQUEST_IS_NOT_FINISHED)
979 ROS_ERROR(
"[Demo] : BALANCE_PARAM_ERR::PREV_REQUEST_IS_NOT_FINISHED");
983 ROS_ERROR(
"[Demo] : Failed to set balance param ");
990 std::string balance_yaml_path =
"";
991 balance_yaml_path =
package_name_ +
"/config/balance_param.yaml";
997 doc = YAML::LoadFile(balance_yaml_path.c_str());
999 double cob_x_offset_m = doc[
"cob_x_offset_m"].as<
double>();
1000 double cob_y_offset_m = doc[
"cob_y_offset_m"].as<
double>();
1001 double hip_roll_swap_angle_rad = doc[
"hip_roll_swap_angle_rad"].as<
double>();
1002 double foot_roll_gyro_p_gain = doc[
"foot_roll_gyro_p_gain"].as<
double>();
1003 double foot_roll_gyro_d_gain = doc[
"foot_roll_gyro_d_gain"].as<
double>();
1004 double foot_pitch_gyro_p_gain = doc[
"foot_pitch_gyro_p_gain"].as<
double>();
1005 double foot_pitch_gyro_d_gain = doc[
"foot_pitch_gyro_d_gain"].as<
double>();
1006 double foot_roll_angle_p_gain = doc[
"foot_roll_angle_p_gain"].as<
double>();
1007 double foot_roll_angle_d_gain = doc[
"foot_roll_angle_d_gain"].as<
double>();
1008 double foot_pitch_angle_p_gain = doc[
"foot_pitch_angle_p_gain"].as<
double>();
1009 double foot_pitch_angle_d_gain = doc[
"foot_pitch_angle_d_gain"].as<
double>();
1010 double foot_x_force_p_gain = doc[
"foot_x_force_p_gain"].as<
double>();
1011 double foot_x_force_d_gain = doc[
"foot_x_force_d_gain"].as<
double>();
1012 double foot_y_force_p_gain = doc[
"foot_y_force_p_gain"].as<
double>();
1013 double foot_y_force_d_gain = doc[
"foot_y_force_d_gain"].as<
double>();
1014 double foot_z_force_p_gain = doc[
"foot_z_force_p_gain"].as<
double>();
1015 double foot_z_force_d_gain = doc[
"foot_z_force_d_gain"].as<
double>();
1016 double foot_roll_torque_p_gain = doc[
"foot_roll_torque_p_gain"].as<
double>();
1017 double foot_roll_torque_d_gain = doc[
"foot_roll_torque_d_gain"].as<
double>();
1018 double foot_pitch_torque_p_gain = doc[
"foot_pitch_torque_p_gain"].as<
double>();
1019 double foot_pitch_torque_d_gain = doc[
"foot_pitch_torque_d_gain"].as<
double>();
1020 double roll_gyro_cut_off_frequency = doc[
"roll_gyro_cut_off_frequency"].as<
double>();
1021 double pitch_gyro_cut_off_frequency = doc[
"pitch_gyro_cut_off_frequency"].as<
double>();
1022 double roll_angle_cut_off_frequency = doc[
"roll_angle_cut_off_frequency"].as<
double>();
1023 double pitch_angle_cut_off_frequency = doc[
"pitch_angle_cut_off_frequency"].as<
double>();
1024 double foot_x_force_cut_off_frequency = doc[
"foot_x_force_cut_off_frequency"].as<
double>();
1025 double foot_y_force_cut_off_frequency = doc[
"foot_y_force_cut_off_frequency"].as<
double>();
1026 double foot_z_force_cut_off_frequency = doc[
"foot_z_force_cut_off_frequency"].as<
double>();
1027 double foot_roll_torque_cut_off_frequency = doc[
"foot_roll_torque_cut_off_frequency"].as<
double>();
1028 double foot_pitch_torque_cut_off_frequency = doc[
"foot_pitch_torque_cut_off_frequency"].as<
double>();
1053 set_balance_param_srv_.request.balance_param.pitch_gyro_cut_off_frequency = pitch_gyro_cut_off_frequency ;
1054 set_balance_param_srv_.request.balance_param.roll_angle_cut_off_frequency = roll_angle_cut_off_frequency ;
1055 set_balance_param_srv_.request.balance_param.pitch_angle_cut_off_frequency = pitch_angle_cut_off_frequency ;
1056 set_balance_param_srv_.request.balance_param.foot_x_force_cut_off_frequency = foot_x_force_cut_off_frequency ;
1057 set_balance_param_srv_.request.balance_param.foot_y_force_cut_off_frequency = foot_y_force_cut_off_frequency ;
1058 set_balance_param_srv_.request.balance_param.foot_z_force_cut_off_frequency = foot_z_force_cut_off_frequency ;
1059 set_balance_param_srv_.request.balance_param.foot_roll_torque_cut_off_frequency = foot_roll_torque_cut_off_frequency ;
1060 set_balance_param_srv_.request.balance_param.foot_pitch_torque_cut_off_frequency = foot_pitch_torque_cut_off_frequency;
1064 catch (
const std::exception& e)
1066 ROS_ERROR(
"Failed to load balance param yaml file.");
1078 if (result_load ==
false)
1081 bool service_result =
false;
1085 if (service_result ==
true)
1089 if (_result == thormang3_walking_module_msgs::SetJointFeedBackGain::Response::NO_ERROR)
1091 ROS_INFO(
"[Demo] : Succeed to set joint feedback gain");
1092 log(
Info,
"Set Walking Joint FeedBack gain");
1096 if (_result & thormang3_walking_module_msgs::SetJointFeedBackGain::Response::NOT_ENABLED_WALKING_MODULE)
1097 ROS_ERROR(
"[Demo] : FRRDBACK_GAIN_ERR::NOT_ENABLED_WALKING_MODULE");
1098 if (_result & thormang3_walking_module_msgs::SetJointFeedBackGain::Response::PREV_REQUEST_IS_NOT_FINISHED)
1099 ROS_ERROR(
"[Demo] : FRRDBACK_GAIN_ERR::PREV_REQUEST_IS_NOT_FINISHED");
1104 ROS_ERROR(
"[Demo] : Failed to set Joint Feedback Gain");
1105 log(
Error,
"Fain to set Walking Joint FeedBack gain");
1112 std::string balance_yaml_path =
"";
1113 balance_yaml_path =
package_name_ +
"/config/joint_feedback_gain.yaml";
1119 doc = YAML::LoadFile(balance_yaml_path.c_str());
1148 catch (
const std::exception& e)
1150 ROS_ERROR(
"Failed to load joint feedback gain yaml file.");
1162 if (result_load ==
false)
1167 log(
Info,
"Turn On Walking Balance");
1175 if (result_load ==
false)
1200 log(
Info,
"Turn Off Walking Balance");
1208 log(
Error,
"Motion index is not valid.");
1212 std::stringstream log_stream;
1213 switch (motion_index)
1216 log_stream <<
"BRAKE Motion";
1220 log_stream <<
"STOP Motion";
1225 log_stream <<
"Play Motion : [" << motion_index <<
"] " << motion_name;
1229 std_msgs::Int32 motion_msg;
1230 motion_msg.data = motion_index;
1232 if (to_action_script ==
true)
1247 log(
Info,
"Get Pose For Step");
1253 double z_offset = 0.723;
1254 Q_EMIT
updateCurrPos(msg->position.x, msg->position.y, msg->position.z + z_offset);
1255 Q_EMIT
updateCurrOri(msg->orientation.x, msg->orientation.y, msg->orientation.z, msg->orientation.w);
1268 ROS_INFO(
"get position from rviz");
1279 switch (feedback->event_type)
1281 case visualization_msgs::InteractiveMarkerFeedback::BUTTON_CLICK:
1284 case visualization_msgs::InteractiveMarkerFeedback::MENU_SELECT:
1287 case visualization_msgs::InteractiveMarkerFeedback::POSE_UPDATE:
1296 case visualization_msgs::InteractiveMarkerFeedback::MOUSE_DOWN:
1299 case visualization_msgs::InteractiveMarkerFeedback::MOUSE_UP:
1320 "Make Interactive Marker! - " << marker_pose.position.x <<
", " << marker_pose.position.y <<
", " << marker_pose.position.z <<
" [" << marker_pose.orientation.x <<
", " << marker_pose.orientation.y <<
", " << marker_pose.orientation.z <<
" | " << marker_pose.orientation.w <<
"]");
1324 visualization_msgs::InteractiveMarker interactive_marker;
1325 interactive_marker.pose = marker_pose;
1328 interactive_marker.header.frame_id =
frame_id_;
1329 interactive_marker.scale = 0.3;
1332 interactive_marker.description =
"3D Pose Control";
1335 visualization_msgs::InteractiveMarkerControl center_marker_control;
1337 center_marker_control.always_visible =
true;
1338 center_marker_control.interaction_mode = visualization_msgs::InteractiveMarkerControl::NONE;
1340 visualization_msgs::Marker marker;
1342 marker.type = visualization_msgs::Marker::CUBE;
1345 marker.scale.x = 0.03;
1346 marker.scale.y = 0.03;
1347 marker.scale.z = 0.03;
1349 marker.color.r = 1.0;
1350 marker.color.g = 0.5;
1351 marker.color.b = 0.5;
1352 marker.color.a = 1.0;
1354 center_marker_control.markers.push_back(marker);
1357 marker.pose.position.x = 0.05;
1358 marker.pose.position.y = 0.0;
1359 marker.pose.position.z = 0.0;
1361 marker.scale.x = 0.1;
1362 marker.scale.y = 0.01;
1363 marker.scale.z = 0.01;
1365 marker.color.r = 1.0;
1366 marker.color.g = 0.0;
1367 marker.color.b = 0.0;
1368 marker.color.a = 1.0;
1370 center_marker_control.markers.push_back(marker);
1373 marker.pose.position.x = 0.0;
1374 marker.pose.position.y = 0.05;
1375 marker.pose.position.z = 0.0;
1377 marker.scale.x = 0.01;
1378 marker.scale.y = 0.1;
1379 marker.scale.z = 0.01;
1381 marker.color.r = 0.0;
1382 marker.color.g = 1.0;
1383 marker.color.b = 0.0;
1384 marker.color.a = 1.0;
1386 center_marker_control.markers.push_back(marker);
1389 marker.pose.position.x = 0.0;
1390 marker.pose.position.y = 0.0;
1391 marker.pose.position.z = 0.05;
1393 marker.scale.x = 0.01;
1394 marker.scale.y = 0.01;
1395 marker.scale.z = 0.1;
1397 marker.color.r = 0.0;
1398 marker.color.g = 0.0;
1399 marker.color.b = 1.0;
1400 marker.color.a = 1.0;
1402 center_marker_control.markers.push_back(marker);
1404 interactive_marker.controls.push_back(center_marker_control);
1407 visualization_msgs::InteractiveMarkerControl interactive_control;
1410 interactive_control.orientation.x = 1;
1411 interactive_control.orientation.y = 0;
1412 interactive_control.orientation.z = 0;
1413 interactive_control.orientation.w = 1;
1414 interactive_control.name =
"rotate";
1415 interactive_control.interaction_mode = visualization_msgs::InteractiveMarkerControl::ROTATE_AXIS;
1416 interactive_marker.controls.push_back(interactive_control);
1417 interactive_control.name =
"move";
1418 interactive_control.interaction_mode = visualization_msgs::InteractiveMarkerControl::MOVE_AXIS;
1419 interactive_marker.controls.push_back(interactive_control);
1422 interactive_control.orientation.x = 0;
1423 interactive_control.orientation.y = 1;
1424 interactive_control.orientation.z = 0;
1425 interactive_control.orientation.w = 1;
1426 interactive_control.name =
"rotate";
1427 interactive_control.interaction_mode = visualization_msgs::InteractiveMarkerControl::ROTATE_AXIS;
1428 interactive_marker.controls.push_back(interactive_control);
1429 interactive_control.name =
"move";
1430 interactive_control.interaction_mode = visualization_msgs::InteractiveMarkerControl::MOVE_AXIS;
1431 interactive_marker.controls.push_back(interactive_control);
1434 interactive_control.orientation.x = 0;
1435 interactive_control.orientation.y = 0;
1436 interactive_control.orientation.z = 1;
1437 interactive_control.orientation.w = 1;
1438 interactive_control.name =
"rotate";
1439 interactive_control.interaction_mode = visualization_msgs::InteractiveMarkerControl::ROTATE_AXIS;
1440 interactive_marker.controls.push_back(interactive_control);
1441 interactive_control.name =
"move";
1442 interactive_control.interaction_mode = visualization_msgs::InteractiveMarkerControl::MOVE_AXIS;
1443 interactive_marker.controls.push_back(interactive_control);
1454 ROS_INFO(
"Update Interactive Marker Pose");
1456 visualization_msgs::InteractiveMarker interactive_marker;
1457 bool result_getting =
false;
1460 if (result_getting ==
false)
1462 ROS_ERROR(
"No Interactive marker to set pose");
1472 ROS_INFO(
"Get Interactive Marker Pose");
1474 visualization_msgs::InteractiveMarker _interactive_marker;
1477 ROS_ERROR(
"No Interactive marker to get pose");
1489 ROS_INFO(
"Clear Interactive Marker");
1498 if (kick_foot ==
"right kick")
1501 if (result ==
false)
1510 thormang3_foot_step_generator::FootStepCommand msg;
1511 msg.command = kick_foot;
1515 usleep(7.2 * 1000 * 1000);
1523 usleep(2 * 1000 * 1000);
1525 else if (kick_foot ==
"left kick")
1528 if (result ==
false)
1536 thormang3_foot_step_generator::FootStepCommand msg;
1537 msg.command = kick_foot;
1541 usleep(7.2 * 1000 * 1000);
1549 usleep(2 * 1000 * 1000);
1556 log((
LogLevel) msg->type, msg->status_msg, msg->module_name);
1562 std::stringstream logging_model_msg;
1565 int current_time = duration_time.
sec;
1566 int min_time = 0, sec_time = 0;
1567 min_time = (int) (current_time / 60);
1568 sec_time = (int) (current_time % 60);
1570 std::stringstream min_str, sec_str;
1575 min_str << min_time;
1576 sec_str << sec_time;
1578 std::stringstream stream_sender;
1579 stream_sender <<
"[" << sender <<
"] ";
1586 logging_model_msg <<
"[DEBUG] [" << min_str.str() <<
":" << sec_str.str() <<
"]: " << stream_sender.str() << msg;
1592 logging_model_msg <<
"[INFO] [" << min_str.str() <<
":" << sec_str.str() <<
"]: " << stream_sender.str() << msg;
1598 logging_model_msg <<
"[WARN] [" << min_str.str() <<
":" << sec_str.str() <<
"]: " << stream_sender.str() << msg;
1604 logging_model_msg <<
"<ERROR> [" << min_str.str() <<
":" << sec_str.str() <<
"]: " << stream_sender.str() << msg;
1610 logging_model_msg <<
"[FATAL] [" << min_str.str() <<
":" << sec_str.str() <<
"]: " << stream_sender.str() << msg;
1615 QVariant new_row(QString(logging_model_msg.str().c_str()));
bool getIDJointNameFromIndex(const int &index, int &id, std::string &joint_name)
void statusMsgCallback(const robotis_controller_msgs::StatusMsg::ConstPtr &msg)
ServiceClient serviceClient(const std::string &service_name, bool persistent=false, const M_string &header_values=M_string())
void sendInitPoseMsg(std_msgs::String msg)
#define ROS_DEBUG_STREAM_COND(cond, args)
void clearInteractiveMarker()
ros::Subscriber pose_sub_
void pointStampedCallback(const geometry_msgs::PointStamped::ConstPtr &msg)
ros::Publisher motion_page_pub_
ros::Publisher set_walking_footsteps_pub_
ros::Publisher marker_pub_
void parseMotionMapFromYaml(const std::string &path)
void poseCallback(const geometry_msgs::Pose::ConstPtr &msg)
void publish(const boost::shared_ptr< M > &message) const
void visualizePreviewFootsteps(bool clear)
void quaternionEigenToMsg(const Eigen::Quaterniond &e, geometry_msgs::Quaternion &m)
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
ros::Publisher init_ft_pub_
void sendDestJointMsg(thormang3_manipulation_module_msgs::JointPose msg)
void setBalanceParameter()
ros::Subscriber current_module_control_sub_
ros::ServiceClient set_balance_param_client_
QNodeThor3(int argc, char **argv)
void setWalkingBalanceParam(const double &gyro_gain, const double &ft_gain_ratio, const double &imu_time_const, const double &ft_time_const)
ros::Publisher set_head_joint_angle_pub_
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
bool call(MReq &req, MRes &res)
std::vector< int > preview_foot_types_
ros::Publisher module_control_pub_
bool isUsingModule(const std::string &module_name)
void getKinematicsPose(std::string group_name)
void setWalkingFootsteps()
void enableControlModule(const std::string &mode)
thormang3_walking_module_msgs::SetBalanceParam set_balance_param_srv_
void setWalkingBalance(bool on_command)
ros::Subscriber current_joint_states_sub_
ros::Subscriber init_ft_foot_sub_
void getJointControlModule()
bool loadBalanceParameterFromYaml()
void kickDemo(const std::string &kick_foot)
void playMotion(int motion_index, bool to_action_script=true)
void sendGripperPosition(sensor_msgs::JointState msg)
QStringListModel logging_model_
void refreshCurrentJointControlCallback(const robotis_controller_msgs::JointCtrlModule::ConstPtr &msg)
void updateCurrOri(double x, double y, double z, double w)
ros::Subscriber rviz_clicked_point_sub_
void updatePresentJointControlModules(std::vector< int > mode)
static const double RADIAN2DEGREE
#define ROS_FATAL_STREAM(args)
bool getJointNameFromID(const int &id, std::string &joint_name)
ros::ServiceClient get_module_control_client_
std::map< std::string, int > mode_index_table_
void interactiveMarkerFeedback(const visualization_msgs::InteractiveMarkerFeedbackConstPtr &feedback)
thormang3_walking_module_msgs::SetJointFeedBackGain set_joint_feedback_gain_srv_
void setCurrentControlUI(int mode)
bool param(const std::string ¶m_name, T ¶m_val, const T &default_val) const
ros::Publisher motion_index_pub_
ros::Publisher send_des_joint_msg_pub_
ros::ServiceClient get_joint_pose_client_
void makeFootstepUsingPlanner()
ros::Publisher module_control_preset_pub_
void updateDemoPose(const geometry_msgs::Pose pose)
void parseJointNameFromYaml(const std::string &path)
std::vector< geometry_msgs::Pose2D > preview_foot_steps_
ros::Subscriber status_msg_sub_
std::map< int, std::string > index_mode_table_
geometry_msgs::Pose current_pose_
ros::Publisher send_gripper_pub_
ros::Subscriber kenematics_pose_sub_
boost::shared_ptr< interactive_markers::InteractiveMarkerServer > interactive_marker_server_
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
ros::ServiceClient get_kinematics_pose_client_
std::string package_name_
std::map< int, std::string > id_joint_table_
ros::ServiceClient humanoid_footstep_client_
ros::Publisher init_pose_pub_
#define ROS_WARN_STREAM(args)
#define ROS_DEBUG_STREAM(args)
void updateCurrPos(double x, double y, double z)
void log(const LogLevel &level, const std::string &msg, std::string sender="Demo")
void getJointPose(std::string joint_name)
ROSLIB_DECL std::string getPath(const std::string &package_name)
void pointEigenToMsg(const Eigen::Vector3d &e, geometry_msgs::Point &m)
void setWalkingCommand(thormang3_foot_step_generator::FootStepCommand msg)
std::map< std::string, bool > using_mode_table_
void getKinematicsPoseCallback(const geometry_msgs::Pose::ConstPtr &msg)
void initFTFootCallback(const thormang3_feet_ft_module_msgs::BothWrench::ConstPtr &msg)
geometry_msgs::Pose pose_from_ui_
void updateHeadJointStatesCallback(const sensor_msgs::JointState::ConstPtr &msg)
std::map< int, std::string > module_table_
INLINE Rall1d< T, V, S > acos(const Rall1d< T, V, S > &x)
#define ROS_INFO_STREAM(args)
void updateHeadJointsAngle(double pan, double tilt)
ROSCPP_DECL bool isStarted()
ros::Publisher send_ik_msg_pub_
std::string getModuleName(const int &index)
std::map< int, std::string > motion_table_
void initFTCommand(std::string command)
void quaternionMsgToEigen(const geometry_msgs::Quaternion &m, Eigen::Quaterniond &e)
void updateDemoPoint(const geometry_msgs::Point point)
ros::ServiceClient set_joint_feedback_gain_client_
ros::Publisher move_lidar_pub_
ROSCPP_DECL void shutdown()
void sendIkMsg(thormang3_manipulation_module_msgs::KinematicsPose msg)
INLINE Rall1d< T, V, S > cos(const Rall1d< T, V, S > &arg)
#define ROS_ERROR_STREAM(args)
bool loadFeedbackGainFromYaml()
int getModuleIndex(const std::string &mode_name)
ROSCPP_DECL void spinOnce()
void makeInteractiveMarker(const geometry_msgs::Pose &marker_pose)
void getInteractiveMarkerPose()
ros::Publisher set_walking_balance_pub_
INLINE Rall1d< T, V, S > sin(const Rall1d< T, V, S > &arg)
ros::Publisher set_walking_command_pub_
std::map< std::string, int > joint_id_table_
void updateInteractiveMarker(const geometry_msgs::Pose &pose)
ROSCPP_DECL void waitForShutdown()
ros::Publisher send_ini_pose_msg_pub_
void updateCurrJoint(double value)
bool getIDFromJointName(const std::string &joint_name, int &id)
void setHeadJoint(double pan, double tilt)