38 #include <geometric_shapes/body_operations.h>
39 #include <geometric_shapes/shape_operations.h>
42 #include <geometric_shapes/check_isometry.h>
43 #include <rclcpp/logger.hpp>
44 #include <rclcpp/logging.hpp>
45 #include <rclcpp/time.hpp>
46 #include <tf2_eigen/tf2_eigen.hpp>
53 #include <rclcpp/clock.hpp>
54 #include <rclcpp/duration.hpp>
59 static const rclcpp::Logger LOGGER =
rclcpp::get_logger(
"moveit_kinematic_constraints.kinematic_constraints");
61 static double normalizeAngle(
double angle)
63 double v = fmod(angle, 2.0 * M_PI);
77 static double normalizeAbsoluteAngle(
const double angle)
79 const double normalized_angle = std::fmod(std::abs(angle), 2 * M_PI);
80 return std::min(2 * M_PI - normalized_angle, normalized_angle);
90 template <
typename Derived>
91 std::tuple<Eigen::Matrix<typename Eigen::MatrixBase<Derived>::Scalar, 3, 1>,
bool>
96 EIGEN_STATIC_ASSERT_MATRIX_SPECIFIC_SIZE(Derived, 3, 3)
97 using Index = EIGEN_DEFAULT_DENSE_INDEX_TYPE;
98 using Scalar =
typename Eigen::MatrixBase<Derived>::Scalar;
102 Eigen::Matrix<Scalar, 3, 1> res;
103 const Scalar rsum = sqrt((R(i, i) * R(i, i) + R(i, j) * R(i, j) + R(j, k) * R(j, k) + R(k, k) * R(k, k)) / 2);
104 res[1] = atan2(R(i, k), rsum);
106 if (rsum > 4 * Eigen::NumTraits<Scalar>::epsilon())
108 res[0] = atan2(-R(j, k), R(k, k));
109 res[2] = atan2(-R(i, j), R(i, i));
110 return { res,
true };
112 else if (R(i, k) > 0)
114 const Scalar spos = R(j, i) + R(k, j);
115 const Scalar cpos = R(j, j) - R(k, i);
116 res[0] = atan2(spos, cpos);
118 return { res,
false };
120 const Scalar sneg = R(k, j) - R(j, i);
121 const Scalar cneg = R(j, j) + R(k, i);
122 res[0] = atan2(sneg, cneg);
124 return { res,
false };
128 : type_(UNKNOWN_CONSTRAINT), robot_model_(model), constraint_weight_(std::numeric_limits<double>::epsilon())
140 if (jc.tolerance_above < 0.0 || jc.tolerance_below < 0.0)
142 RCLCPP_WARN(LOGGER,
"JointConstraint tolerance values must be positive.");
155 std::size_t pos = jc.joint_name.find_last_of(
'/');
156 if (pos != std::string::npos)
159 if (pos + 1 < jc.joint_name.length())
173 RCLCPP_ERROR(LOGGER,
"Joint '%s' has no parameters to constrain", jc.joint_name.c_str());
179 "Joint '%s' has more than one parameter to constrain. "
180 "This type of constraint is not supported.",
181 jc.joint_name.c_str());
189 for (std::size_t i = 0; i < local_var_names.size(); ++i)
199 RCLCPP_ERROR(LOGGER,
"Local variable name '%s' is not known to joint '%s'",
local_variable_name_.c_str(),
242 "Joint %s is constrained to be below the minimum bounds. "
243 "Assuming minimum bounds instead.",
244 jc.joint_name.c_str());
251 "Joint %s is constrained to be above the maximum bounds. "
252 "Assuming maximum bounds instead.",
253 jc.joint_name.c_str());
257 if (jc.weight <= std::numeric_limits<double>::epsilon())
259 RCLCPP_WARN(LOGGER,
"The weight on constraint for joint '%s' is very near zero. Setting to 1.0.",
260 jc.joint_name.c_str());
298 dif = 2.0 * M_PI - dif;
300 else if (dif < -M_PI)
314 "Constraint %s:: Joint name: '%s', actual value: %f, desired value: %f, "
315 "tolerance_above: %f, tolerance_below: %f",
344 out <<
" tolerance below = ";
346 out <<
" tolerance above = ";
351 out <<
"No constraint" <<
'\n';
362 RCLCPP_WARN(LOGGER,
"Position constraint link model %s not found in kinematic model. Constraint invalid.",
363 pc.link_name.c_str());
367 if (pc.header.frame_id.empty())
369 RCLCPP_WARN(LOGGER,
"No frame specified for position constraint on link '%s'!", pc.link_name.c_str());
388 for (std::size_t i = 0; i < pc.constraint_region.primitives.size(); ++i)
390 std::unique_ptr<shapes::Shape> shape(shapes::constructShapeFromMsg(pc.constraint_region.primitives[i]));
393 if (pc.constraint_region.primitive_poses.size() <= i)
395 RCLCPP_WARN(LOGGER,
"Constraint region message does not contain enough primitive poses");
399 tf2::fromMsg(pc.constraint_region.primitive_poses[i], t);
405 const bodies::BodyPtr body(bodies::createEmptyBodyFromShapeType(shape->type));
406 body->setDimensionsDirty(shape.get());
408 body->updateInternalData();
412 RCLCPP_WARN(LOGGER,
"Could not construct primitive shape %zu", i);
416 for (std::size_t i = 0; i < pc.constraint_region.meshes.size(); ++i)
418 std::unique_ptr<shapes::Shape> shape(shapes::constructShapeFromMsg(pc.constraint_region.meshes[i]));
421 if (pc.constraint_region.mesh_poses.size() <= i)
423 RCLCPP_WARN(LOGGER,
"Constraint region message does not contain enough primitive poses");
427 tf2::fromMsg(pc.constraint_region.mesh_poses[i], t);
432 const bodies::BodyPtr body(bodies::createEmptyBodyFromShapeType(shape->type));
433 body->setDimensionsDirty(shape.get());
435 body->updateInternalData();
440 RCLCPP_WARN(LOGGER,
"Could not construct mesh shape %zu", i);
444 if (pc.weight <= std::numeric_limits<double>::epsilon())
446 RCLCPP_WARN(LOGGER,
"The weight on position constraint for link '%s' is near zero. Setting to 1.0.",
447 pc.link_name.c_str());
469 bool some_match =
false;
475 if (diff.translation().norm() < margin && diff.linear().isIdentity(margin) &&
481 other_region_matches_this[j] =
true;
489 if (!other_region_matches_this[i])
500 const std::string&
name,
double weight,
501 bool result,
bool verbose)
503 double dx = desired.x() - pt.x();
504 double dy = desired.y() - pt.y();
505 double dz = desired.z() - pt.z();
508 RCLCPP_INFO(LOGGER,
"Position constraint %s on link '%s'. Desired: %f, %f, %f, current: %f, %f, %f",
509 result ?
"satisfied" :
"violated",
name.c_str(), desired.x(), desired.y(), desired.z(), pt.x(), pt.y(),
511 RCLCPP_INFO(LOGGER,
"Differences %g %g %g", dx, dy, dz);
513 return ConstraintEvaluationResult(result, weight * sqrt(dx * dx + dy * dy + dz * dz));
568 out <<
"No constraint" <<
'\n';
597 RCLCPP_WARN(LOGGER,
"Could not find link model for link name %s", oc.link_name.c_str());
600 Eigen::Quaterniond q;
601 tf2::fromMsg(oc.orientation, q);
602 if (fabs(q.norm() - 1.0) > 1e-3)
605 "Orientation constraint for link '%s' is probably incorrect: %f, %f, %f, "
606 "%f. Assuming identity instead.",
607 oc.link_name.c_str(), oc.orientation.x, oc.orientation.y, oc.orientation.z, oc.orientation.w);
608 q = Eigen::Quaterniond(1.0, 0.0, 0.0, 0.0);
611 if (oc.header.frame_id.empty())
612 RCLCPP_WARN(LOGGER,
"No frame specified for position constraint on link '%s'!", oc.link_name.c_str());
628 std::stringstream matrix_str;
630 RCLCPP_DEBUG(LOGGER,
"The desired rotation matrix for link '%s' in frame %s is:\n%s", oc.link_name.c_str(),
633 if (oc.weight <= std::numeric_limits<double>::epsilon())
635 RCLCPP_WARN(LOGGER,
"The weight on orientation constraint for link '%s' is near zero. Setting to 1.0.",
636 oc.link_name.c_str());
650 "Unknown parameterization for orientation constraint tolerance, using default (XYZ_EULER_ANGLES).");
656 RCLCPP_WARN(LOGGER,
"Near-zero value for absolute_x_axis_tolerance");
659 RCLCPP_WARN(LOGGER,
"Near-zero value for absolute_y_axis_tolerance");
662 RCLCPP_WARN(LOGGER,
"Near-zero value for absolute_z_axis_tolerance");
705 Eigen::Isometry3d diff;
720 std::tuple<Eigen::Vector3d, bool> euler_angles_error;
731 xyz_rotation = std::get<Eigen::Vector3d>(euler_angles_error);
732 if (!std::get<bool>(euler_angles_error))
736 xyz_rotation(2) = xyz_rotation(0);
741 xyz_rotation = xyz_rotation.unaryExpr(&normalizeAbsoluteAngle);
745 Eigen::AngleAxisd aa(diff.linear());
746 xyz_rotation = aa.axis() * aa.angle();
747 xyz_rotation(0) = fabs(xyz_rotation(0));
748 xyz_rotation(1) = fabs(xyz_rotation(1));
749 xyz_rotation(2) = fabs(xyz_rotation(2));
754 RCLCPP_ERROR(LOGGER,
"The parameterization type for the orientation constraints is invalid.");
766 "Orientation constraint %s for link '%s'. Quaternion desired: %f %f %f %f, quaternion "
767 "actual: %f %f %f %f, error: x=%f, y=%f, z=%f, tolerance: x=%f, y=%f, z=%f",
768 result ?
"satisfied" :
"violated",
link_model_->
getName().c_str(), q_des.x(), q_des.y(), q_des.z(),
769 q_des.w(), q_act.x(), q_act.y(), q_act.z(), q_act.w(), xyz_rotation(0), xyz_rotation(1),
782 out <<
"Desired orientation:" << q_des.x() <<
',' << q_des.y() <<
',' << q_des.z() <<
',' << q_des.w() <<
'\n';
785 out <<
"No constraint" <<
'\n';
814 if (vc.target_radius <= std::numeric_limits<double>::epsilon())
815 RCLCPP_WARN(LOGGER,
"The radius of the target disc that must be visible should be strictly positive");
817 if (vc.cone_sides < 3)
820 "The number of sides for the visibility region must be 3 or more. "
821 "Assuming 3 sides instead of the specified %d",
830 double delta = 2.0 * M_PI /
static_cast<double>(
cone_sides_);
832 for (
unsigned int i = 0; i <
cone_sides_; ++i, a += delta)
865 if (vc.weight <= std::numeric_limits<double>::epsilon())
867 RCLCPP_WARN(LOGGER,
"The weight of visibility constraint is near zero. Setting to 1.0.");
894 if (diff.translation().norm() > margin)
896 if (!diff.linear().isIdentity(margin))
900 if (diff.translation().norm() > margin)
902 if (!diff.linear().isIdentity(margin))
911 return (
target_radius_ > std::numeric_limits<double>::epsilon()) ||
917 const Eigen::Isometry3d& tform_world_to_target)
const
920 const Eigen::Isometry3d& sp = tform_world_to_sensor;
923 const Eigen::Isometry3d& tp = tform_world_to_target;
926 const EigenSTL::vector_Vector3d* points = &
points_;
927 std::unique_ptr<EigenSTL::vector_Vector3d> temp_points;
929 temp_points = std::make_unique<EigenSTL::vector_Vector3d>(
points_.size());
930 for (std::size_t i = 0; i <
points_.size(); ++i)
932 temp_points->at(i) = tp *
points_[i];
934 points = temp_points.get();
937 shapes::Mesh* m =
new shapes::Mesh();
939 m->vertices =
new double[m->vertex_count * 3];
941 m->triangles =
new unsigned int[m->triangle_count * 3];
945 m->vertices[0] = sp.translation().x();
946 m->vertices[1] = sp.translation().y();
947 m->vertices[2] = sp.translation().z();
950 m->vertices[3] = tp.translation().x();
951 m->vertices[4] = tp.translation().y();
952 m->vertices[5] = tp.translation().z();
955 for (std::size_t i = 0; i < points->size(); ++i)
957 m->vertices[i * 3 + 6] = points->at(i).x();
958 m->vertices[i * 3 + 7] = points->at(i).y();
959 m->vertices[i * 3 + 8] = points->at(i).z();
963 std::size_t p3 = points->size() * 3;
964 for (std::size_t i = 1; i < points->size(); ++i)
967 std::size_t i3 = (i - 1) * 3;
968 m->triangles[i3] = i + 1;
969 m->triangles[i3 + 1] = 0;
970 m->triangles[i3 + 2] = i + 2;
972 std::size_t i6 = p3 + i3;
973 m->triangles[i6] = i + 1;
974 m->triangles[i6 + 1] = 1;
975 m->triangles[i6 + 2] = i + 2;
979 m->triangles[p3 - 3] = points->size() + 1;
980 m->triangles[p3 - 2] = 0;
981 m->triangles[p3 - 1] = 2;
983 m->triangles[p3 - 3] = points->size() + 1;
984 m->triangles[p3 - 2] = 1;
985 m->triangles[p3 - 1] = 2;
991 visualization_msgs::msg::MarkerArray& markers)
const
1000 visualization_msgs::msg::Marker mk;
1001 shapes::constructMarkerFromShape(m, mk);
1004 mk.header.stamp = rclcpp::Clock().now();
1005 mk.ns =
"constraints";
1007 mk.action = visualization_msgs::msg::Marker::ADD;
1008 mk.pose.position.x = 0;
1009 mk.pose.position.y = 0;
1010 mk.pose.position.z = 0;
1011 mk.pose.orientation.x = 0;
1012 mk.pose.orientation.y = 0;
1013 mk.pose.orientation.z = 0;
1014 mk.pose.orientation.w = 1;
1015 mk.lifetime = rclcpp::Duration::from_seconds(60);
1023 markers.markers.push_back(mk);
1025 visualization_msgs::msg::Marker mka;
1026 mka.type = visualization_msgs::msg::Marker::ARROW;
1027 mka.action = visualization_msgs::msg::Marker::ADD;
1028 mka.color = mk.color;
1031 mka.header = mk.header;
1034 mka.lifetime = mk.lifetime;
1038 mka.points.resize(2);
1040 mka.points[0].x = tp.translation().x();
1041 mka.points[0].y = tp.translation().y();
1042 mka.points[0].z = tp.translation().z();
1043 mka.points[1].x =
d.x();
1044 mka.points[1].y =
d.y();
1045 mka.points[1].z =
d.z();
1046 markers.markers.push_back(mka);
1053 mka.points[0].x = sp.translation().x();
1054 mka.points[0].y = sp.translation().y();
1055 mka.points[0].z = sp.translation().z();
1056 mka.points[1].x =
d.x();
1057 mka.points[1].y =
d.y();
1058 mka.points[1].z =
d.z();
1060 markers.markers.push_back(mka);
1077 const Eigen::Vector3d& normal1 = tform_world_to_target.linear().col(2) * -1.0;
1078 double dp = sensor_view_axis.dot(normal1);
1079 double ang = acos(dp);
1084 RCLCPP_INFO(LOGGER,
"Visibility constraint is violated because the sensor is looking at "
1094 "Visibility constraint is violated because the view angle is %lf "
1095 "(above the maximum allowed of %lf)",
1106 (tform_world_to_target.translation() - tform_world_to_sensor.translation()).normalized();
1107 double dp = sensor_view_axis.dot(dir);
1112 RCLCPP_INFO(LOGGER,
"Visibility constraint is violated because the sensor is looking at "
1118 double ang = acos(dp);
1124 "Visibility constraint is violated because the range angle is %lf "
1125 "(above the maximum allowed of %lf)",
1135 shapes::Mesh* m =
getVisibilityCone(tform_world_to_sensor, tform_world_to_target);
1138 RCLCPP_ERROR(LOGGER,
"Visibility constraint is violated because we could not create the visibility cone mesh.");
1143 const auto collision_env_local = std::make_shared<collision_detection::CollisionEnvFCL>(
robot_model_);
1144 collision_env_local->getWorld()->addToObject(
"cone", shapes::ShapeConstPtr(m), Eigen::Isometry3d::Identity());
1159 collision_env_local->checkRobotCollision(req, res, state, acm);
1163 std::stringstream ss;
1165 RCLCPP_INFO(LOGGER,
"Visibility constraint %ssatisfied. Visibility cone approximation:\n %s",
1166 res.
collision ?
"not " :
"", ss.str().c_str());
1169 collision_env_local->getWorld()->removeObject(
"cone");
1188 RCLCPP_DEBUG(LOGGER,
"Accepted collision with either sensor or target");
1196 RCLCPP_DEBUG(LOGGER,
"Accepted collision with either sensor or target");
1206 out <<
"Visibility constraint for sensor in frame '" <<
sensor_frame_id_ <<
"' using target in frame '"
1211 out <<
"No constraint" <<
'\n';
1227 for (
const moveit_msgs::msg::JointConstraint& joint_constraint : jc)
1230 bool u = ev->
configure(joint_constraint);
1231 result = result && u;
1243 for (
const moveit_msgs::msg::PositionConstraint& position_constraint : pc)
1246 bool u = ev->
configure(position_constraint, tf);
1247 result = result && u;
1259 for (
const moveit_msgs::msg::OrientationConstraint& orientation_constraint : oc)
1262 bool u = ev->
configure(orientation_constraint, tf);
1263 result = result && u;
1266 all_constraints_.orientation_constraints.push_back(orientation_constraint);
1275 for (
const moveit_msgs::msg::VisibilityConstraint& visibility_constraint : vc)
1278 bool u = ev->
configure(visibility_constraint, tf);
1279 result = result && u;
1289 bool j =
add(c.joint_constraints);
1290 bool p =
add(c.position_constraints, tf);
1291 bool o =
add(c.orientation_constraints, tf);
1292 bool v =
add(c.visibility_constraints, tf);
1293 return j && p && o && v;
1310 std::vector<ConstraintEvaluationResult>& results,
1319 result.
distance += results[i].distance;
1329 kinematic_constraint->print(out);
Definition of a structure for the allowed collision matrix. All elements in the collision world are r...
void setDefaultEntry(const std::string &name, bool allowed)
Set the default value for entries that include name but are not set explicitly with setEntry().
Class for handling single DOF joint constraints.
double joint_tolerance_below_
Position and tolerance values.
std::string joint_variable_name_
The joint variable name.
bool equal(const KinematicConstraint &other, double margin) const override
Check if two joint constraints are the same.
ConstraintEvaluationResult decide(const moveit::core::RobotState &state, bool verbose=false) const override
Decide whether the constraint is satisfied in the indicated state.
int joint_variable_index_
The index of the joint variable name in the full robot state.
double joint_tolerance_above_
bool joint_is_continuous_
Whether or not the joint is continuous.
void clear() override
Clear the stored constraint.
bool configure(const moveit_msgs::msg::JointConstraint &jc)
Configure the constraint based on a moveit_msgs::msg::JointConstraint.
const moveit::core::JointModel * joint_model_
The joint from the kinematic model for this constraint.
bool enabled() const override
This function returns true if this constraint is configured and able to decide whether states do meet...
void print(std::ostream &out=std::cout) const override
Print the constraint data.
std::string local_variable_name_
The local variable name for a multi DOF joint, if any.
A class that contains many different constraints, and can check RobotState *versus the full set....
void print(std::ostream &out=std::cout) const
Print the constraint data.
void clear()
Clear the stored constraints.
bool equal(const KinematicConstraintSet &other, double margin) const
Whether or not another KinematicConstraintSet is equal to this one.
std::vector< moveit_msgs::msg::VisibilityConstraint > visibility_constraints_
Messages corresponding to all internal visibility constraints.
std::vector< moveit_msgs::msg::OrientationConstraint > orientation_constraints_
Messages corresponding to all internal orientation constraints.
moveit::core::RobotModelConstPtr robot_model_
The kinematic model used for by the Set.
bool add(const moveit_msgs::msg::Constraints &c, const moveit::core::Transforms &tf)
Add all known constraints.
moveit_msgs::msg::Constraints all_constraints_
Messages corresponding to all internal constraints.
std::vector< moveit_msgs::msg::PositionConstraint > position_constraints_
Messages corresponding to all internal position constraints.
std::vector< KinematicConstraintPtr > kinematic_constraints_
Shared pointers to all the member constraints.
ConstraintEvaluationResult decide(const moveit::core::RobotState &state, bool verbose=false) const
Determines whether all constraints are satisfied by state, returning a single evaluation result.
std::vector< moveit_msgs::msg::JointConstraint > joint_constraints_
Messages corresponding to all internal joint constraints.
Base class for representing a kinematic constraint.
double constraint_weight_
The weight of a constraint is a multiplicative factor associated to the distance computed by the deci...
ConstraintType type_
The type of the constraint.
virtual ~KinematicConstraint()
ConstraintType getType() const
Get the type of constraint.
KinematicConstraint(const moveit::core::RobotModelConstPtr &model)
Constructor.
moveit::core::RobotModelConstPtr robot_model_
The kinematic model associated with this constraint.
Class for constraints on the orientation of a link.
bool mobile_frame_
Whether or not the header frame is mobile or fixed.
void clear() override
Clear the stored constraint.
bool equal(const KinematicConstraint &other, double margin) const override
Check if two orientation constraints are the same.
void print(std::ostream &out=std::cout) const override
Print the constraint data.
double absolute_y_axis_tolerance_
std::string desired_rotation_frame_id_
The target frame of the transform tree.
bool configure(const moveit_msgs::msg::OrientationConstraint &oc, const moveit::core::Transforms &tf)
Configure the constraint based on a moveit_msgs::msg::OrientationConstraint.
ConstraintEvaluationResult decide(const moveit::core::RobotState &state, bool verbose=false) const override
Decide whether the constraint is satisfied in the indicated state.
double absolute_z_axis_tolerance_
Storage for the tolerances.
Eigen::Matrix3d desired_rotation_matrix_inv_
The inverse of the desired rotation matrix, precomputed for efficiency. Guaranteed to be valid rotati...
bool enabled() const override
This function returns true if this constraint is configured and able to decide whether states do meet...
Eigen::Matrix3d desired_rotation_matrix_
The desired rotation matrix in the tf frame. Guaranteed to be valid rotation matrix.
const moveit::core::LinkModel * link_model_
The target link model.
double absolute_x_axis_tolerance_
int parameterization_type_
Parameterization type for orientation tolerance.
Class for constraints on the XYZ position of a link.
void print(std::ostream &out=std::cout) const override
Print the constraint data.
bool enabled() const override
This function returns true if this constraint is configured and able to decide whether states do meet...
std::string constraint_frame_id_
The constraint frame id.
void clear() override
Clear the stored constraint.
bool configure(const moveit_msgs::msg::PositionConstraint &pc, const moveit::core::Transforms &tf)
Configure the constraint based on a moveit_msgs::msg::PositionConstraint.
std::vector< bodies::BodyPtr > constraint_region_
The constraint region vector.
ConstraintEvaluationResult decide(const moveit::core::RobotState &state, bool verbose=false) const override
Decide whether the constraint is satisfied in the indicated state.
bool equal(const KinematicConstraint &other, double margin) const override
Check if two constraints are the same. For position constraints this means that:
const moveit::core::LinkModel * link_model_
The link model constraint subject.
bool has_offset_
Whether the offset is substantially different than 0.0.
Eigen::Vector3d offset_
The target offset.
EigenSTL::vector_Isometry3d constraint_region_pose_
The constraint region pose vector. All isometries are guaranteed to be valid.
bool mobile_frame_
Whether or not a mobile frame is employed.
Class for constraints on the visibility relationship between a sensor and a target.
moveit::core::RobotModelConstPtr robot_model_
A copy of the robot model used to create collision environments to check the cone against robot links...
shapes::Mesh * getVisibilityCone(const Eigen::Isometry3d &tform_world_to_sensor, const Eigen::Isometry3d &tform_world_to_target) const
Gets a trimesh shape representing the visibility cone.
Eigen::Isometry3d target_pose_
The target pose transformed into the transform frame.
void clear() override
Clear the stored constraint.
bool equal(const KinematicConstraint &other, double margin) const override
Check if two constraints are the same.
Eigen::Isometry3d sensor_pose_
The sensor pose transformed into the transform frame.
void print(std::ostream &out=std::cout) const override
Print the constraint data.
bool enabled() const override
This function returns true if this constraint is configured and able to decide whether states do meet...
VisibilityConstraint(const moveit::core::RobotModelConstPtr &model)
Constructor.
std::string target_frame_id_
The target frame id.
double max_range_angle_
Storage for the max range angle.
std::string sensor_frame_id_
The sensor frame id.
double max_view_angle_
Storage for the max view angle.
double target_radius_
Storage for the target radius.
ConstraintEvaluationResult decide(const moveit::core::RobotState &state, bool verbose=false) const override
Decide whether the constraint is satisfied in the indicated state.
void getMarkers(const moveit::core::RobotState &state, visualization_msgs::msg::MarkerArray &markers) const
Adds markers associated with the visibility cone, sensor and target to the visualization array.
bool configure(const moveit_msgs::msg::VisibilityConstraint &vc, const moveit::core::Transforms &tf)
Configure the constraint based on a moveit_msgs::msg::VisibilityConstraint.
EigenSTL::vector_Vector3d points_
A set of points along the base of the circle.
int sensor_view_direction_
Storage for the sensor view direction.
unsigned int cone_sides_
Storage for the cone sides
bool decideContact(const collision_detection::Contact &contact) const
Function that gets passed into collision checking to allow some collisions.
const std::vector< std::string > & getLocalVariableNames() const
Get the local names of the variable that make up the joint (suffixes that are attached to joint names...
std::size_t getVariableCount() const
Get the number of variables that describe this joint.
const std::string & getName() const
Get the name of the joint.
const VariableBounds & getVariableBounds(const std::string &variable) const
Get the bounds for a variable. Throw an exception if the variable was not found.
JointType getType() const
Get the type of joint.
const std::string & getName() const
The name of this link.
bool isContinuous() const
Check if this joint wraps around.
Representation of a robot's state. This includes position, velocity, acceleration and effort.
const Eigen::Isometry3d & getGlobalLinkTransform(const std::string &link_name)
Get the link transform w.r.t. the root link (model frame) of the RobotModel. This is typically the ro...
const Eigen::Isometry3d & getFrameTransform(const std::string &frame_id, bool *frame_found=nullptr)
Get the transformation matrix from the model frame (root of model) to the frame identified by frame_i...
double getVariablePosition(const std::string &variable) const
Get the position of a particular variable. An exception is thrown if the variable is not known.
@ ROBOT_LINK
A link on the robot.
@ ROBOT_ATTACHED
A body attached to a robot link.
@ WORLD_OBJECT
A body in the environment.
std::function< bool(collision_detection::Contact &)> DecideContactFn
Signature of predicate that decides whether a contact is allowed or not (when AllowedCollision::Type ...
Vec3fX< details::Vec3Data< double > > Vector3d
Representation and evaluation of kinematic constraints.
std::tuple< Eigen::Matrix< typename Eigen::MatrixBase< Derived >::Scalar, 3, 1 >, bool > calcEulerAngles(const Eigen::MatrixBase< Derived > &R)
rclcpp::Logger get_logger()
geometry_msgs::msg::Pose getPose(const moveit::core::RobotState *self, const std::string &link_name)
Representation of a collision checking request.
bool verbose
Flag indicating whether information about detected collisions should be reported.
bool contacts
If true, compute contacts. Otherwise only a binary collision yes/no is reported.
std::size_t max_contacts
Overall maximum number of contacts to compute.
Representation of a collision checking result.
ContactMap contacts
A map returning the pairs of body ids in contact, plus their contact details.
void print() const
Throttled warning printing the first collision pair, if any. All collisions are logged at DEBUG level...
bool collision
True if collision was found, false otherwise.
Struct for containing the results of constraint evaluation.
bool satisfied
Whether or not the constraint or constraints were satisfied.
double distance
The distance evaluation from the constraint or constraints.