You are on page 1of 14

CODE TRACK DANIELE GUSMINI

ID DATA FILE
map_grid_visualizer.cpp
1 21/04/2020
map_grid_visualizer.h
Added 4 explicit topics to visualize separately goal_cost,
DESCRIPTION
path_cost, occ_cost and total cost
CODE COMMENTS
/ /

ID DATA FILE
map_grid.cpp
2 21/04/2020
map_grid.h
Added description in the brief .h of setTargetCells and
DESCRIPTION
computeTargetDistance. Modified setTargetCell.
CODE PRE CODE POST
void void MapGrid::setTargetCells(const
MapGrid::setTargetCells(const costmap_2d::Costmap2D& costmap,
costmap_2d::Costmap2D& costmap, const
const std::vector<geometry_msgs::PoseStamp
std::vector<geometry_msgs::PoseSta ed>& global_plan) {
mped>& global_plan) {
sizeCheck(costmap.getSizeInCellsX(),
sizeCheck(costmap.getSizeInCellsX( costmap.getSizeInCellsY());
), costmap.getSizeInCellsY());
bool started_path = false;
bool started_path = false;
queue<MapCell*> path_dist_queue;
queue<MapCell*>
path_dist_queue;
std::vector<geometry_msgs::PoseStamp
ed> adjusted_global_plan;
std::vector<geometry_msgs::PoseSta
mped> adjusted_global_plan; adjustPlanResolution(global_plan,
adjusted_global_plan,
adjustPlanResolution(global_plan, costmap.getResolution());
adjusted_global_plan, if (adjusted_global_plan.size()
costmap.getResolution()); != global_plan.size()) {
if ROS_DEBUG("Adjusted global
(adjusted_global_plan.size() != plan resolution, added %zu points",
global_plan.size()) { adjusted_global_plan.size() -
ROS_DEBUG("Adjusted global global_plan.size());
plan resolution, added %zu }
points", unsigned int i;
adjusted_global_plan.size() - // put global path points into
global_plan.size()); local map until we reach the border
} of the local map
unsigned int i; for (i = 0; i <
// put global path points into adjusted_global_plan.size(); ++i) {
local map until we reach the double g_x =
border of the local map adjusted_global_plan[i].pose.positio
for (i = 0; i < n.x;
adjusted_global_plan.size(); ++i) double g_y =
{ adjusted_global_plan[i].pose.positio
double g_x = n.y;
adjusted_global_plan[i].pose.posit unsigned int map_x, map_y;
ion.x; if (costmap.worldToMap(g_x,
double g_y = g_y, map_x, map_y) &&
adjusted_global_plan[i].pose.posit costmap.getCost(map_x, map_y) !=
ion.y; costmap_2d::NO_INFORMATION) {
unsigned int map_x, map_y; MapCell& current =
if (costmap.worldToMap(g_x, getCell(map_x, map_y);
g_y, map_x, map_y) && current.target_dist = 10-i*0.1;
costmap.getCost(map_x, map_y) != current.target_mark = true;
costmap_2d::NO_INFORMATION) {
MapCell& current =
getCell(map_x, map_y); path_dist_queue.push(&current);
current.target_dist = 0; started_path = true;
//Modfied to ALG C Daniele Gusmini } else if (started_path) {
current.target_mark = break;
true; }
}
if (!started_path) {
path_dist_queue.push(&current); ROS_ERROR("None of the %d
started_path = true; first of %zu (%zu) points of the
} else if (started_path) { global plan were in the local
break; costmap and free",
} i,
} adjusted_global_plan.size(),
if (!started_path) { global_plan.size());
ROS_ERROR("None of the %d return;
first of %zu (%zu) points of the }
global plan were in the local
costmap and free",
i,
adjusted_global_plan.size(), computeTargetDistance(path_dist_queu
global_plan.size()); e, costmap);
return;
} }

computeTargetDistance(path_dist_qu
eue, costmap);

}
COMMENTS
Modified to introduce a cost proportional to the distance from the robot
along the curvilinear coordinate
ID DATA FILE
map_grid.cpp
3 22/04/2020
map_grid.h
Added a while cycle that read again the queue, assign a
DESCRIPTION cost = max_cost-steep at each cell and give the cells to the
compute target distance function.
CODE PRE CODE POST
void void MapGrid::setTargetCells(const
MapGrid::setTargetCells(const costmap_2d::Costmap2D& costmap,
costmap_2d::Costmap2D& costmap, const
const std::vector<geometry_msgs::PoseStamp
std::vector<geometry_msgs::PoseSta ed>& global_plan) {
mped>& global_plan) {
sizeCheck(costmap.getSizeInCellsX(),
sizeCheck(costmap.getSizeInCellsX( costmap.getSizeInCellsY());
), costmap.getSizeInCellsY());
bool started_path = false;
bool started_path = false; //Check if a local_path as been
initialized
queue<MapCell*>
path_dist_queue; queue<MapCell*> path_dist_queue;
//Initialize a queue of the cell
whoose contains the local path
queue<MapCell*>
std::vector<geometry_msgs::PoseSta path_dist_queue_modified;
mped> adjusted_global_plan; //Initialize a queue of the cell
whoose contains the local path,
adjustPlanResolution(global_plan, modified with a decreasing cost
adjusted_global_plan,
costmap.getResolution());
if std::vector<geometry_msgs::PoseStamp
(adjusted_global_plan.size() != ed> adjusted_global_plan;
global_plan.size()) {
ROS_DEBUG("Adjusted global adjustPlanResolution(global_plan,
plan resolution, added %zu adjusted_global_plan,
points", costmap.getResolution()); //Resize
adjusted_global_plan.size() - the global path to fit the
global_plan.size()); resolution of the cost_grid (local)
} if (adjusted_global_plan.size()
unsigned int i; != global_plan.size()) {
// put global path points into ROS_DEBUG("Adjusted global
local map until we reach the plan resolution, added %zu points",
border of the local map adjusted_global_plan.size() -
for (i = 0; i < global_plan.size());
adjusted_global_plan.size(); ++i) }
{ unsigned int i;
double g_x =
adjusted_global_plan[i].pose.posit // put global path points into local
ion.x; map until we reach the border of the
double g_y = local map
adjusted_global_plan[i].pose.posit for (i = 0; i <
ion.y; adjusted_global_plan.size(); ++i) {
unsigned int map_x, map_y; //For each point of the local path
if (costmap.worldToMap(g_x, find the cell and if it has not been
g_y, map_x, map_y) && check before update cost
costmap.getCost(map_x, map_y) != double g_x =
costmap_2d::NO_INFORMATION) { adjusted_global_plan[i].pose.positio
MapCell& current = n.x;
getCell(map_x, map_y); double g_y =
current.target_dist = 10-i*0.1; adjusted_global_plan[i].pose.positio
current.target_mark = n.y;
true; unsigned int map_x, map_y;
if (costmap.worldToMap(g_x,
g_y, map_x, map_y) &&
path_dist_queue.push(&current); costmap.getCost(map_x, map_y) !=
started_path = true; costmap_2d::NO_INFORMATION) {
} else if (started_path) { MapCell& current =
break; getCell(map_x, map_y);
} //Pointer to the current cell of
} grid
if (!started_path) { // current.target_dist = 10-
ROS_ERROR("None of the %d i*0.1;
first of %zu (%zu) points of the //-->Modfied to ALG C Daniele
global plan were in the local Gusmini
costmap and free", current.target_dist = 0;
i, current.target_mark = true;
adjusted_global_plan.size(), //Cell marked as updated
global_plan.size());
return; path_dist_queue.push(&current);
} //Add the cell to the queue
started_path = true;
//Declare the path started
computeTargetDistance(path_dist_qu } else if (started_path) {
eue, costmap); break;
}
} }
if (!started_path) {
ROS_ERROR("None of the %d
first of %zu (%zu) points of the
global plan were in the local
costmap and free",
i,
adjusted_global_plan.size(),
global_plan.size());
return;
}

//Update the cost of the cell


containing the path base on the
dimension of queue

double steep;
double cost;
unsigned long lPathLenght;

steep = 0.1;
lPathLenght =
path_dist_queue.size();
cost = lPathLenght * steep;

while(!path_dist_queue.empty()){
path_dist_queue.front()-
>target_dist = cost;

path_dist_queue_modified.push(path_d
ist_queue.front());
path_dist_queue.pop();
cost = cost - steep;
}

computeTargetDistance(path_dist_queu
e_modified, costmap);
//Compute the remaining cell costs
starting from the path

}
COMMENTS
The while cycle read and create another queue, unable to access at each
element of a queue without decomposing it.

