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>
54#include <rclcpp/clock.hpp>
55#include <rclcpp/duration.hpp>
67static double normalizeAngle(
double angle)
69 double v = fmod(angle, 2.0 * M_PI);
83static double normalizeAbsoluteAngle(
const double angle)
85 const double normalized_angle = std::fmod(std::abs(angle), 2 * M_PI);
86 return std::min(2 * M_PI - normalized_angle, normalized_angle);
96template <
typename Derived>
97std::tuple<Eigen::Matrix<typename Eigen::MatrixBase<Derived>::Scalar, 3, 1>,
bool>
102 EIGEN_STATIC_ASSERT_MATRIX_SPECIFIC_SIZE(Derived, 3, 3)
103 using Index = EIGEN_DEFAULT_DENSE_INDEX_TYPE;
104 using Scalar =
typename Eigen::MatrixBase<Derived>::Scalar;
108 Eigen::Matrix<Scalar, 3, 1> res;
109 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);
110 res[1] = atan2(R(i, k), rsum);
112 if (rsum > 4 * Eigen::NumTraits<Scalar>::epsilon())
114 res[0] = atan2(-R(j, k), R(k, k));
115 res[2] = atan2(-R(i, j), R(i, i));
116 return { res,
true };
118 else if (R(i, k) > 0)
120 const Scalar spos = R(j, i) + R(k, j);
121 const Scalar cpos = R(j, j) - R(k, i);
122 res[0] = atan2(spos, cpos);
124 return { res,
false };
126 const Scalar sneg = R(k, j) - R(j, i);
127 const Scalar cneg = R(j, j) + R(k, i);
128 res[0] = atan2(sneg, cneg);
130 return { res,
false };
134 : type_(UNKNOWN_CONSTRAINT), robot_model_(model), constraint_weight_(std::numeric_limits<double>::epsilon())
146 if (jc.tolerance_above < 0.0 || jc.tolerance_below < 0.0)
148 RCLCPP_WARN(getLogger(),
"JointConstraint tolerance values must be positive.");
161 std::size_t pos = jc.joint_name.find_last_of(
'/');
162 if (pos != std::string::npos)
165 if (pos + 1 < jc.joint_name.length())
179 RCLCPP_ERROR(getLogger(),
"Joint '%s' has no parameters to constrain", jc.joint_name.c_str());
184 RCLCPP_ERROR(getLogger(),
185 "Joint '%s' has more than one parameter to constrain. "
186 "This type of constraint is not supported.",
187 jc.joint_name.c_str());
195 for (std::size_t i = 0; i < local_var_names.size(); ++i)
205 RCLCPP_ERROR(getLogger(),
"Local variable name '%s' is not known to joint '%s'",
local_variable_name_.c_str(),
247 RCLCPP_WARN(getLogger(),
248 "Joint %s is constrained to be below the minimum bounds. "
249 "Assuming minimum bounds instead.",
250 jc.joint_name.c_str());
256 RCLCPP_WARN(getLogger(),
257 "Joint %s is constrained to be above the maximum bounds. "
258 "Assuming maximum bounds instead.",
259 jc.joint_name.c_str());
263 if (jc.weight <= std::numeric_limits<double>::epsilon())
265 RCLCPP_WARN(getLogger(),
"The weight on constraint for joint '%s' is very near zero. Setting to 1.0.",
266 jc.joint_name.c_str());
304 dif = 2.0 * M_PI - dif;
306 else if (dif < -M_PI)
319 RCLCPP_INFO(getLogger(),
320 "Constraint %s:: Joint name: '%s', actual value: %f, desired value: %f, "
321 "tolerance_above: %f, tolerance_below: %f",
350 out <<
" tolerance below = ";
352 out <<
" tolerance above = ";
357 out <<
"No constraint" <<
'\n';
368 RCLCPP_WARN(getLogger(),
"Position constraint link model %s not found in kinematic model. Constraint invalid.",
369 pc.link_name.c_str());
373 if (pc.header.frame_id.empty())
375 RCLCPP_WARN(getLogger(),
"No frame specified for position constraint on link '%s'!", pc.link_name.c_str());
379 offset_ = Eigen::Vector3d(pc.target_point_offset.x, pc.target_point_offset.y, pc.target_point_offset.z);
394 for (std::size_t i = 0; i < pc.constraint_region.primitives.size(); ++i)
396 std::unique_ptr<shapes::Shape> shape(shapes::constructShapeFromMsg(pc.constraint_region.primitives[i]));
399 if (pc.constraint_region.primitive_poses.size() <= i)
401 RCLCPP_WARN(getLogger(),
"Constraint region message does not contain enough primitive poses");
405 tf2::fromMsg(pc.constraint_region.primitive_poses[i], t);
411 const bodies::BodyPtr body(bodies::createEmptyBodyFromShapeType(shape->type));
412 body->setDimensionsDirty(shape.get());
414 body->updateInternalData();
418 RCLCPP_WARN(getLogger(),
"Could not construct primitive shape %zu", i);
422 for (std::size_t i = 0; i < pc.constraint_region.meshes.size(); ++i)
424 std::unique_ptr<shapes::Shape> shape(shapes::constructShapeFromMsg(pc.constraint_region.meshes[i]));
427 if (pc.constraint_region.mesh_poses.size() <= i)
429 RCLCPP_WARN(getLogger(),
"Constraint region message does not contain enough primitive poses");
433 tf2::fromMsg(pc.constraint_region.mesh_poses[i], t);
438 const bodies::BodyPtr body(bodies::createEmptyBodyFromShapeType(shape->type));
439 body->setDimensionsDirty(shape.get());
441 body->updateInternalData();
446 RCLCPP_WARN(getLogger(),
"Could not construct mesh shape %zu", i);
450 if (pc.weight <= std::numeric_limits<double>::epsilon())
452 RCLCPP_WARN(getLogger(),
"The weight on position constraint for link '%s' is near zero. Setting to 1.0.",
453 pc.link_name.c_str());
475 bool some_match =
false;
481 if (diff.translation().norm() < margin && diff.linear().isIdentity(margin) &&
487 other_region_matches_this[j] =
true;
495 if (!other_region_matches_this[i])
505 const Eigen::Vector3d& desired,
506 const std::string& name,
double weight,
507 bool result,
bool verbose)
509 double dx = desired.x() - pt.x();
510 double dy = desired.y() - pt.y();
511 double dz = desired.z() - pt.z();
514 RCLCPP_INFO(getLogger(),
"Position constraint %s on link '%s'. Desired: %f, %f, %f, current: %f, %f, %f",
515 result ?
"satisfied" :
"violated", name.c_str(), desired.x(), desired.y(), desired.z(), pt.x(), pt.y(),
517 RCLCPP_INFO(getLogger(),
"Differences %g %g %g", dx, dy, dz);
519 return ConstraintEvaluationResult(result, weight * sqrt(dx * dx + dy * dy + dz * dz));
553 return finishPositionConstraintDecision(pt,
constraint_region_[i]->getPose().translation(),
574 out <<
"No constraint" <<
'\n';
580 offset_ = Eigen::Vector3d(0.0, 0.0, 0.0);
604 RCLCPP_WARN(getLogger(),
"Could not find link model for link name %s", oc.link_name.c_str());
607 Eigen::Quaterniond q;
608 tf2::fromMsg(oc.orientation, q);
609 if (fabs(q.norm() - 1.0) > 1e-3)
611 RCLCPP_WARN(getLogger(),
612 "Orientation constraint for link '%s' is probably incorrect: %f, %f, %f, "
613 "%f. Assuming identity instead.",
614 oc.link_name.c_str(), oc.orientation.x, oc.orientation.y, oc.orientation.z, oc.orientation.w);
615 q = Eigen::Quaterniond(1.0, 0.0, 0.0, 0.0);
618 if (oc.header.frame_id.empty())
619 RCLCPP_WARN(getLogger(),
"No frame specified for position constraint on link '%s'!", oc.link_name.c_str());
636 std::stringstream matrix_str;
638 RCLCPP_DEBUG(getLogger(),
"The desired rotation matrix for link '%s' in frame %s is:\n%s", oc.link_name.c_str(),
641 if (oc.weight <= std::numeric_limits<double>::epsilon())
643 RCLCPP_WARN(getLogger(),
"The weight on orientation constraint for link '%s' is near zero. Setting to 1.0.",
644 oc.link_name.c_str());
657 RCLCPP_WARN(getLogger(),
658 "Unknown parameterization for orientation constraint tolerance, using default (XYZ_EULER_ANGLES).");
664 RCLCPP_WARN(getLogger(),
"Near-zero value for absolute_x_axis_tolerance");
667 RCLCPP_WARN(getLogger(),
"Near-zero value for absolute_y_axis_tolerance");
670 RCLCPP_WARN(getLogger(),
"Near-zero value for absolute_z_axis_tolerance");
713 Eigen::Isometry3d diff;
728 std::tuple<Eigen::Vector3d, bool> euler_angles_error;
729 Eigen::Vector3d xyz_rotation;
739 xyz_rotation = std::get<Eigen::Vector3d>(euler_angles_error);
740 if (!std::get<bool>(euler_angles_error))
744 xyz_rotation(2) = xyz_rotation(0);
749 xyz_rotation = xyz_rotation.unaryExpr(&normalizeAbsoluteAngle);
753 Eigen::AngleAxisd aa(diff.linear());
760 RCLCPP_ERROR(getLogger(),
"The parameterization type for the orientation constraints is invalid.");
771 RCLCPP_INFO(getLogger(),
772 "Orientation constraint %s for link '%s'. Quaternion desired: %f %f %f %f, quaternion "
773 "actual: %f %f %f %f, error: x=%f, y=%f, z=%f, tolerance: x=%f, y=%f, z=%f",
774 result ?
"satisfied" :
"violated",
link_model_->
getName().c_str(), q_des.x(), q_des.y(), q_des.z(),
775 q_des.w(), q_act.x(), q_act.y(), q_act.z(), q_act.w(), xyz_rotation(0), xyz_rotation(1),
788 out <<
"Desired orientation:" << q_des.x() <<
',' << q_des.y() <<
',' << q_des.z() <<
',' << q_des.w() <<
'\n';
791 out <<
"No constraint" <<
'\n';
820 if (vc.target_radius <= std::numeric_limits<double>::epsilon())
821 RCLCPP_WARN(getLogger(),
"The radius of the target disc that must be visible should be strictly positive");
823 if (vc.cone_sides < 3)
825 RCLCPP_WARN(getLogger(),
826 "The number of sides for the visibility region must be 3 or more. "
827 "Assuming 3 sides instead of the specified %d",
836 double delta = 2.0 * M_PI /
static_cast<double>(
cone_sides_);
838 for (
unsigned int i = 0; i <
cone_sides_; ++i, a += delta)
842 points_.push_back(Eigen::Vector3d(x, y, 0.0));
871 if (vc.weight <= std::numeric_limits<double>::epsilon())
873 RCLCPP_WARN(getLogger(),
"The weight of visibility constraint is near zero. Setting to 1.0.");
900 if (diff.translation().norm() > margin)
902 if (!diff.linear().isIdentity(margin))
906 if (diff.translation().norm() > margin)
908 if (!diff.linear().isIdentity(margin))
917 return (
target_radius_ > std::numeric_limits<double>::epsilon()) ||
923 const Eigen::Isometry3d& tform_world_to_target)
const
926 const Eigen::Isometry3d& sp = tform_world_to_sensor;
929 const Eigen::Isometry3d& tp = tform_world_to_target;
932 const EigenSTL::vector_Vector3d* points = &
points_;
933 std::unique_ptr<EigenSTL::vector_Vector3d> temp_points;
935 temp_points = std::make_unique<EigenSTL::vector_Vector3d>(
points_.size());
936 for (std::size_t i = 0; i <
points_.size(); ++i)
938 temp_points->at(i) = tp *
points_[i];
940 points = temp_points.get();
943 shapes::Mesh* m =
new shapes::Mesh();
945 m->vertices =
new double[m->vertex_count * 3];
947 m->triangles =
new unsigned int[m->triangle_count * 3];
951 m->vertices[0] = sp.translation().x();
952 m->vertices[1] = sp.translation().y();
953 m->vertices[2] = sp.translation().z();
956 m->vertices[3] = tp.translation().x();
957 m->vertices[4] = tp.translation().y();
958 m->vertices[5] = tp.translation().z();
961 for (std::size_t i = 0; i < points->size(); ++i)
963 m->vertices[i * 3 + 6] = points->at(i).x();
964 m->vertices[i * 3 + 7] = points->at(i).y();
965 m->vertices[i * 3 + 8] = points->at(i).z();
969 std::size_t p3 = points->size() * 3;
970 for (std::size_t i = 1; i < points->size(); ++i)
973 std::size_t i3 = (i - 1) * 3;
974 m->triangles[i3] = i + 1;
975 m->triangles[i3 + 1] = 0;
976 m->triangles[i3 + 2] = i + 2;
978 std::size_t i6 = p3 + i3;
979 m->triangles[i6] = i + 1;
980 m->triangles[i6 + 1] = 1;
981 m->triangles[i6 + 2] = i + 2;
985 m->triangles[p3 - 3] = points->size() + 1;
986 m->triangles[p3 - 2] = 0;
987 m->triangles[p3 - 1] = 2;
989 m->triangles[p3 - 3] = points->size() + 1;
990 m->triangles[p3 - 2] = 1;
991 m->triangles[p3 - 1] = 2;
997 visualization_msgs::msg::MarkerArray& markers)
const
1006 visualization_msgs::msg::Marker mk;
1007 shapes::constructMarkerFromShape(m, mk);
1010 mk.header.stamp = rclcpp::Clock().now();
1011 mk.ns =
"constraints";
1013 mk.action = visualization_msgs::msg::Marker::ADD;
1014 mk.pose.position.x = 0;
1015 mk.pose.position.y = 0;
1016 mk.pose.position.z = 0;
1017 mk.pose.orientation.x = 0;
1018 mk.pose.orientation.y = 0;
1019 mk.pose.orientation.z = 0;
1020 mk.pose.orientation.w = 1;
1021 mk.lifetime = rclcpp::Duration::from_seconds(60);
1029 markers.markers.push_back(mk);
1031 visualization_msgs::msg::Marker mka;
1032 mka.type = visualization_msgs::msg::Marker::ARROW;
1033 mka.action = visualization_msgs::msg::Marker::ADD;
1034 mka.color = mk.color;
1037 mka.header = mk.header;
1040 mka.lifetime = mk.lifetime;
1044 mka.points.resize(2);
1045 Eigen::Vector3d d = tp.translation() + tp.linear().col(2) * 0.5;
1046 mka.points[0].x = tp.translation().x();
1047 mka.points[0].y = tp.translation().y();
1048 mka.points[0].z = tp.translation().z();
1049 mka.points[1].x = d.x();
1050 mka.points[1].y = d.y();
1051 mka.points[1].z = d.z();
1052 markers.markers.push_back(mka);
1059 mka.points[0].x = sp.translation().x();
1060 mka.points[0].y = sp.translation().y();
1061 mka.points[0].z = sp.translation().z();
1062 mka.points[1].x = d.x();
1063 mka.points[1].y = d.y();
1064 mka.points[1].z = d.z();
1066 markers.markers.push_back(mka);
1078 const Eigen::Vector3d& sensor_view_axis = tform_world_to_sensor.linear().col(2 -
sensor_view_direction_);
1083 const Eigen::Vector3d& normal1 = tform_world_to_target.linear().col(2) * -1.0;
1084 double dp = sensor_view_axis.dot(normal1);
1085 double ang = acos(dp);
1090 RCLCPP_INFO(getLogger(),
"Visibility constraint is violated because the sensor is looking at "
1099 RCLCPP_INFO(getLogger(),
1100 "Visibility constraint is violated because the view angle is %lf "
1101 "(above the maximum allowed of %lf)",
1111 const Eigen::Vector3d& dir =
1112 (tform_world_to_target.translation() - tform_world_to_sensor.translation()).normalized();
1113 double dp = sensor_view_axis.dot(dir);
1118 RCLCPP_INFO(getLogger(),
"Visibility constraint is violated because the sensor is looking at "
1124 double ang = acos(dp);
1129 RCLCPP_INFO(getLogger(),
1130 "Visibility constraint is violated because the range angle is %lf "
1131 "(above the maximum allowed of %lf)",
1141 shapes::Mesh* m =
getVisibilityCone(tform_world_to_sensor, tform_world_to_target);
1144 RCLCPP_ERROR(getLogger(),
1145 "Visibility constraint is violated because we could not create the visibility cone mesh.");
1150 const auto collision_env_local = std::make_shared<collision_detection::CollisionEnvFCL>(
robot_model_);
1151 collision_env_local->getWorld()->addToObject(
"cone", shapes::ShapeConstPtr(m), Eigen::Isometry3d::Identity());
1166 collision_env_local->checkRobotCollision(req, res, state, acm);
1170 std::stringstream ss;
1172 RCLCPP_INFO(getLogger(),
"Visibility constraint %ssatisfied. Visibility cone approximation:\n %s",
1173 res.
collision ?
"not " :
"", ss.str().c_str());
1176 collision_env_local->getWorld()->removeObject(
"cone");
1195 RCLCPP_DEBUG(getLogger(),
"Accepted collision with either sensor or target");
1203 RCLCPP_DEBUG(getLogger(),
"Accepted collision with either sensor or target");
1213 out <<
"Visibility constraint for sensor in frame '" <<
sensor_frame_id_ <<
"' using target in frame '"
1218 out <<
"No constraint" <<
'\n';
1234 for (
const moveit_msgs::msg::JointConstraint& joint_constraint : jc)
1237 bool u = ev->
configure(joint_constraint);
1238 result = result && u;
1250 for (
const moveit_msgs::msg::PositionConstraint& position_constraint : pc)
1253 bool u = ev->
configure(position_constraint, tf);
1254 result = result && u;
1266 for (
const moveit_msgs::msg::OrientationConstraint& orientation_constraint : oc)
1269 bool u = ev->
configure(orientation_constraint, tf);
1270 result = result && u;
1273 all_constraints_.orientation_constraints.push_back(orientation_constraint);
1282 for (
const moveit_msgs::msg::VisibilityConstraint& visibility_constraint : vc)
1285 bool u = ev->
configure(visibility_constraint, tf);
1286 result = result && u;
1296 bool j =
add(c.joint_constraints);
1297 bool p =
add(c.position_constraints, tf);
1298 bool o =
add(c.orientation_constraints, tf);
1299 bool v =
add(c.visibility_constraints, tf);
1300 return j && p && o && v;
1317 std::vector<ConstraintEvaluationResult>& results,
1326 result.
distance += results[i].distance;
1336 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.
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_
Eigen::Matrix3d desired_R_in_frame_id_
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_
Eigen::Matrix3d desired_rotation_matrix_inv_
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_
const moveit::core::LinkModel * link_model_
double absolute_x_axis_tolerance_
int parameterization_type_
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 & 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.
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...
@ ROBOT_LINK
A link on the robot.
@ ROBOT_ATTACHED
A body attached to a robot link.
@ WORLD_OBJECT
A body in the environment.
rclcpp::Logger getLogger()
std::function< bool(collision_detection::Contact &)> DecideContactFn
Signature of predicate that decides whether a contact is allowed or not (when AllowedCollision::Type ...
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 getLogger(const std::string &name)
Creates a namespaced logger.
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.
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.