40 #ifndef ROBOT_FOOTPRINT_MODEL_H 41 #define ROBOT_FOOTPRINT_MODEL_H 45 #include <visualization_msgs/Marker.h> 102 virtual void visualizeRobot(
const PoseSE2& current_pose, std::vector<visualization_msgs::Marker>& markers )
const {}
114 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
238 visualization_msgs::Marker& marker = markers.back();
239 marker.type = visualization_msgs::Marker::CYLINDER;
241 marker.scale.x = marker.scale.y = 2*radius_;
242 marker.scale.z = 0.05;
243 marker.color.a = 0.5;
244 marker.color.r = 0.0;
245 marker.color.g = 0.8;
246 marker.color.b = 0.0;
277 : front_offset_(front_offset), front_radius_(front_radius), rear_offset_(rear_offset), rear_radius_(rear_radius) { }
291 void setParameters(
double front_offset,
double front_radius,
double rear_offset,
double rear_radius)
292 {front_offset_=front_offset; front_radius_=front_radius; rear_offset_=rear_offset; rear_radius_=rear_radius;}
305 return std::min(dist_front, dist_rear);
320 return std::min(dist_front, dist_rear);
333 std_msgs::ColorRGBA color;
342 markers.push_back(visualization_msgs::Marker());
343 visualization_msgs::Marker& marker1 = markers.front();
344 marker1.type = visualization_msgs::Marker::CYLINDER;
346 marker1.pose.position.x += front_offset_*dir.x();
347 marker1.pose.position.y += front_offset_*dir.y();
348 marker1.scale.x = marker1.scale.y = 2*front_radius_;
350 marker1.color = color;
355 markers.push_back(visualization_msgs::Marker());
356 visualization_msgs::Marker& marker2 = markers.back();
357 marker2.type = visualization_msgs::Marker::CYLINDER;
359 marker2.pose.position.x -= rear_offset_*dir.x();
360 marker2.pose.position.y -= rear_offset_*dir.y();
361 marker2.scale.x = marker2.scale.y = 2*rear_radius_;
363 marker2.color = color;
373 double min_longitudinal = std::min(rear_offset_ + rear_radius_, front_offset_ + front_radius_);
374 double min_lateral = std::min(rear_radius_, front_radius_);
375 return std::min(min_longitudinal, min_lateral);
404 setLine(line_start, line_end);
414 setLine(line_start, line_end);
428 line_start_.x() = line_start.x;
429 line_start_.y() = line_start.y;
430 line_end_.x() = line_end.x;
431 line_end_.y() = line_end.y;
452 Eigen::Vector2d line_start_world;
453 Eigen::Vector2d line_end_world;
454 transformToWorld(current_pose, line_start_world, line_end_world);
467 Eigen::Vector2d line_start_world;
468 Eigen::Vector2d line_end_world;
469 transformToWorld(current_pose, line_start_world, line_end_world);
483 std_msgs::ColorRGBA color;
489 markers.push_back(visualization_msgs::Marker());
490 visualization_msgs::Marker& marker = markers.front();
491 marker.type = visualization_msgs::Marker::LINE_STRIP;
495 geometry_msgs::Point line_start_world;
496 line_start_world.x = line_start_.x();
497 line_start_world.y = line_start_.y();
498 line_start_world.z = 0;
499 marker.points.push_back(line_start_world);
501 geometry_msgs::Point line_end_world;
502 line_end_world.x = line_end_.x();
503 line_end_world.y = line_end_.y();
504 line_end_world.z = 0;
505 marker.points.push_back(line_end_world);
507 marker.scale.x = 0.05;
508 marker.color = color;
530 double cos_th = std::cos(current_pose.
theta());
531 double sin_th = std::sin(current_pose.
theta());
532 line_start_world.x() = current_pose.
x() + cos_th * line_start_.x() - sin_th * line_start_.y();
533 line_start_world.y() = current_pose.
y() + sin_th * line_start_.x() + cos_th * line_start_.y();
534 line_end_world.x() = current_pose.
x() + cos_th * line_end_.x() - sin_th * line_end_.y();
535 line_end_world.y() = current_pose.
y() + sin_th * line_end_.x() + cos_th * line_end_.y();
542 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
584 transformToWorld(current_pose, polygon_world);
598 transformToWorld(current_pose, polygon_world);
612 if (vertices_.empty())
615 std_msgs::ColorRGBA color;
621 markers.push_back(visualization_msgs::Marker());
622 visualization_msgs::Marker& marker = markers.front();
623 marker.type = visualization_msgs::Marker::LINE_STRIP;
626 for (std::size_t i = 0; i < vertices_.size(); ++i)
628 geometry_msgs::Point
point;
629 point.x = vertices_[i].x();
630 point.y = vertices_[i].y();
632 marker.points.push_back(point);
635 geometry_msgs::Point
point;
636 point.x = vertices_.front().x();
637 point.y = vertices_.front().y();
639 marker.points.push_back(point);
641 marker.scale.x = 0.025;
642 marker.color = color;
652 double min_dist = std::numeric_limits<double>::max();
653 Eigen::Vector2d center(0.0, 0.0);
655 if (vertices_.size() <= 2)
658 for (
int i = 0; i < (int)vertices_.size() - 1; ++i)
661 double vertex_dist = vertices_[i].norm();
663 min_dist = std::min(min_dist, std::min(vertex_dist, edge_dist));
667 double vertex_dist = vertices_.back().norm();
669 return std::min(min_dist, std::min(vertex_dist, edge_dist));
681 double cos_th = std::cos(current_pose.
theta());
682 double sin_th = std::sin(current_pose.
theta());
683 for (std::size_t i=0; i<vertices_.size(); ++i)
685 polygon_world[i].x() = current_pose.
x() + cos_th * vertices_[i].x() - sin_th * vertices_[i].y();
686 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 & 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.
Eigen::Vector2d orientationUnitVec() const
Return the unit vector of the current orientation.
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.
void toPoseMsg(geometry_msgs::Pose &pose) const
Convert PoseSE2 to a geometry_msgs::Pose.
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.
boost::shared_ptr< BaseRobotFootprintModel > RobotFootprintModelPtr
Abbrev. for shared obstacle pointers.
Abstract class that defines the interface for modelling obstacles.