ID DATA FILE
dwa_planner.cpp
4 23/04/2020
dwa_planner.h
Added read parameters mod and steep from param
DESCRIPTION server and call setMod method on the path_cost.
Modified critics and getCellCost to exclude goal.
CODE PRE CODE POST
DWAPlanner::DWAPlanner(std::string DWAPlanner::DWAPlanner(std::string
name, name,
base_local_planner::LocalPlannerUt base_local_planner::LocalPlannerUtil
il *planner_util) : *planner_util) :
planner_util_(planner_util), planner_util_(planner_util),
obstacle_costs_(planner_util-
obstacle_costs_(planner_util- >getCostmap()),
>getCostmap()), path_costs_(planner_util-
path_costs_(planner_util- >getCostmap()),
>getCostmap()), goal_costs_(planner_util-
goal_costs_(planner_util- >getCostmap(), 0.0, 0.0, true),
>getCostmap(), 0.0, 0.0, true),
goal_front_costs_(planner_util-
goal_front_costs_(planner_util- >getCostmap(), 0.0, 0.0, true),
>getCostmap(), 0.0, 0.0, true), alignment_costs_(planner_util-
>getCostmap())
alignment_costs_(planner_util- {
>getCostmap()) ros::NodeHandle private_nh("~/"
{ + name);
ros::NodeHandle
private_nh("~/" + name);
goal_front_costs_.setStopOnFailure(
false );
goal_front_costs_.setStopOnFailure
( false ); alignment_costs_.setStopOnFailure( f
alse );
alignment_costs_.setStopOnFailure(
false ); //Assuming this planner is being
run within the navigation stack, we
//Assuming this planner is can
being run within the navigation //just do an upward search for
stack, we can the frequency at which its being
//just do an upward search for run. This
the frequency at which its being //also allows the frequency to
run. This be overwritten locally.
//also allows the frequency to std::string
be overwritten locally. controller_frequency_param_name;
std::string if(!
controller_frequency_param_name; private_nh.searchParam("controller_f
if(! requency",
private_nh.searchParam("controller controller_frequency_param_name)) {
_frequency", sim_period_ = 0.05;
controller_frequency_param_name)) } else {
{ double controller_frequency =
sim_period_ = 0.05; 0;
} else {
double controller_frequency private_nh.param(controller_frequenc
= 0; y_param_name, controller_frequency,
20.0);
private_nh.param(controller_freque if(controller_frequency > 0) {
ncy_param_name, sim_period_ = 1.0 /
controller_frequency, 20.0); controller_frequency;
if(controller_frequency > 0) } else {
{ ROS_WARN("A
sim_period_ = 1.0 / controller_frequency less than 0 has
controller_frequency; been set. Ignoring the parameter,
} else { assuming a rate of 20Hz");
ROS_WARN("A sim_period_ = 0.05;
controller_frequency less than 0 }
has been set. Ignoring the }
parameter, assuming a rate of ROS_INFO("Sim period is set to
20Hz"); %.2f", sim_period_);
sim_period_ = 0.05;
}
} oscillation_costs_.resetOscillationF
ROS_INFO("Sim period is set to lags();
%.2f", sim_period_);
bool sum_scores;
private_nh.param("sum_scores",
oscillation_costs_.resetOscillatio sum_scores, false);
nFlags();
obstacle_costs_.setSumScores(sum_sco
bool sum_scores; res);
private_nh.param("sum_scores",
sum_scores, false);

obstacle_costs_.setSumScores(sum_s private_nh.param("publish_cost_grid_
cores); pc", publish_cost_grid_pc_, false);
map_viz_.initialize(name,
planner_util->getGlobalFrame(),
boost::bind(&DWAPlanner::getCellCost
private_nh.param("publish_cost_gri s, this, _1, _2, _3, _4, _5, _6));
d_pc", publish_cost_grid_pc_,
false);
map_viz_.initialize(name, private_nh.param("global_frame_id",
planner_util->getGlobalFrame(), frame_id_, std::string("odom"));
boost::bind(&DWAPlanner::getCellCo
sts, this, _1, _2, _3, _4, _5, traj_cloud_pub_ =
_6)); private_nh.advertise<sensor_msgs::Po
intCloud2>("trajectory_cloud", 1);

private_nh.param("global_frame_id" private_nh.param("publish_traj_pc",
, frame_id_, std::string("odom")); publish_traj_pc_, false);

traj_cloud_pub_ = //-> Daniele


private_nh.advertise<sensor_msgs:: private_nh.param("mod", mod_,
PointCloud2>("trajectory_cloud", false); //Read the
1); parameters from parameter server
private_nh.param("steep",
private_nh.param("publish_traj_pc" steep_, 0.0);
, publish_traj_pc_, true); path_costs_.setMod(mod_,
steep_); //Method
// set up all the cost defined in map_grid_cost_function.h
functions that will be applied in to send mod and steep params
order
// (any function returning // set up all the cost functions
negative values will abort that will be applied in order
scoring, so the order can improve // (any function returning
performance) negative values will abort scoring,
so the order can improve
std::vector<base_local_planner::Tr performance)
ajectoryCostFunction*> critics;
std::vector<base_local_planner::Traj
critics.push_back(&oscillation_cos ectoryCostFunction*> critics;
ts_); // discards oscillating
motions (assisgns cost -1) if (mod_){ //in mod do
not update critics og local goal
critics.push_back(&obstacle_costs_
); // discards trajectories that critics.push_back(&oscillation_costs
move into obstacles _); // discards oscillating motions
(assisgns cost -1)
critics.push_back(&goal_front_cost
s_); // prefers trajectories that critics.push_back(&obstacle_costs_);
make the nose go towards (local) // discards trajectories that move
nose goal into obstacles

critics.push_back(&alignment_costs critics.push_back(&goal_front_costs_
_); // prefers trajectories that ); // prefers trajectories that make
keep the robot nose on nose path the nose go towards (local) nose
goal
critics.push_back(&path_costs_); /
/ prefers trajectories on global critics.push_back(&alignment_costs_)
path ; // prefers trajectories that keep
the robot nose on nose path
critics.push_back(&goal_costs_); /
/ prefers trajectories that go critics.push_back(&path_costs_); //
towards (local) goal, based on prefers trajectories on global path
wave propagation
critics.push_back(&twirling_costs_);
critics.push_back(&twirling_costs_ // optionally prefer trajectories
); // optionally prefer that don't spin
trajectories that don't spin }
else {
// trajectory generators
critics.push_back(&oscillation_costs
std::vector<base_local_planner::Tr _); // discards oscillating motions
ajectorySampleGenerator*> (assisgns cost -1)
generator_list;
critics.push_back(&obstacle_costs_);
generator_list.push_back(&generato // discards trajectories that move
r_); into obstacles

scored_sampling_planner_ = critics.push_back(&goal_front_costs_
base_local_planner::SimpleScoredSa ); // prefers trajectories that make
mplingPlanner(generator_list, the nose go towards (local) nose
critics); goal

critics.push_back(&alignment_costs_)
private_nh.param("cheat_factor", ; // prefers trajectories that keep
cheat_factor_, 1.0); the robot nose on nose path

//###################### critics.push_back(&path_costs_); //
MODIFIED 20200116 Singhiozzo in prefers trajectories on global path
curva ###########################
critics.push_back(&goal_costs_); //
goal_costs_.setStopOnFailure(false prefers trajectories that go towards
); (local) goal, based on wave
propagation
path_costs_.setStopOnFailure(false
); critics.push_back(&twirling_costs_);
// optionally prefer trajectories
alignment_costs_.setStopOnFailure( that don't spin
false); }
///
################################## // trajectory generators
##################################
################## std::vector<base_local_planner::Traj
} ectorySampleGenerator*>
generator_list;
// used for visualization only,
total_costs are not really total generator_list.push_back(&generator_
costs );
bool
DWAPlanner::getCellCosts(int cx, scored_sampling_planner_ =
int cy, float &path_cost, float base_local_planner::SimpleScoredSamp
&goal_cost, float &occ_cost, float lingPlanner(generator_list,
&total_cost) { critics);

path_cost = private_nh.param("cheat_factor",
path_costs_.getCellCosts(cx, cy); cheat_factor_, 1.0);
goal_cost =
goal_costs_.getCellCosts(cx, cy); //######################
occ_cost = planner_util_- MODIFIED 20200116 Singhiozzo in
>getCostmap()->getCost(cx, cy); curva ###########################
ROS_INFO("Hey");
if (path_cost == goal_costs_.setStopOnFailure(false);
path_costs_.obstacleCosts() ||
path_cost == path_costs_.setStopOnFailure(false);
path_costs_.unreachableCellCosts()
|| alignment_costs_.setStopOnFailure(fa
occ_cost >= lse);
costmap_2d::INSCRIBED_INFLATED_OBS ///
TACLE) { ####################################
return false; ####################################
} ##############
}
total_cost =
pdist_scale_ * path_cost + // used for visualization only,
gdist_scale_ * goal_cost + total_costs are not really total
occdist_scale_ * occ_cost; costs
bool DWAPlanner::getCellCosts(int
return true; cx, int cy, float &path_cost, float
} &goal_cost, float &occ_cost, float
&total_cost) {
path_cost =
path_costs_.getCellCosts(cx, cy);
goal_cost =
goal_costs_.getCellCosts(cx, cy);
occ_cost = planner_util_-
>getCostmap()->getCost(cx, cy);

if (path_cost ==
path_costs_.obstacleCosts() ||
path_cost ==
path_costs_.unreachableCellCosts()
||
occ_cost >=
costmap_2d::INSCRIBED_INFLATED_OBSTA
CLE) {
return false;
}

if(mod_){
total_cost =
pdist_scale_ * path_cost +
occdist_scale_ * occ_cost;
}
else{
total_cost =
pdist_scale_ * path_cost +
gdist_scale_ * goal_cost +
occdist_scale_ * occ_cost;
}

return true;
}
COMMENTS
Mod_ and steep_ are private parameters of the dwa_planner

ID DATA FILE
5 23/04/2020 map_grid_cost_function.h
Introduced a method setMod that take the values and set
DESCRIPTION
mod and steep
CODE PRE CODE POST
/
/
COMMENTS

ID DATA FILE
6 23/04/2020 map_grid_cost_function.cpp
Add a check in prepare(), if mod_ call seTargetCellsMod
DESCRIPTION
the modified version that take into parameter steep_
CODE PRE CODE POST
MapGridCostFunction::MapGridCostFu MapGridCostFunction::MapGridCostFunc
nction(costmap_2d::Costmap2D* tion(costmap_2d::Costmap2D* costmap,
costmap, double xshift,
double xshift, double yshift,
double yshift, bool is_local_goal_function,
bool is_local_goal_function, CostAggregationType
CostAggregationType aggregationType) :
aggregationType) : costmap_(costmap),
costmap_(costmap), map_(costmap->getSizeInCellsX(),
map_(costmap- costmap->getSizeInCellsY()),
>getSizeInCellsX(), costmap-
>getSizeInCellsY()), aggregationType_(aggregationType),
xshift_(xshift),
aggregationType_(aggregationType), yshift_(yshift),
xshift_(xshift),
yshift_(yshift), is_local_goal_function_(is_local_goa
l_function),
is_local_goal_function_(is_local_g stop_on_failure_(true),
oal_function), mod_(0), //
stop_on_failure_(true) {} steep_(0){} //

void void
MapGridCostFunction::setTargetPose MapGridCostFunction::setTargetPoses(
s(std::vector<geometry_msgs::PoseS std::vector<geometry_msgs::PoseStamp
tamped> target_poses) { ed> target_poses) {
target_poses_ = target_poses; target_poses_ = target_poses;
} }

bool bool MapGridCostFunction::prepare()


MapGridCostFunction::prepare() { {
map_.resetPathDist(); map_.resetPathDist();

if (is_local_goal_function_) { if (is_local_goal_function_) {
map_.setLocalGoal(*costmap_, map_.setLocalGoal(*costmap_,
target_poses_); target_poses_);
} else { } else {
map_.setTargetCells(*costmap_, if(mod_){
target_poses_);
} map_.setTargetCellsMod(*costmap_,
return true; target_poses_, steep_);
} }
else {
map_.setTargetCells(*costmap_,
target_poses_);
}

}
return true;
}
COMMENTS

ID DATA FILE
map_grid.h
7 23/04/2020
map_grid.cpp
Split setTargetCell and *Mod that take as input the
DESCRIPTION
paramenter steep
CODE PRE CODE POST
/
/
COMMENTS

ID DATA FILE
map_grid.h
8 1/05/2020
map_grid.cpp
Added computeTargetDistance to use the quadratic cost
function if enabled from parameters, it calls
DESCRIPTION
updatepathCellMod instead of the standard version that
make uses of the quadratic cost function
CODE PRE CODE POST
void void
MapGrid::computeTargetDistance(que MapGrid::computeTargetDistanceQuad(q
ue<MapCell*>& dist_queue, const ueue<MapCell*>& dist_queue, const
costmap_2d::Costmap2D& costmap){ costmap_2d::Costmap2D& costmap,
MapCell* current_cell; double multi){
MapCell* check_cell; MapCell* current_cell;
unsigned int last_col = MapCell* check_cell;
size_x_ - 1; unsigned int last_col = size_x_
unsigned int last_row = - 1;
size_y_ - 1; unsigned int last_row = size_y_
while(!dist_queue.empty()){ - 1;
current_cell = while(!dist_queue.empty()){
dist_queue.front(); current_cell =
dist_queue.front();

dist_queue.pop();
dist_queue.pop();
if(current_cell->cx > 0){
check_cell = current_cell if(current_cell->cx > 0){
- 1; check_cell = current_cell -
if(!check_cell- 1;
>target_mark){ if(!check_cell->target_mark)
//mark the cell as {
visisted //mark the cell as
check_cell->target_mark visisted
= true; check_cell->target_mark =
true;
if(updatePathCell(current_cell,
check_cell, costmap)) { if(updatePathCellQuad(current_cell,
check_cell, costmap, multi)) {
dist_queue.push(check_cell);
} dist_queue.push(check_cell);
} }
} }
}
if(current_cell->cx <
last_col){ if(current_cell->cx <
check_cell = current_cell last_col){
+ 1; check_cell = current_cell +
if(!check_cell- 1;
>target_mark){ if(!check_cell->target_mark)
check_cell->target_mark {
= true; check_cell->target_mark =
true;
if(updatePathCell(current_cell,
check_cell, costmap)) { if(updatePathCellQuad(current_cell,
check_cell, costmap, multi)) {
dist_queue.push(check_cell);
} dist_queue.push(check_cell);
} }
} }
}
if(current_cell->cy > 0){
check_cell = current_cell if(current_cell->cy > 0){
- size_x_; check_cell = current_cell -
if(!check_cell- size_x_;
>target_mark){ if(!check_cell->target_mark)
check_cell->target_mark {
= true; check_cell->target_mark =
true;
if(updatePathCell(current_cell,
check_cell, costmap)) { if(updatePathCellQuad(current_cell,
check_cell, costmap, multi)) {
dist_queue.push(check_cell);
} dist_queue.push(check_cell);
} }
} }
}
if(current_cell->cy <
last_row){ if(current_cell->cy <
check_cell = current_cell last_row){
+ size_x_; check_cell = current_cell +
if(!check_cell- size_x_;
>target_mark){ if(!check_cell->target_mark)
check_cell->target_mark {
= true; check_cell->target_mark =
true;
if(updatePathCell(current_cell,
check_cell, costmap)) { if(updatePathCellQuad(current_cell,
check_cell, costmap, multi)) {
dist_queue.push(check_cell);
} dist_queue.push(check_cell);
} }
} }
} }
} }
}
};
COMMENTS

ID DATA FILE
9 1/05/2020 map_cell.cpp
Added target_dist_real to indicate the real distance from
the path of the cell not taking into account the cost of the
cell containing the path, root_cost that take trace of the
DESCRIPTION cost of the root cell from which the cell take the cost, the
original target_dist id the alg is the modified version does
not corresponds to the dist but to the dist + the cost of
the root cell.
CODE PRE CODE POST
#include #include
<base_local_planner/map_cell.h> <base_local_planner/map_cell.h>

namespace base_local_planner{ namespace base_local_planner{

MapCell::MapCell() MapCell::MapCell()
: cx(0), cy(0), : cx(0), cy(0),
target_dist(DBL_MAX), target_dist(DBL_MAX),
target_mark(false), target_dist_real(DBL_MAX),
within_robot(false) root_cost(DBL_MAX),
target_mark(false),
{} within_robot(false)

MapCell::MapCell(const MapCell& {}
mc)
: cx(mc.cx), cy(mc.cy), MapCell::MapCell(const MapCell&
target_dist(mc.target_dist), mc)
target_mark(mc.target_mark), : cx(mc.cx), cy(mc.cy),
target_dist(mc.target_dist),
within_robot(mc.within_robot) target_dist_real(DBL_MAX),
{} root_cost(DBL_MAX),
}; target_mark(mc.target_mark),
within_robot(mc.within_robot)
{}
};

COMMENTS

ID DATA FILE
10 1/05/2020 map_cell.cpp
Added updatePathCellQuad() that compute the cost of
DESCRIPTION the remaining cell as the cost of the root cell + the
quadratic distance*multi
CODE PRE CODE POST
/ inline bool
MapGrid::updatePathCellQuad(MapCell*
current_cell, MapCell* check_cell,
const costmap_2d::Costmap2D&
costmap, double multi){

//if the cell is an obstacle set


the max path distance
unsigned char cost =
costmap.getCost(check_cell->cx,
check_cell->cy);
if(! getCell(check_cell->cx,
check_cell->cy).within_robot &&
(cost ==
costmap_2d::LETHAL_OBSTACLE ||
cost ==
costmap_2d::INSCRIBED_INFLATED_OBSTA
CLE ||
cost ==
costmap_2d::NO_INFORMATION)){
check_cell->target_dist =
obstacleCosts();
return false;
}

double new_target_dist =
current_cell->target_dist_real + 1;
//real distance
//double new_target_dist =
current_cell->target_dist + 100;

if (new_target_dist <
check_cell->target_dist) {
check_cell->root_cost =
current_cell->root_cost;
check_cell->target_dist_real =
new_target_dist;
check_cell->target_dist =
check_cell->root_cost +
pow(new_target_dist*multi,2);
}
return true;
}
COMMENTS

You might also like