00001 #include "wam_arm_navigation_alg.h" 00002 00003 WamArmNavigationAlgorithm::WamArmNavigationAlgorithm(void): 00004 frame_id_target(""), 00005 has_pose(false) 00006 { 00007 } 00008 00009 WamArmNavigationAlgorithm::~WamArmNavigationAlgorithm(void) 00010 { 00011 } 00012 00013 void WamArmNavigationAlgorithm::config_update(Config& new_cfg, uint32_t level) 00014 { 00015 this->lock(); 00016 00017 // save the current configuration 00018 this->config_=new_cfg; 00019 00020 this->unlock(); 00021 } 00022 00023 // WamArmNavigationAlgorithm Public API 00024 void WamArmNavigationAlgorithm::setTarget(const geometry_msgs::PoseStamped& pose,const std::string& nameFrame) 00025 { 00026 frame_id_target=nameFrame; 00027 pose_goal=pose; 00028 has_pose=true; 00029 } 00030 bool WamArmNavigationAlgorithm::hasPose() 00031 { 00032 return has_pose; 00033 } 00034 void WamArmNavigationAlgorithm::sendedPose() 00035 { 00036 has_pose=false; 00037 } 00039 void WamArmNavigationAlgorithm::setPlannerRequest(arm_navigation_msgs::MoveArmGoal& goal) 00040 { 00041 goal.planner_service_name=std::string("ompl_planning/plan_kinematic_path"); 00042 goal.motion_plan_request.group_name="iri_wam"; 00043 goal.motion_plan_request.num_planning_attempts = 2; 00044 goal.motion_plan_request.allowed_planning_time = ros::Duration(5.0); 00045 goal.motion_plan_request.planner_id = std::string(""); 00046 goal.motion_plan_request.expected_path_duration = ros::Duration(10.0); 00047 goal.motion_plan_request.expected_path_dt = ros::Duration(0.2); 00048 } 00049 00051 void WamArmNavigationAlgorithm::setPlannerRequestPose(arm_navigation_msgs::MoveArmGoal& goal) 00052 { 00053 00054 arm_navigation_msgs::SimplePoseConstraint desired_pose; 00055 desired_pose.link_name = frame_id_target; 00056 desired_pose.header.frame_id = pose_goal.header.frame_id; 00057 desired_pose.pose = pose_goal.pose; 00058 desired_pose.absolute_position_tolerance.x = 0.05; 00059 desired_pose.absolute_position_tolerance.y = 0.05; 00060 desired_pose.absolute_position_tolerance.z = 0.05; 00061 desired_pose.absolute_roll_tolerance = 0.05; 00062 desired_pose.absolute_pitch_tolerance = 0.05; 00063 desired_pose.absolute_yaw_tolerance = 0.05; 00064 00065 addGoalConstraintToMoveArmGoal(desired_pose, goal); 00066 00067 } 00068 00073 void WamArmNavigationAlgorithm::addGoalConstraintToMoveArmGoal(const arm_navigation_msgs::SimplePoseConstraint &pose_constraint, arm_navigation_msgs::MoveArmGoal &move_arm_goal) 00074 { 00075 arm_navigation_msgs::PositionConstraint position_constraint; 00076 arm_navigation_msgs::OrientationConstraint orientation_constraint; 00077 arm_navigation_msgs::poseConstraintToPositionOrientationConstraints(pose_constraint, position_constraint, orientation_constraint); 00078 move_arm_goal.motion_plan_request.goal_constraints.position_constraints.push_back(position_constraint); 00079 move_arm_goal.motion_plan_request.goal_constraints.orientation_constraints.push_back(orientation_constraint); 00080 }