Go to the documentation of this file.
44 #include <Eigen/StdVector>
45 #include <Eigen/Geometry>
49 #include <boost/shared_ptr.hpp>
50 #include <boost/pointer_cast.hpp>
52 #include <geometry_msgs/Polygon.h>
53 #include <geometry_msgs/TwistWithCovariance.h>
54 #include <geometry_msgs/QuaternionStamped.h>
93 virtual const Eigen::Vector2d&
getCentroid()
const = 0;
113 virtual bool checkCollision(
const Eigen::Vector2d& position,
double min_dist)
const = 0;
151 virtual Eigen::Vector2d
getClosestPoint(
const Eigen::Vector2d& position)
const = 0;
215 const geometry_msgs::Quaternion& orientation)
219 vel.coeffRef(0) = velocity.twist.linear.x;
220 vel.coeffRef(1) = velocity.twist.linear.y;
224 if (vel.norm() < 0.001)
236 const geometry_msgs::QuaternionStamped& orientation)
262 virtual void toPolygonMsg(geometry_msgs::Polygon& polygon) = 0;
273 twistWithCovariance.twist.linear.x = 0;
274 twistWithCovariance.twist.linear.y = 0;
288 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
347 double t = a.dot(b)/a.dot(a);
360 return (position-
pos_).norm();
376 virtual Eigen::Vector2d
getClosestPoint(
const Eigen::Vector2d& position)
const
414 return std::complex<double>(
pos_[0],
pos_[1]);
418 const Eigen::Vector2d& position()
const {
return pos_;}
419 Eigen::Vector2d& position() {
return pos_;}
420 double& x() {
return pos_.coeffRef(0);}
421 const double& x()
const {
return pos_.coeffRef(0);}
422 double& y() {
return pos_.coeffRef(1);}
423 const double& y()
const {
return pos_.coeffRef(1);}
426 virtual void toPolygonMsg(geometry_msgs::Polygon& polygon)
428 polygon.points.resize(1);
429 polygon.points.front().x =
pos_.x();
430 polygon.points.front().y =
pos_.y();
431 polygon.points.front().z = 0;
440 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
491 double t = a.dot(b)/a.dot(a);
520 virtual Eigen::Vector2d
getClosestPoint(
const Eigen::Vector2d& position)
const
558 return std::complex<double>(
pos_[0],
pos_[1]);
562 const Eigen::Vector2d& position()
const {
return pos_;}
563 Eigen::Vector2d& position() {
return pos_;}
564 double& x() {
return pos_.coeffRef(0);}
565 const double& x()
const {
return pos_.coeffRef(0);}
566 double& y() {
return pos_.coeffRef(1);}
567 const double& y()
const {
return pos_.coeffRef(1);}
569 const double& radius()
const {
return radius_;}
572 virtual void toPolygonMsg(geometry_msgs::Polygon& polygon)
576 polygon.points.resize(1);
577 polygon.points.front().x =
pos_.x();
578 polygon.points.front().y =
pos_.y();
579 polygon.points.front().z = 0;
584 Eigen::Vector2d
pos_;
589 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
601 typedef std::vector<Eigen::Vector2d,Eigen::aligned_allocator<Eigen::Vector2d> >
VertexContainer;
671 virtual Eigen::Vector2d
getClosestPoint(
const Eigen::Vector2d& position)
const
710 const Eigen::Vector2d&
start()
const {
return start_;}
712 const Eigen::Vector2d&
end()
const {
return end_;}
716 virtual void toPolygonMsg(geometry_msgs::Polygon& polygon)
718 polygon.points.resize(2);
719 polygon.points.front().x =
start_.x();
722 polygon.points.back().x =
end_.x();
723 polygon.points.back().y =
end_.y();
724 polygon.points.back().z = polygon.points.front().z = 0;
732 Eigen::Vector2d
end_;
737 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
818 virtual Eigen::Vector2d
getClosestPoint(
const Eigen::Vector2d& position)
const
821 return closed_point_line +
radius_*(position-closed_point_line).normalized();
858 const Eigen::Vector2d&
start()
const {
return start_;}
860 const Eigen::Vector2d&
end()
const {
return end_;}
864 virtual void toPolygonMsg(geometry_msgs::Polygon& polygon)
868 polygon.points.resize(2);
869 polygon.points.front().x =
start_.x();
870 polygon.points.front().y =
start_.y();
872 polygon.points.back().x =
end_.x();
873 polygon.points.back().y =
end_.y();
874 polygon.points.back().z = polygon.points.front().z = 0;
888 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
948 if (c>0)
return true;
986 virtual Eigen::Vector2d
getClosestPoint(
const Eigen::Vector2d& position)
const;
1017 for (std::size_t i = 0; i <
vertices_.size(); i++)
1019 pred_vertices[i] =
vertices_[i] + offset;
1024 virtual const Eigen::Vector2d&
getCentroid()
const
1026 assert(
finalized_ &&
"Finalize the polygon after all vertices are added.");
1033 assert(
finalized_ &&
"Finalize the polygon after all vertices are added.");
1038 virtual void toPolygonMsg(geometry_msgs::Polygon& polygon);
1054 void pushBackVertex(
const Eigen::Ref<const Eigen::Vector2d>& vertex)
1069 vertices_.push_back(Eigen::Vector2d(x,y));
1110 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
Eigen::Vector2d centroid_velocity_
Store the corresponding velocity (vx, vy) of the centroid (zero, if _dynamic is true)
int noVertices() const
Get the number of vertices defining the polygon (the first vertex is counted once)
virtual std::complex< double > getCentroidCplx() const
Get centroid coordinates of the obstacle as complex number.
void setStart(const Eigen::Ref< const Eigen::Vector2d > &start)
virtual std::complex< double > getCentroidCplx() const
Get centroid coordinates of the obstacle as complex number.
virtual double getMinimumDistance(const Eigen::Vector2d &position) const
Get the minimum euclidean distance to the obstacle (point as reference)
CircularObstacle()
Default constructor of the circular obstacle class.
virtual void predictCentroidConstantVelocity(double t, Eigen::Ref< Eigen::Vector2d > position) const
Predict position of the centroid assuming a constant velocity model.
virtual double getMinimumDistance(const Eigen::Vector2d &position) const
Get the minimum euclidean distance to the obstacle (point as reference)
void setEnd(const Eigen::Ref< const Eigen::Vector2d > &end)
bool isDynamic() const
Check if the obstacle is a moving with a (non-zero) velocity.
virtual double getMinimumDistance(const Eigen::Vector2d &position) const =0
Get the minimum euclidean distance to the obstacle (point as reference)
virtual const Eigen::Vector2d & getCentroid() const
Get centroid coordinates of the obstacle.
virtual void predictCentroidConstantVelocity(double t, Eigen::Ref< Eigen::Vector2d > position) const
Predict position of the centroid assuming a constant velocity model.
virtual Eigen::Vector2d getClosestPoint(const Eigen::Vector2d &position) const
Get the closest point on the boundary of the obstacle w.r.t. a specified reference position.
virtual void predictVertices(double t, Point2dContainer &pred_vertices) const
virtual bool checkCollision(const Eigen::Vector2d &point, double min_dist) const
Check if a given point collides with the obstacle.
std::vector< Eigen::Vector2d, Eigen::aligned_allocator< Eigen::Vector2d > > Point2dContainer
Abbrev. for a container storing 2d points.
PolygonObstacle()
Default constructor of the polygon obstacle class.
virtual std::complex< double > getCentroidCplx() const =0
Get centroid coordinates of the obstacle as complex number.
virtual void toPolygonMsg(geometry_msgs::Polygon &polygon)
Convert the obstacle to a polygon message.
void finalizePolygon()
Call finalizePolygon after the polygon is created with the help of pushBackVertex() methods.
double distance_segment_to_segment_2d(const Eigen::Ref< const Eigen::Vector2d > &line1_start, const Eigen::Ref< const Eigen::Vector2d > &line1_end, const Eigen::Ref< const Eigen::Vector2d > &line2_start, const Eigen::Ref< const Eigen::Vector2d > &line2_end)
Helper function to calculate the smallest distance between two line segments.
Eigen::Vector2d centroid_
Store the centroid coordinates of the polygon (.
virtual void predictCentroidConstantVelocity(double t, Eigen::Ref< Eigen::Vector2d > position) const
Predict position of the centroid assuming a constant velocity model.
void clearVertices()
Clear all vertices (Afterwards the polygon is not valid anymore)
virtual bool checkLineIntersection(const Eigen::Vector2d &line_start, const Eigen::Vector2d &line_end, double min_dist=0) const
Check if a given line segment between two points intersects with the obstacle (and additionally keeps...
const Eigen::Vector2d & getCentroidVelocity() const
Get the obstacle velocity (vx, vy) (w.r.t. to the centroid)
virtual Eigen::Vector2d getClosestPoint(const Eigen::Vector2d &position) const
Get the closest point on the boundary of the obstacle w.r.t. a specified reference position.
Abstract class that defines the interface for modelling obstacles.
virtual double getMinimumSpatioTemporalDistance(const Eigen::Vector2d &position, double t) const =0
Get the estimated minimum spatiotemporal distance to the moving obstacle using a constant velocity mo...
virtual double getMinimumSpatioTemporalDistance(const Eigen::Vector2d &position, double t) const
Get the estimated minimum spatiotemporal distance to the moving obstacle using a constant velocity mo...
virtual const Eigen::Vector2d & getCentroid() const
Get centroid coordinates of the obstacle.
virtual bool checkCollision(const Eigen::Vector2d &point, double min_dist) const
Check if a given point collides with the obstacle.
virtual void toTwistWithCovarianceMsg(geometry_msgs::TwistWithCovariance &twistWithCovariance)
virtual void toPolygonMsg(geometry_msgs::Polygon &polygon)=0
Convert the obstacle to a polygon message.
PointObstacle()
Default constructor of the point obstacle class.
virtual bool checkLineIntersection(const Eigen::Vector2d &line_start, const Eigen::Vector2d &line_end, double min_dist=0) const =0
Check if a given line segment between two points intersects with the obstacle (and additionally keeps...
void pushBackVertex(const Eigen::Ref< const Eigen::Vector2d > &vertex)
Add a vertex to the polygon (edge-point)
virtual bool checkCollision(const Eigen::Vector2d &position, double min_dist) const =0
Check if a given point collides with the obstacle.
virtual bool checkLineIntersection(const Eigen::Vector2d &line_start, const Eigen::Vector2d &line_end, double min_dist=0) const
Check if a given line segment between two points intersects with the obstacle (and additionally keeps...
std::vector< Eigen::Vector2d, Eigen::aligned_allocator< Eigen::Vector2d > > VertexContainer
Abbrev. for a container storing vertices (2d points defining the edge points of the polygon)
boost::shared_ptr< const Obstacle > ObstacleConstPtr
Abbrev. for shared obstacle const pointers.
virtual void toPolygonMsg(geometry_msgs::Polygon &polygon)
Convert the obstacle to a polygon message.
Eigen::Vector2d centroid_
virtual const Eigen::Vector2d & getCentroid() const
Get centroid coordinates of the obstacle.
Obstacle()
Default constructor of the abstract obstacle class.
Eigen::Vector2d pos_
Store the center position of the CircularObstacle.
void calcCentroid()
Compute the centroid of the polygon (called inside finalizePolygon())
boost::shared_ptr< Obstacle > ObstaclePtr
Abbrev. for shared obstacle pointers.
virtual std::complex< double > getCentroidCplx() const
Get centroid coordinates of the obstacle as complex number.
virtual bool checkCollision(const Eigen::Vector2d &point, double min_dist) const
Check if a given point collides with the obstacle.
virtual void toPolygonMsg(geometry_msgs::Polygon &polygon)
Convert the obstacle to a polygon message.
Eigen::Vector2d closest_point_on_line_segment_2d(const Eigen::Ref< const Eigen::Vector2d > &point, const Eigen::Ref< const Eigen::Vector2d > &line_start, const Eigen::Ref< const Eigen::Vector2d > &line_end)
Helper function to obtain the closest point on a line segment w.r.t. a reference point.
void fixPolygonClosure()
Check if the current polygon contains the first vertex twice (as start and end) and in that case eras...
Implements a 2D circular obstacle (point obstacle plus radius)
virtual double getMinimumDistance(const Eigen::Vector2d &position) const
Get the minimum euclidean distance to the obstacle (point as reference)
double distance_point_to_segment_2d(const Eigen::Ref< const Eigen::Vector2d > &point, const Eigen::Ref< const Eigen::Vector2d > &line_start, const Eigen::Ref< const Eigen::Vector2d > &line_end)
Helper function to calculate the distance between a line segment and a point.
bool dynamic_
Store flag if obstacle is dynamic (resp. a moving obstacle)
double distance_point_to_polygon_2d(const Eigen::Vector2d &point, const Point2dContainer &vertices)
Helper function to calculate the smallest distance between a point and a closed polygon.
virtual std::complex< double > getCentroidCplx() const
Get centroid coordinates of the obstacle as complex number.
std::vector< ObstaclePtr > ObstContainer
Abbrev. for containers storing multiple obstacles.
virtual double getMinimumSpatioTemporalDistance(const Eigen::Vector2d &position, double t) const
Get the estimated minimum spatiotemporal distance to the moving obstacle using a constant velocity mo...
Implements a 2D pill/stadium/capsular-shaped obstacle (line + distance/radius)
LineObstacle()
Default constructor of the point obstacle class.
virtual bool checkLineIntersection(const Eigen::Vector2d &line_start, const Eigen::Vector2d &line_end, double min_dist=0) const
Check if a given line segment between two points intersects with the obstacle (and additionally keeps...
virtual Eigen::Vector2d getClosestPoint(const Eigen::Vector2d &position) const
Get the closest point on the boundary of the obstacle w.r.t. a specified reference position.
virtual const Eigen::Vector2d & getCentroid() const
Get centroid coordinates of the obstacle.
bool finalized_
Flat that keeps track if the polygon was finalized after adding all vertices.
virtual bool checkLineIntersection(const Eigen::Vector2d &line_start, const Eigen::Vector2d &line_end, double min_dist=0) const
Check if a given line segment between two points intersects with the obstacle (and additionally keeps...
virtual double getMinimumDistance(const Eigen::Vector2d &position) const
Get the minimum euclidean distance to the obstacle (point as reference)
Point2dContainer vertices_
Store vertices defining the polygon (.
const Eigen::Vector2d & start() const
double radius_
Radius of the obstacle.
const Eigen::Vector2d & end() const
PillObstacle()
Default constructor of the point obstacle class.
Implements a 2D point obstacle.
virtual double getMinimumDistance(const Eigen::Vector2d &position) const
Get the minimum euclidean distance to the obstacle (point as reference)
void setEnd(const Eigen::Ref< const Eigen::Vector2d > &end)
double distance_polygon_to_polygon_2d(const Point2dContainer &vertices1, const Point2dContainer &vertices2)
Helper function to calculate the smallest distance between two closed polygons.
virtual double getMinimumSpatioTemporalDistance(const Eigen::Vector2d &position, double t) const
Get the estimated minimum spatiotemporal distance to the moving obstacle using a constant velocity mo...
const Eigen::Vector2d & start() const
void setStart(const Eigen::Ref< const Eigen::Vector2d > &start)
virtual bool checkLineIntersection(const Eigen::Vector2d &line_start, const Eigen::Vector2d &line_end, double min_dist=0) const
Check if a given line segment between two points intersects with the obstacle (and additionally keeps...
const Eigen::Vector2d & end() const
virtual void toPolygonMsg(geometry_msgs::Polygon &polygon)
Convert the obstacle to a polygon message.
virtual double getMinimumSpatioTemporalDistance(const Eigen::Vector2d &position, double t) const
Get the estimated minimum spatiotemporal distance to the moving obstacle using a constant velocity mo...
double distance_segment_to_polygon_2d(const Eigen::Vector2d &line_start, const Eigen::Vector2d &line_end, const Point2dContainer &vertices)
Helper function to calculate the smallest distance between a line segment and a closed polygon.
virtual const Eigen::Vector2d & getCentroid() const =0
Get centroid coordinates of the obstacle.
Implements a 2D line obstacle.
virtual ~Obstacle()
Virtual destructor.
virtual const Eigen::Vector2d & getCentroid() const
Get centroid coordinates of the obstacle.
virtual bool checkCollision(const Eigen::Vector2d &point, double min_dist) const
Check if a given point collides with the obstacle.
virtual void toPolygonMsg(geometry_msgs::Polygon &polygon)
Convert the obstacle to a polygon message.
virtual bool checkCollision(const Eigen::Vector2d &point, double min_dist) const
Check if a given point collides with the obstacle.
Implements a polygon obstacle with an arbitrary number of vertices.
virtual Eigen::Vector2d getClosestPoint(const Eigen::Vector2d &position) const
Get the closest point on the boundary of the obstacle w.r.t. a specified reference position.
virtual std::complex< double > getCentroidCplx() const
Get centroid coordinates of the obstacle as complex number.
virtual Eigen::Vector2d getClosestPoint(const Eigen::Vector2d &position) const =0
Get the closest point on the boundary of the obstacle w.r.t. a specified reference position.
geometry_msgs::TransformStamped t
virtual Eigen::Vector2d getClosestPoint(const Eigen::Vector2d &position) const
Get the closest point on the boundary of the obstacle w.r.t. a specified reference position.
Eigen::Vector2d centroid_
bool check_line_segments_intersection_2d(const Eigen::Ref< const Eigen::Vector2d > &line1_start, const Eigen::Ref< const Eigen::Vector2d > &line1_end, const Eigen::Ref< const Eigen::Vector2d > &line2_start, const Eigen::Ref< const Eigen::Vector2d > &line2_end, Eigen::Vector2d *intersection=NULL)
Helper function to check whether two line segments intersects.
Eigen::Vector2d pos_
Store the position of the PointObstacle.
void setCentroidVelocity(const Eigen::Ref< const Eigen::Vector2d > &vel)
Set the 2d velocity (vx, vy) of the obstacle w.r.t to the centroid.
virtual double getMinimumSpatioTemporalDistance(const Eigen::Vector2d &position, double t) const
Get the estimated minimum spatiotemporal distance to the moving obstacle using a constant velocity mo...
teb_local_planner
Author(s): Christoph Rösmann
autogenerated on Sun Jan 7 2024 03:45:15