Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <ros/ros.h>
- #include <actionlib/client/simple_action_client.h>
- #include <arm_navigation_msgs/MoveArmAction.h>
- #include <arm_navigation_msgs/utils.h>
- int main(int argc, char **argv){
- ros::init (argc, argv, "move_arm_pose_goal_test");
- ros::NodeHandle nh;
- ROS_INFO("Connecting to MoveArmAction server. Waiting...");
- actionlib::SimpleActionClient<arm_navigation_msgs::MoveArmAction> TCP("/move_ur5",true);
- TCP.waitForServer();
- ROS_INFO("Connected to server");
- arm_navigation_msgs::MoveArmGoal goalA;
- goalA.motion_plan_request.group_name = "ur5";
- goalA.motion_plan_request.num_planning_attempts = 1;
- goalA.motion_plan_request.planner_id = std::string("");
- goalA.planner_service_name = std::string("ompl_planning/plan_kinematic_path");
- goalA.motion_plan_request.allowed_planning_time = ros::Duration(5.0);
- arm_navigation_msgs::SimplePoseConstraint desired_pose;
- desired_pose.header.frame_id = "base_link";
- desired_pose.link_name = " ee_link";
- desired_pose.pose.position.x = 0.0;
- desired_pose.pose.position.y = -0.0;
- desired_pose.pose.position.z = 0;
- desired_pose.pose.orientation.x = 0.0;
- desired_pose.pose.orientation.y = 0.0;
- desired_pose.pose.orientation.z = 0.0;
- desired_pose.pose.orientation.w = 1.0;
- desired_pose.absolute_position_tolerance.x = 0.02;
- desired_pose.absolute_position_tolerance.y = 0.02;
- desired_pose.absolute_position_tolerance.z = 0.02;
- desired_pose.absolute_roll_tolerance = 0.04;
- desired_pose.absolute_pitch_tolerance = 0.04;
- desired_pose.absolute_yaw_tolerance = 0.04;
- arm_navigation_msgs::addGoalConstraintToMoveArmGoal(desired_pose,goalA);
- if (nh.ok())
- {
- bool finished_within_time = false;
- TCP.sendGoal(goalA);
- finished_within_time = TCP.waitForResult(ros::Duration(200.0));
- if (!finished_within_time)
- {
- TCP.cancelGoal();
- ROS_INFO("Timed out achieving goal A");
- }
- else
- {
- actionlib::SimpleClientGoalState state = TCP.getState();
- bool success = (state == actionlib::SimpleClientGoalState::SUCCEEDED);
- if(success)
- ROS_INFO("Action finished: %s",state.toString().c_str());
- else
- ROS_INFO("Action failed: %s",state.toString().c_str());
- }
- }
- ros::shutdown();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement