40 #ifndef ROBOT_FOOTPRINT_MODEL_H 41 #define ROBOT_FOOTPRINT_MODEL_H 45 #include <visualization_msgs/Marker.h> 103 virtual void visualizeRobot(
const PoseSE2& current_pose, std::vector<visualization_msgs::Marker>& markers,
const std_msgs::ColorRGBA& color)
const {}
115 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
192 virtual void visualizeRobot(
const PoseSE2& current_pose, std::vector<visualization_msgs::Marker>& markers,
const std_msgs::ColorRGBA& color)
const 195 markers.push_back(visualization_msgs::Marker());
196 visualization_msgs::Marker& marker = markers.back();
197 marker.type = visualization_msgs::Marker::POINTS;
199 marker.points.push_back(geometry_msgs::Point());
200 marker.scale.x = 0.025;
201 marker.color = color;
203 if (min_obstacle_dist_ <= 0)
209 markers.push_back(visualization_msgs::Marker());
210 visualization_msgs::Marker& marker2 = markers.back();
211 marker2.type = visualization_msgs::Marker::LINE_STRIP;
212 marker2.scale.x = 0.025;
213 marker2.color = color;
217 const double r = min_obstacle_dist_;
218 for (
double theta = 0; theta <= 2 * M_PI; theta += M_PI / n)
220 geometry_msgs::Point pt;
221 pt.x = r *
cos(theta);
222 pt.y = r *
sin(theta);
223 marker2.points.push_back(pt);
228 const double min_obstacle_dist_ = 0.0;
289 virtual void visualizeRobot(
const PoseSE2& current_pose, std::vector<visualization_msgs::Marker>& markers,
const std_msgs::ColorRGBA& color)
const 292 visualization_msgs::Marker& marker = markers.back();
293 marker.type = visualization_msgs::Marker::CYLINDER;
295 marker.scale.x = marker.scale.y = 2*radius_;
296 marker.scale.z = 0.05;
297 marker.color = color;
328 : front_offset_(front_offset), front_radius_(front_radius), rear_offset_(rear_offset), rear_radius_(rear_radius) { }
342 void setParameters(
double front_offset,
double front_radius,
double rear_offset,
double rear_radius)
343 {front_offset_=front_offset; front_radius_=front_radius; rear_offset_=rear_offset; rear_radius_=rear_radius;}
356 return std::min(dist_front, dist_rear);
371 return std::min(dist_front, dist_rear);
383 virtual void visualizeRobot(
const PoseSE2& current_pose, std::vector<visualization_msgs::Marker>& markers,
const std_msgs::ColorRGBA& color)
const 388 markers.push_back(visualization_msgs::Marker());
389 visualization_msgs::Marker& marker1 = markers.back();
390 marker1.type = visualization_msgs::Marker::CYLINDER;
392 marker1.pose.position.x += front_offset_*dir.x();
393 marker1.pose.position.y += front_offset_*dir.y();
394 marker1.scale.x = marker1.scale.y = 2*front_radius_;
396 marker1.color = color;
401 markers.push_back(visualization_msgs::Marker());
402 visualization_msgs::Marker& marker2 = markers.back();
403 marker2.type = visualization_msgs::Marker::CYLINDER;
405 marker2.pose.position.x -= rear_offset_*dir.x();
406 marker2.pose.position.y -= rear_offset_*dir.y();
407 marker2.scale.x = marker2.scale.y = 2*rear_radius_;
409 marker2.color = color;
419 double min_longitudinal = std::min(rear_offset_ + rear_radius_, front_offset_ + front_radius_);
420 double min_lateral = std::min(rear_radius_, front_radius_);
421 return std::min(min_longitudinal, min_lateral);
450 setLine(line_start, line_end);
460 setLine(line_start, line_end);
474 line_start_.x() = line_start.x;
475 line_start_.y() = line_start.y;
476 line_end_.x() = line_end.x;
477 line_end_.y() = line_end.y;
498 Eigen::Vector2d line_start_world;
499 Eigen::Vector2d line_end_world;
500 transformToWorld(current_pose, line_start_world, line_end_world);
513 Eigen::Vector2d line_start_world;
514 Eigen::Vector2d line_end_world;
515 transformToWorld(current_pose, line_start_world, line_end_world);
528 virtual void visualizeRobot(
const PoseSE2& current_pose, std::vector<visualization_msgs::Marker>& markers,
const std_msgs::ColorRGBA& color)
const 530 markers.push_back(visualization_msgs::Marker());
531 visualization_msgs::Marker& marker = markers.back();
532 marker.type = visualization_msgs::Marker::LINE_STRIP;
536 geometry_msgs::Point line_start_world;
537 line_start_world.x = line_start_.x();
538 line_start_world.y = line_start_.y();
539 line_start_world.z = 0;
540 marker.points.push_back(line_start_world);
542 geometry_msgs::Point line_end_world;
543 line_end_world.x = line_end_.x();
544 line_end_world.y = line_end_.y();
545 line_end_world.z = 0;
546 marker.points.push_back(line_end_world);
548 marker.scale.x = 0.025;
549 marker.color = color;
551 if (min_obstacle_dist_ <= 0)
557 markers.push_back(visualization_msgs::Marker());
558 visualization_msgs::Marker& marker2 = markers.back();
559 marker2.type = visualization_msgs::Marker::LINE_STRIP;
560 marker2.scale.x = 0.025;
561 marker2.color = color;
565 const double r = min_obstacle_dist_;
566 const double ori =
atan2(line_end_.y() - line_start_.y(), line_end_.x() - line_start_.x());
569 for (
double theta = M_PI_2 + ori; theta <= 3 * M_PI_2 + ori; theta += M_PI / n)
571 geometry_msgs::Point pt;
572 pt.x = line_start_.x() + r *
cos(theta);
573 pt.y = line_start_.y() + r *
sin(theta);
574 marker2.points.push_back(pt);
578 for (
double theta = -M_PI_2 + ori; theta <= M_PI_2 + ori; theta += M_PI / n)
580 geometry_msgs::Point pt;
581 pt.x = line_end_.x() + r *
cos(theta);
582 pt.y = line_end_.y() + r *
sin(theta);
583 marker2.points.push_back(pt);
587 geometry_msgs::Point pt;
588 pt.x = line_start_.x() + r *
cos(M_PI_2 + ori);
589 pt.y = line_start_.y() + r *
sin(M_PI_2 + ori);
590 marker2.points.push_back(pt);
612 double cos_th = std::cos(current_pose.
theta());
613 double sin_th = std::sin(current_pose.
theta());
614 line_start_world.x() = current_pose.
x() + cos_th * line_start_.x() - sin_th * line_start_.y();
615 line_start_world.y() = current_pose.
y() + sin_th * line_start_.x() + cos_th * line_start_.y();
616 line_end_world.x() = current_pose.
x() + cos_th * line_end_.x() - sin_th * line_end_.y();
617 line_end_world.y() = current_pose.
y() + sin_th * line_end_.x() + cos_th * line_end_.y();
622 const double min_obstacle_dist_ = 0.0;
625 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
667 transformToWorld(current_pose, polygon_world);
681 transformToWorld(current_pose, polygon_world);
694 virtual void visualizeRobot(
const PoseSE2& current_pose, std::vector<visualization_msgs::Marker>& markers,
const std_msgs::ColorRGBA& color)
const 696 if (vertices_.empty())
699 markers.push_back(visualization_msgs::Marker());
700 visualization_msgs::Marker& marker = markers.back();
701 marker.type = visualization_msgs::Marker::LINE_STRIP;
704 for (std::size_t i = 0; i < vertices_.size(); ++i)
706 geometry_msgs::Point
point;
707 point.x = vertices_[i].x();
708 point.y = vertices_[i].y();
710 marker.points.push_back(point);
713 geometry_msgs::Point
point;
714 point.x = vertices_.front().x();
715 point.y = vertices_.front().y();
717 marker.points.push_back(point);
719 marker.scale.x = 0.025;
720 marker.color = color;
730 double min_dist = std::numeric_limits<double>::max();
731 Eigen::Vector2d center(0.0, 0.0);
733 if (vertices_.size() <= 2)
736 for (
int i = 0; i < (int)vertices_.size() - 1; ++i)
739 double vertex_dist = vertices_[i].norm();
741 min_dist = std::min(min_dist, std::min(vertex_dist, edge_dist));
745 double vertex_dist = vertices_.back().norm();
747 return std::min(min_dist, std::min(vertex_dist, edge_dist));
759 double cos_th = std::cos(current_pose.
theta());
760 double sin_th = std::sin(current_pose.
theta());
761 for (std::size_t i=0; i<vertices_.size(); ++i)
763 polygon_world[i].x() = current_pose.
x() + cos_th * vertices_[i].x() - sin_th * vertices_[i].y();
764 polygon_world[i].y() = current_pose.
y() + sin_th * vertices_[i].x() + cos_th * vertices_[i].y();
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...
Eigen::Vector2d orientationUnitVec() const
Return the unit vector of the current orientation.
Eigen::Vector2d & position()
Access the 2D position part.
double & x()
Access the x-coordinate the pose.
std::vector< Eigen::Vector2d, Eigen::aligned_allocator< Eigen::Vector2d > > Point2dContainer
Abbrev. for a container storing 2d points.
geometry_msgs::TransformStamped t
void toPoseMsg(geometry_msgs::Pose &pose) const
Convert PoseSE2 to a geometry_msgs::Pose.
virtual double getMinimumDistance(const Eigen::Vector2d &position) const =0
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.
boost::shared_ptr< const BaseRobotFootprintModel > RobotFootprintModelConstPtr
Abbrev. for shared obstacle const pointers.
double & y()
Access the y-coordinate the pose.
This class implements a pose in the domain SE2: The pose consist of the position x and y and an orie...
double & theta()
Access the orientation part (yaw angle) of the pose.
INLINE Rall1d< T, V, S > atan2(const Rall1d< T, V, S > &y, const Rall1d< T, V, S > &x)
INLINE Rall1d< T, V, S > cos(const Rall1d< T, V, S > &arg)
boost::shared_ptr< BaseRobotFootprintModel > RobotFootprintModelPtr
Abbrev. for shared obstacle pointers.
INLINE Rall1d< T, V, S > sin(const Rall1d< T, V, S > &arg)
Abstract class that defines the interface for modelling obstacles.