-
Notifications
You must be signed in to change notification settings - Fork 706
Port OMPL orientation constraints to MoveIt2 #1273
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
db3d4f0
a82e174
17b7651
1efe4c4
a8ad53c
0560c6e
1170c2e
3856cdb
8209509
135da21
65b259f
c396e55
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -200,11 +200,8 @@ BoxConstraint::BoxConstraint(const moveit::core::RobotModelConstPtr& robot_model | |
|
|
||
| void BoxConstraint::parseConstraintMsg(const moveit_msgs::msg::Constraints& constraints) | ||
| { | ||
| RCLCPP_DEBUG(LOGGER, "Parsing box position constraint for OMPL constrained state space."); | ||
| assert(bounds_.size() == 0); | ||
| bounds_ = positionConstraintMsgToBoundVector(constraints.position_constraints.at(0)); | ||
| RCLCPP_DEBUG(LOGGER, "Parsed Box constraints"); | ||
| RCLCPP_DEBUG_STREAM(LOGGER, "Bounds: " << bounds_); | ||
|
|
||
| // extract target position and orientation | ||
| geometry_msgs::msg::Point position = | ||
|
|
@@ -216,7 +213,6 @@ void BoxConstraint::parseConstraintMsg(const moveit_msgs::msg::Constraints& cons | |
| target_orientation_); | ||
|
|
||
| link_name_ = constraints.position_constraints.at(0).link_name; | ||
| RCLCPP_DEBUG_STREAM(LOGGER, "Position constraints applied to link: " << link_name_); | ||
| } | ||
|
|
||
| Eigen::VectorXd BoxConstraint::calcError(const Eigen::Ref<const Eigen::VectorXd>& x) const | ||
|
|
@@ -270,12 +266,7 @@ void EqualityPositionConstraint::parseConstraintMsg(const moveit_msgs::msg::Cons | |
| tf2::fromMsg(constraints.position_constraints.at(0).constraint_region.primitive_poses.at(0).orientation, | ||
| target_orientation_); | ||
|
|
||
| RCLCPP_DEBUG_STREAM(LOGGER, "Equality constraint on x-position? " << (is_dim_constrained_[0] ? "yes" : "no")); | ||
| RCLCPP_DEBUG_STREAM(LOGGER, "Equality constraint on y-position? " << (is_dim_constrained_[1] ? "yes" : "no")); | ||
| RCLCPP_DEBUG_STREAM(LOGGER, "Equality constraint on z-position? " << (is_dim_constrained_[2] ? "yes" : "no")); | ||
|
|
||
| link_name_ = constraints.position_constraints.at(0).link_name; | ||
| RCLCPP_DEBUG_STREAM(LOGGER, "Position constraints applied to link: " << link_name_); | ||
| } | ||
|
|
||
| void EqualityPositionConstraint::function(const Eigen::Ref<const Eigen::VectorXd>& joint_values, | ||
|
|
@@ -310,6 +301,32 @@ void EqualityPositionConstraint::jacobian(const Eigen::Ref<const Eigen::VectorXd | |
| } | ||
| } | ||
|
|
||
| /****************************************** | ||
| * Orientation constraints | ||
| * ****************************************/ | ||
| void OrientationConstraint::parseConstraintMsg(const moveit_msgs::msg::Constraints& constraints) | ||
stephanie-eng marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| { | ||
| bounds_ = orientationConstraintMsgToBoundVector(constraints.orientation_constraints.at(0)); | ||
|
|
||
| tf2::fromMsg(constraints.orientation_constraints.at(0).orientation, target_orientation_); | ||
|
|
||
| link_name_ = constraints.orientation_constraints.at(0).link_name; | ||
| } | ||
|
|
||
| Eigen::VectorXd OrientationConstraint::calcError(const Eigen::Ref<const Eigen::VectorXd>& x) const | ||
stephanie-eng marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| { | ||
| Eigen::Matrix3d orientation_difference = forwardKinematics(x).linear().transpose() * target_orientation_; | ||
| Eigen::AngleAxisd aa(orientation_difference); | ||
| return aa.axis() * aa.angle(); | ||
| } | ||
|
|
||
| Eigen::MatrixXd OrientationConstraint::calcErrorJacobian(const Eigen::Ref<const Eigen::VectorXd>& x) const | ||
stephanie-eng marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| { | ||
| Eigen::Matrix3d orientation_difference = forwardKinematics(x).linear().transpose() * target_orientation_; | ||
| Eigen::AngleAxisd aa{ orientation_difference }; | ||
| return -angularVelocityToAngleAxis(aa.angle(), aa.axis()) * robotGeometricJacobian(x).bottomRows(3); | ||
| } | ||
|
|
||
| /************************************ | ||
| * MoveIt constraint message parsing | ||
| * **********************************/ | ||
|
|
@@ -330,6 +347,20 @@ Bounds positionConstraintMsgToBoundVector(const moveit_msgs::msg::PositionConstr | |
| { dims.at(0) / 2.0, dims.at(1) / 2.0, dims.at(2) / 2.0 } }; | ||
| } | ||
|
|
||
| Bounds orientationConstraintMsgToBoundVector(const moveit_msgs::msg::OrientationConstraint& ori_con) | ||
| { | ||
| std::vector<double> dims = { ori_con.absolute_x_axis_tolerance, ori_con.absolute_y_axis_tolerance, | ||
| ori_con.absolute_z_axis_tolerance }; | ||
|
|
||
| // dimension of -1 signifies unconstrained parameter, so set to infinity | ||
| for (auto& dim : dims) | ||
| { | ||
| if (dim == -1) | ||
| dim = std::numeric_limits<double>::infinity(); | ||
| } | ||
| return { { -dims[0], -dims[1], -dims[2] }, { dims[0], dims[1], dims[2] } }; | ||
| } | ||
|
|
||
| /****************************************** | ||
| * OMPL Constraints Factory | ||
| * ****************************************/ | ||
|
|
@@ -348,40 +379,38 @@ std::shared_ptr<BaseConstraint> createOMPLConstraint(const moveit::core::RobotMo | |
|
|
||
| if (num_pos_con > 1) | ||
| { | ||
| RCLCPP_WARN(LOGGER, "Only a single position constraints supported. Using the first one."); | ||
| RCLCPP_WARN(LOGGER, "Only a single position constraint is supported. Using the first one."); | ||
| } | ||
| if (num_ori_con > 1) | ||
| { | ||
| RCLCPP_WARN(LOGGER, "Only a single orientation constraints supported. Using the first one."); | ||
| RCLCPP_WARN(LOGGER, "Only a single orientation constraint is supported. Using the first one."); | ||
| } | ||
|
|
||
| if (num_pos_con > 0 && num_ori_con > 0) | ||
| { | ||
| RCLCPP_ERROR(LOGGER, "Combining position and orientation constraints not implemented yet for OMPL's constrained " | ||
| RCLCPP_ERROR(LOGGER, "Combining position and orientation constraints is not implemented yet for OMPL's constrained " | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, this kind of sucks. Oh well. We can work with it.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @JeroenDM what is the difficulty here? The underlying OMPL code shouldn't care. Can you describe what is needed to support this? |
||
| "state space."); | ||
| return nullptr; | ||
| } | ||
| else if (num_pos_con > 0) | ||
| { | ||
| RCLCPP_DEBUG_STREAM(LOGGER, "Constraint name: " << constraints.name); | ||
| BaseConstraintPtr pos_con; | ||
| if (constraints.name == "use_equality_constraints") | ||
| { | ||
| RCLCPP_DEBUG(LOGGER, "OMPL is using equality position constraints."); | ||
| pos_con = std::make_shared<EqualityPositionConstraint>(robot_model, group, num_dofs); | ||
| } | ||
| else | ||
| { | ||
| RCLCPP_DEBUG(LOGGER, "OMPL is using box position constraints."); | ||
| pos_con = std::make_shared<BoxConstraint>(robot_model, group, num_dofs); | ||
| } | ||
| pos_con->init(constraints); | ||
| return pos_con; | ||
| } | ||
| else if (num_ori_con > 0) | ||
| { | ||
| RCLCPP_ERROR(LOGGER, "Orientation constraints are not yet supported."); | ||
| return nullptr; | ||
| auto ori_con = std::make_shared<OrientationConstraint>(robot_model, group, num_dofs); | ||
| ori_con->init(constraints); | ||
| return ori_con; | ||
| } | ||
| else | ||
| { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.