Go to the documentation of this file.
41 #include <ros/console.h>
46 : costmap_(costmap), sum_scores_(false) {
47 if (costmap != NULL) {
80 ROS_ERROR(
"Footprint spec is empty, maybe missing call to setFootprint?");
84 for (
unsigned int i = 0; i < traj.getPointsSize(); ++i) {
85 traj.getPoint(i, px, py, pth);
95 unsigned int cell_x, cell_y;
108 double vmag = hypot(traj.
xv_, traj.
yv_);
113 if (vmag > scaling_speed) {
115 double ratio = (vmag - scaling_speed) / (max_trans_vel - scaling_speed);
116 scale = max_scaling_factor * ratio + 1.0;
131 for(
unsigned int i = 0; i < footprint_spec.
size(); ++i) {
132 geometry_msgs::Point new_pt;
133 new_pt.x = scale * footprint_spec[i].x;
134 new_pt.y = scale * footprint_spec[i].y;
140 double footprint_cost = world_model->
footprintCost(x, y, th, scaled_footprint);
142 if (footprint_cost < 0) {
145 unsigned int cell_x, cell_y;
148 if ( ! costmap->
worldToMap(x, y, cell_x, cell_y)) {
virtual double footprintCost(const geometry_msgs::Point &position, const std::vector< geometry_msgs::Point > &footprint, double inscribed_radius, double circumscribed_radius)=0
Subclass will implement this method to check a footprint at a given position and orientation for lega...
bool worldToMap(double wx, double wy, unsigned int &mx, unsigned int &my) const
double scoreTrajectory(Trajectory &traj)
costmap_2d::Costmap2D * costmap_
void setFootprint(std::vector< geometry_msgs::Point > footprint_spec)
void setParams(double max_trans_vel, double max_scaling_factor, double scaling_speed)
std::vector< geometry_msgs::Point > footprint_spec_
A class that implements the WorldModel interface to provide grid based collision checks for the traje...
base_local_planner::WorldModel * world_model_
An interface the trajectory controller uses to interact with the world regardless of the underlying w...
ObstacleCostFunction(costmap_2d::Costmap2D *costmap)
double max_scaling_factor_
Holds a trajectory generated by considering an x, y, and theta velocity.
unsigned char getCost(unsigned int mx, unsigned int my) const
static double getScalingFactor(Trajectory &traj, double scaling_speed, double max_trans_vel, double max_scaling_factor)
static double footprintCost(const double &x, const double &y, const double &th, double scale, std::vector< geometry_msgs::Point > footprint_spec, costmap_2d::Costmap2D *costmap, base_local_planner::WorldModel *world_model)