Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #include <ros/ros.h>
00038 #include <moveit_msgs/ConstructConstraintApproximation.h>
00039
00040 static const std::string ROBOT_DESCRIPTION="robot_description";
00041 static const std::string CONSTRUCT_CONSTRAINT_APPROXIMATION_SERVICE_NAME="ompl_planning/construct_constraint_approximation";
00042
00043 moveit_msgs::ConstructConstraintApproximation::Request getDualArmConstraint()
00044 {
00045 moveit_msgs::Constraints c;
00046 moveit_msgs::PositionConstraint pcm2;
00047 pcm2.link_name = "r_wrist_roll_link";
00048 pcm2.header.frame_id = "l_wrist_roll_link";
00049
00050 pcm2.target_point_offset.x = 0.7;
00051 pcm2.target_point_offset.y = 0;
00052 pcm2.target_point_offset.z = 0;
00053 pcm2.constraint_region.primitives.resize(1);
00054 pcm2.constraint_region.primitives[0].type = shape_msgs::SolidPrimitive::BOX;
00055 pcm2.constraint_region.primitives[0].dimensions.x = 0.01;
00056 pcm2.constraint_region.primitives[0].dimensions.y = 0.01;
00057 pcm2.constraint_region.primitives[0].dimensions.z = 0.01;
00058
00059 pcm2.constraint_region.primitive_poses.resize(1);
00060 pcm2.constraint_region.primitive_poses[0].position.x = 0.0;
00061 pcm2.constraint_region.primitive_poses[0].position.y = 0.0;
00062 pcm2.constraint_region.primitive_poses[0].position.z = 0.0;
00063 pcm2.constraint_region.primitive_poses[0].orientation.x = 0.0;
00064 pcm2.constraint_region.primitive_poses[0].orientation.y = 0.0;
00065 pcm2.constraint_region.primitive_poses[0].orientation.z = 0.0;
00066 pcm2.constraint_region.primitive_poses[0].orientation.w = 1.0;
00067 pcm2.weight = 1.0;
00068 c.position_constraints.push_back(pcm2);
00069
00070 moveit_msgs::OrientationConstraint ocm;
00071 ocm.link_name = "l_wrist_roll_link";
00072 ocm.header.frame_id = "odom_combined";
00073 ocm.orientation.x = 0.5;
00074 ocm.orientation.y = 0.5;
00075 ocm.orientation.z = 0.5;
00076 ocm.orientation.w = 0.5;
00077 ocm.absolute_x_axis_tolerance = 0.01;
00078 ocm.absolute_y_axis_tolerance = M_PI;
00079 ocm.absolute_z_axis_tolerance = 0.01;
00080 ocm.weight = 1.0;
00081 c.orientation_constraints.push_back(ocm);
00082
00083 ocm.link_name = "r_wrist_roll_link";
00084 ocm.header.frame_id = "l_wrist_roll_link";
00085 ocm.orientation.x = 0.0;
00086 ocm.orientation.y = 0.0;
00087 ocm.orientation.z = 1.0;
00088 ocm.orientation.w = 0.0;
00089 ocm.absolute_x_axis_tolerance = 0.01;
00090 ocm.absolute_y_axis_tolerance = 0.01;
00091 ocm.absolute_z_axis_tolerance = 0.01;
00092 ocm.weight = 1.0;
00093 c.orientation_constraints.push_back(ocm);
00094
00095 moveit_msgs::ConstructConstraintApproximation::Request cca;
00096 cca.constraint = c;
00097 cca.group = "arms";
00098 cca.state_space_parameterization = "PoseModel";
00099 cca.samples = 1000;
00100 cca.edges_per_sample = 0;
00101 return cca;
00102 }
00103
00104 int main(int argc, char **argv)
00105 {
00106 ros::init(argc, argv, "call_cca", ros::init_options::AnonymousName);
00107
00108 ros::AsyncSpinner spinner(1);
00109 spinner.start();
00110
00111 ros::NodeHandle nh;
00112 ros::service::waitForService(CONSTRUCT_CONSTRAINT_APPROXIMATION_SERVICE_NAME);
00113 ros::ServiceClient cca_service_client = nh.serviceClient<moveit_msgs::ConstructConstraintApproximation>(CONSTRUCT_CONSTRAINT_APPROXIMATION_SERVICE_NAME);
00114
00115 moveit_msgs::ConstructConstraintApproximation::Request req = getDualArmConstraint();
00116 moveit_msgs::ConstructConstraintApproximation::Request res;
00117 if (cca_service_client.call(req, res))
00118 ROS_INFO("Done");
00119 else
00120 ROS_ERROR("Failed");
00121
00122 return 0;
00123 }