Hello everyone!
So I have been doing some test with path constraints for the last couple of days. What it really bothers me is that when I plan with orientation path constraints, I always get trajectories which seems to "jump" at certain points. So I capture one of those trajectories and extracted two points, which seem to be the problem:
...
positions: [0.07030076982423171, -0.060087761165928635, -1.7623868458114238, -0.8055791796513985, 0.06632340776779573, 2.49202134613582]
velocities: [0.010108259866117523, -0.01800968406797939, 0.020192532227076853, -0.49630065376978627, -0.026644927582898645, -0.421714333938974]
accelerations: [-0.008078562597439061, 0.009811037477290657, -0.007694065363548413, 0.12815414524762112, 0.03344371346892065, -1.0059267414426358]
effort: []
time_from_start:
secs: 1
nsecs: 916516542
-
positions: [0.07474439076488598, -0.08461940243371537, -1.7228947510669521, -1.9972359537230413, 0.09865933075461127, -2.562606872755544]
velocities: [0.025603867301923242, -0.023606231187315568, 0.022925844088660524, -0.3980391520039673, 0.04631621435255396, -0.5156269910710267]
accelerations: [0.023976273459930215, -0.016057216871521184, 0.010957032514299437, -0.040468771594689944, 0.036180197223611675, 0.9867665299302922]
effort: []
time_from_start:
secs: 5
nsecs: 253830651
...
When you look at the positions between the two points, there are such big jumps in axis 6 (and maybe also in axis 4). The pose of the end effector, however, remains almost the same. It seems to me that it suddenly switch to another IK solution. What I don't understand is, why would such two points considered to be adjacent by the planner? I have never had such problem in planning WITHOUT orientation path constraints, even with the same start point and target pose.
The following is the code I use for planning. Did I miss something or doing something wrong? What the code trying to do is to move the end effector while grapping a box. The box can rotate around the y-axis, but it can't tilt too hard otherwise the things in the box will fall out. I am using RRTConnectkConfigDefault as planner and an IKFast solver for my Schunk LWA 4P arm.
// Setting the target pose
geometry_msgs::Pose target_pose1;
target_pose1.orientation.x = -0.70710678;
target_pose1.orientation.y = 0.0;
target_pose1.orientation.z = 0.0;
target_pose1.orientation.w = 0.70710678;
target_pose1.position.x = 0.0;
target_pose1.position.y = 0.5;
target_pose1.position.z = 0.4;
group.setPoseTarget(target_pose1);
// Setting the start joint state
robot_state::RobotState start_state(*group.getCurrentState());
geometry_msgs::Pose start_pose2;
start_pose2.orientation.x = 0.5;
start_pose2.orientation.y = 0.5;
start_pose2.orientation.z = -0.5;
start_pose2.orientation.w = -0.5;
start_pose2.position.x = -0.4;
start_pose2.position.y = 0.0;
start_pose2.position.z = 0.4;
const robot_state::JointModelGroup *joint_model_group =
start_state.getJointModelGroup(group.getName());
start_state.setFromIK(joint_model_group, start_pose2, 5, 1.0);
// Constructing orientation path constraints
moveit_msgs::OrientationConstraint ocm;
ocm.link_name = "gripper_palm_link";
ocm.header.frame_id = "arm_base_link";
ocm.orientation.x = 0.5;
ocm.orientation.y = 0.5;
ocm.orientation.z = -0.5;
ocm.orientation.w = -0.5;
ocm.absolute_x_axis_tolerance = 0.4;
ocm.absolute_y_axis_tolerance = 2.5;
ocm.absolute_z_axis_tolerance = 0.4;
ocm.weight = 1.0;
// Adding path constraints
moveit_msgs::Constraints test_constraints;
test_constraints.orientation_constraints.push_back(ocm);
group.setPathConstraints(test_constraints);
// Start planning
moveit::planning_interface::MoveGroup::Plan my_plan;
group.setStartState(start_state);
group.setPoseTarget(target_pose1);
success = group.plan(my_plan);
Any helps will be appreciated! Thank you in advance!
Best regards,
Junhong Liang