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 };
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())
183 RCLCPP_ERROR(
getLogger(),
"Joint '%s' has no parameters to constrain", jc.joint_name.c_str());
189 "Joint '%s' has more than one parameter to constrain. "
190 "This type of constraint is not supported.",
191 jc.joint_name.c_str());
198 const std::vector<std::string>& local_var_names =
joint_model_->getLocalVariableNames();
199 for (std::size_t i = 0; i < local_var_names.size(); ++i)
252 "Joint %s is constrained to be below the minimum bounds. "
253 "Assuming minimum bounds instead.",
254 jc.joint_name.c_str());
261 "Joint %s is constrained to be above the maximum bounds. "
262 "Assuming maximum bounds instead.",
263 jc.joint_name.c_str());
267 if (jc.weight <= std::numeric_limits<double>::epsilon())
269 RCLCPP_WARN(
getLogger(),
"The weight on constraint for joint '%s' is very near zero. Setting to 1.0.",
270 jc.joint_name.c_str());
310 dif = 2.0 * M_PI - dif;
312 else if (dif < -M_PI)
328 "Constraint %s:: Joint name: '%s', actual value: %f, desired value: %f, "
329 "tolerance_above: %f, tolerance_below: %f",
358 out <<
" tolerance below = ";
360 out <<
" tolerance above = ";
366 out <<
"No constraint" <<
'\n';
378 RCLCPP_WARN(
getLogger(),
"Position constraint link model %s not found in kinematic model. Constraint invalid.",
379 pc.link_name.c_str());
383 if (pc.header.frame_id.empty())
385 RCLCPP_WARN(
getLogger(),
"No frame specified for position constraint on link '%s'!", pc.link_name.c_str());
389 offset_ = Eigen::Vector3d(pc.target_point_offset.x, pc.target_point_offset.y, pc.target_point_offset.z);
404 for (std::size_t i = 0; i < pc.constraint_region.primitives.size(); ++i)
406 std::unique_ptr<shapes::Shape> shape(shapes::constructShapeFromMsg(pc.constraint_region.primitives[i]));
409 if (pc.constraint_region.primitive_poses.size() <= i)
411 RCLCPP_WARN(
getLogger(),
"Constraint region message does not contain enough primitive poses");
415 tf2::fromMsg(pc.constraint_region.primitive_poses[i], t);
421 const bodies::BodyPtr body(bodies::createEmptyBodyFromShapeType(shape->type));
422 body->setDimensionsDirty(shape.get());
424 body->updateInternalData();
429 RCLCPP_WARN(
getLogger(),
"Could not construct primitive shape %zu", i);
434 for (std::size_t i = 0; i < pc.constraint_region.meshes.size(); ++i)
436 std::unique_ptr<shapes::Shape> shape(shapes::constructShapeFromMsg(pc.constraint_region.meshes[i]));
439 if (pc.constraint_region.mesh_poses.size() <= i)
441 RCLCPP_WARN(
getLogger(),
"Constraint region message does not contain enough primitive poses");
445 tf2::fromMsg(pc.constraint_region.mesh_poses[i], t);
450 const bodies::BodyPtr body(bodies::createEmptyBodyFromShapeType(shape->type));
451 body->setDimensionsDirty(shape.get());
453 body->updateInternalData();
458 RCLCPP_WARN(
getLogger(),
"Could not construct mesh shape %zu", i);
462 if (pc.weight <= std::numeric_limits<double>::epsilon())
464 RCLCPP_WARN(
getLogger(),
"The weight on position constraint for link '%s' is near zero. Setting to 1.0.",
465 pc.link_name.c_str());
489 bool some_match =
false;
495 if (diff.translation().norm() < margin && diff.linear().isIdentity(margin) &&
501 other_region_matches_this[j] =
true;
509 if (!other_region_matches_this[i])
519 const Eigen::Vector3d& desired,
520 const std::string& name,
double weight,
521 bool result,
bool verbose)
523 double dx = desired.x() - pt.x();
524 double dy = desired.y() - pt.y();
525 double dz = desired.z() - pt.z();
528 RCLCPP_INFO(
getLogger(),
"Position constraint %s on link '%s'. Desired: %f, %f, %f, current: %f, %f, %f",
529 result ?
"satisfied" :
"violated", name.c_str(), desired.x(), desired.y(), desired.z(), pt.x(), pt.y(),
531 RCLCPP_INFO(
getLogger(),
"Differences %g %g %g", dx, dy, dz);
533 return ConstraintEvaluationResult(result, weight * sqrt(dx * dx + dy * dy + dz * dz));
567 return finishPositionConstraintDecision(pt,
constraint_region_[i]->getPose().translation(),
584 out <<
"Position constraint on link '" <<
link_model_->getName() <<
'\'' <<
'\n';
588 out <<
"No constraint" <<
'\n';
594 offset_ = Eigen::Vector3d(0.0, 0.0, 0.0);
618 RCLCPP_WARN(
getLogger(),
"Could not find link model for link name %s", oc.link_name.c_str());
621 Eigen::Quaterniond q;
622 tf2::fromMsg(oc.orientation, q);
623 if (fabs(q.norm() - 1.0) > 1e-3)
626 "Orientation constraint for link '%s' is probably incorrect: %f, %f, %f, "
627 "%f. Assuming identity instead.",
628 oc.link_name.c_str(), oc.orientation.x, oc.orientation.y, oc.orientation.z, oc.orientation.w);
629 q = Eigen::Quaterniond(1.0, 0.0, 0.0, 0.0);
632 if (oc.header.frame_id.empty())
633 RCLCPP_WARN(
getLogger(),
"No frame specified for position constraint on link '%s'!", oc.link_name.c_str());
650 std::stringstream matrix_str;
652 RCLCPP_DEBUG(
getLogger(),
"The desired rotation matrix for link '%s' in frame %s is:\n%s", oc.link_name.c_str(),
655 if (oc.weight <= std::numeric_limits<double>::epsilon())
657 RCLCPP_WARN(
getLogger(),
"The weight on orientation constraint for link '%s' is near zero. Setting to 1.0.",
658 oc.link_name.c_str());
672 "Unknown parameterization for orientation constraint tolerance, using default (XYZ_EULER_ANGLES).");
678 RCLCPP_WARN(
getLogger(),
"Near-zero value for absolute_x_axis_tolerance");
681 RCLCPP_WARN(
getLogger(),
"Near-zero value for absolute_y_axis_tolerance");
684 RCLCPP_WARN(
getLogger(),
"Near-zero value for absolute_z_axis_tolerance");
727 Eigen::Isometry3d diff;
742 std::tuple<Eigen::Vector3d, bool> euler_angles_error;
743 Eigen::Vector3d xyz_rotation;
753 xyz_rotation = std::get<Eigen::Vector3d>(euler_angles_error);
754 if (!std::get<bool>(euler_angles_error))
758 xyz_rotation(2) = xyz_rotation(0);
763 xyz_rotation = xyz_rotation.unaryExpr(&normalizeAbsoluteAngle);
767 Eigen::AngleAxisd aa(diff.linear());
774 RCLCPP_ERROR(
getLogger(),
"The parameterization type for the orientation constraints is invalid.");
786 "Orientation constraint %s for link '%s'. Quaternion desired: %f %f %f %f, quaternion "
787 "actual: %f %f %f %f, error: x=%f, y=%f, z=%f, tolerance: x=%f, y=%f, z=%f",
788 result ?
"satisfied" :
"violated",
link_model_->getName().c_str(), q_des.x(), q_des.y(), q_des.z(),
789 q_des.w(), q_act.x(), q_act.y(), q_act.z(), q_act.w(), xyz_rotation(0), xyz_rotation(1),
800 out <<
"Orientation constraint on link '" <<
link_model_->getName() <<
'\'' <<
'\n';
802 out <<
"Desired orientation:" << q_des.x() <<
',' << q_des.y() <<
',' << q_des.z() <<
',' << q_des.w() <<
'\n';
806 out <<
"No constraint" <<
'\n';
836 if (vc.target_radius <= std::numeric_limits<double>::epsilon())
837 RCLCPP_WARN(
getLogger(),
"The radius of the target disc that must be visible should be strictly positive");
839 if (vc.cone_sides < 3)
842 "The number of sides for the visibility region must be 3 or more. "
843 "Assuming 3 sides instead of the specified %d",
854 double delta = 2.0 * M_PI /
static_cast<double>(
cone_sides_);
856 for (
unsigned int i = 0; i <
cone_sides_; ++i, a += delta)
860 points_.push_back(Eigen::Vector3d(x, y, 0.0));
889 if (vc.weight <= std::numeric_limits<double>::epsilon())
891 RCLCPP_WARN(
getLogger(),
"The weight of visibility constraint is near zero. Setting to 1.0.");
920 if (diff.translation().norm() > margin)
922 if (!diff.linear().isIdentity(margin))
926 if (diff.translation().norm() > margin)
928 if (!diff.linear().isIdentity(margin))
937 return (
target_radius_ > std::numeric_limits<double>::epsilon()) ||
943 const Eigen::Isometry3d& tform_world_to_target)
const
946 const Eigen::Isometry3d& sp = tform_world_to_sensor;
949 const Eigen::Isometry3d& tp = tform_world_to_target;
952 const EigenSTL::vector_Vector3d* points = &
points_;
953 std::unique_ptr<EigenSTL::vector_Vector3d> temp_points;
955 temp_points = std::make_unique<EigenSTL::vector_Vector3d>(
points_.size());
956 for (std::size_t i = 0; i <
points_.size(); ++i)
958 temp_points->at(i) = tp *
points_[i];
960 points = temp_points.get();
963 shapes::Mesh* m =
new shapes::Mesh();
965 m->vertices =
new double[m->vertex_count * 3];
967 m->triangles =
new unsigned int[m->triangle_count * 3];
971 m->vertices[0] = sp.translation().x();
972 m->vertices[1] = sp.translation().y();
973 m->vertices[2] = sp.translation().z();
976 m->vertices[3] = tp.translation().x();
977 m->vertices[4] = tp.translation().y();
978 m->vertices[5] = tp.translation().z();
981 for (std::size_t i = 0; i < points->size(); ++i)
983 m->vertices[i * 3 + 6] = points->at(i).x();
984 m->vertices[i * 3 + 7] = points->at(i).y();
985 m->vertices[i * 3 + 8] = points->at(i).z();
989 std::size_t p3 = points->size() * 3;
990 for (std::size_t i = 1; i < points->size(); ++i)
993 std::size_t i3 = (i - 1) * 3;
994 m->triangles[i3] = i + 1;
995 m->triangles[i3 + 1] = 0;
996 m->triangles[i3 + 2] = i + 2;
998 std::size_t i6 = p3 + i3;
999 m->triangles[i6] = i + 1;
1000 m->triangles[i6 + 1] = 1;
1001 m->triangles[i6 + 2] = i + 2;
1005 m->triangles[p3 - 3] = points->size() + 1;
1006 m->triangles[p3 - 2] = 0;
1007 m->triangles[p3 - 1] = 2;
1009 m->triangles[p3 - 3] = points->size() + 1;
1010 m->triangles[p3 - 2] = 1;
1011 m->triangles[p3 - 1] = 2;
1017 visualization_msgs::msg::MarkerArray& markers)
const
1026 visualization_msgs::msg::Marker mk;
1027 shapes::constructMarkerFromShape(m, mk);
1030 mk.header.stamp = rclcpp::Clock().now();
1031 mk.ns =
"constraints";
1033 mk.action = visualization_msgs::msg::Marker::ADD;
1034 mk.pose.position.x = 0;
1035 mk.pose.position.y = 0;
1036 mk.pose.position.z = 0;
1037 mk.pose.orientation.x = 0;
1038 mk.pose.orientation.y = 0;
1039 mk.pose.orientation.z = 0;
1040 mk.pose.orientation.w = 1;
1041 mk.lifetime = rclcpp::Duration::from_seconds(60);
1049 markers.markers.push_back(mk);
1051 visualization_msgs::msg::Marker mka;
1052 mka.type = visualization_msgs::msg::Marker::ARROW;
1053 mka.action = visualization_msgs::msg::Marker::ADD;
1054 mka.color = mk.color;
1057 mka.header = mk.header;
1060 mka.lifetime = mk.lifetime;
1064 mka.points.resize(2);
1065 Eigen::Vector3d d = tp.translation() + tp.linear().col(2) * 0.5;
1066 mka.points[0].x = tp.translation().x();
1067 mka.points[0].y = tp.translation().y();
1068 mka.points[0].z = tp.translation().z();
1069 mka.points[1].x = d.x();
1070 mka.points[1].y = d.y();
1071 mka.points[1].z = d.z();
1072 markers.markers.push_back(mka);
1079 mka.points[0].x = sp.translation().x();
1080 mka.points[0].y = sp.translation().y();
1081 mka.points[0].z = sp.translation().z();
1082 mka.points[1].x = d.x();
1083 mka.points[1].y = d.y();
1084 mka.points[1].z = d.z();
1086 markers.markers.push_back(mka);
1098 const Eigen::Vector3d& sensor_view_axis = tform_world_to_sensor.linear().col(2 -
sensor_view_direction_);
1103 const Eigen::Vector3d& normal1 = tform_world_to_target.linear().col(2) * -1.0;
1104 double dp = sensor_view_axis.dot(normal1);
1105 double ang = acos(dp);
1110 RCLCPP_INFO(
getLogger(),
"Visibility constraint is violated because the sensor is looking at "
1120 "Visibility constraint is violated because the view angle is %lf "
1121 "(above the maximum allowed of %lf)",
1131 const Eigen::Vector3d& dir =
1132 (tform_world_to_target.translation() - tform_world_to_sensor.translation()).normalized();
1133 double dp = sensor_view_axis.dot(dir);
1138 RCLCPP_INFO(
getLogger(),
"Visibility constraint is violated because the sensor is looking at "
1144 double ang = acos(dp);
1150 "Visibility constraint is violated because the range angle is %lf "
1151 "(above the maximum allowed of %lf)",
1161 shapes::Mesh* m =
getVisibilityCone(tform_world_to_sensor, tform_world_to_target);
1165 "Visibility constraint is violated because we could not create the visibility cone mesh.");
1170 const auto collision_env_local = std::make_shared<collision_detection::CollisionEnvFCL>(
robot_model_);
1171 collision_env_local->getWorld()->addToObject(
"cone", shapes::ShapeConstPtr(m), Eigen::Isometry3d::Identity());
1186 collision_env_local->checkRobotCollision(req, res, state, acm);
1190 std::stringstream ss;
1192 RCLCPP_INFO(
getLogger(),
"Visibility constraint %ssatisfied. Visibility cone approximation:\n %s",
1193 res.
collision ?
"not " :
"", ss.str().c_str());
1196 collision_env_local->getWorld()->removeObject(
"cone");
1215 RCLCPP_DEBUG(
getLogger(),
"Accepted collision with either sensor or target");
1223 RCLCPP_DEBUG(
getLogger(),
"Accepted collision with either sensor or target");
1233 out <<
"Visibility constraint for sensor in frame '" <<
sensor_frame_id_ <<
"' using target in frame '"
1239 out <<
"No constraint" <<
'\n';
1256 for (
const moveit_msgs::msg::JointConstraint& joint_constraint : jc)
1259 bool u = ev->
configure(joint_constraint);
1260 result = result && u;
1272 for (
const moveit_msgs::msg::PositionConstraint& position_constraint : pc)
1275 bool u = ev->
configure(position_constraint, tf);
1276 result = result && u;
1288 for (
const moveit_msgs::msg::OrientationConstraint& orientation_constraint : oc)
1291 bool u = ev->
configure(orientation_constraint, tf);
1292 result = result && u;
1295 all_constraints_.orientation_constraints.push_back(orientation_constraint);
1304 for (
const moveit_msgs::msg::VisibilityConstraint& visibility_constraint : vc)
1307 bool u = ev->
configure(visibility_constraint, tf);
1308 result = result && u;
1318 bool j =
add(c.joint_constraints);
1319 bool p =
add(c.position_constraints, tf);
1320 bool o =
add(c.orientation_constraints, tf);
1321 bool v =
add(c.visibility_constraints, tf);
1322 return j && p && o && v;
1339 std::vector<ConstraintEvaluationResult>& results,
1348 result.
distance += results[i].distance;
1358 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_
JointConstraint(const moveit::core::RobotModelConstPtr &model)
Constructor.
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.
KinematicConstraintSet(const moveit::core::RobotModelConstPtr &model)
Constructor.
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.
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.
OrientationConstraint(const moveit::core::RobotModelConstPtr &model)
Constructor.
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.
PositionConstraint(const moveit::core::RobotModelConstPtr &model)
Constructor.
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.
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.
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.
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.
rclcpp::Logger getLogger()