moveit / moveit_task_constructor

A hierarchical multi-stage manipulation planner
https://moveit.github.io/moveit_task_constructor
BSD 3-Clause "New" or "Revised" License
184 stars 152 forks source link

User-defined constraints #562

Closed ammaraljodah closed 7 months ago

ammaraljodah commented 7 months ago

I am trying to make the planner to generate a trajectory such that respects a relation between two joints min_angle <= joint2 _angle - joint3_angle <= max_angle according to this https://moveit.readthedocs.io/en/latest/doc/pr2_tutorials/planning/src/doc/planning_scene_tutorial.html#checking-kinematic-constraints

this is possible by setting the setStateFeasibilityPredicate

User-defined constraints: User defined constraints can also be specified to the PlanningScene class. This is done by specifying a callback using the setStateFeasibilityPredicate function. Here’s a simple example of a user-defined callback that checks whether the “r_shoulder_pan” of the PR2 robot is at a positive or negative angle:

bool userCallback(const robot_state::RobotState& kinematic_state, bool verbose)
{
  const double* joint_values = kinematic_state.getJointPositions("r_shoulder_pan_joint");
  return (joint_values[0] > 0.0);
}

Now, whenever isStateFeasible is called, this user-defined callback will be called.

planning_scene.setStateFeasibilityPredicate(userCallback);

Note that all the planners available through MoveIt! and OMPL will currently perform collision checking, constraint checking and feasibility checking using user-defined callbacks.

`` However there is no way to access the planning scene in the task constructor, is there another way to do this? Many thanks

rhaschke commented 7 months ago

There is currently no way to set a user-defined feasibility callback. You just can configure a Constraint msg. However, this doesn't allow for complex joint dependencies to be checked.