Skip to content

Commit

Permalink
Complete local planner implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
guillermogilg99 committed Oct 22, 2024
1 parent 1e351ac commit 2a02afe
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 2 deletions.
7 changes: 7 additions & 0 deletions include/Planners/AlgorithmBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,13 @@ namespace Planners
*/
void addCollision(const Vec3i &coordinates_);

/**
* @brief Calls removeCollision for a given coordinate
*
* @param coordinates_ Discrete coordinates vector
*/
void removeCollision(const Vec3i &coordinates_);

/**
* @brief Function to use in the future to configure the cost of each node
*
Expand Down
25 changes: 25 additions & 0 deletions include/utils/world.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,31 @@ namespace utils

return setOccupied(_pos.x, _pos.y, _pos.z);
}

/**
* @brief Set the world's node associated
*
* @param _pos discrete node position vector
*/
void setUnoccupied(const int _x, const int _y, const int _z){

if (!checkValid(_x, _y, _z))
return;

discrete_world_vector_[getWorldIndex(_x, _y, _z)].occuppied = false;

}

/**
* @brief Set the world's node associated
*
* @param _pos discrete node position vector
*/
void setUnoccupied(const Vec3i &_pos){

return setUnoccupied(_pos.x, _pos.y, _pos.z);
}

/**
* @brief Checks the value of the internal flag of the node
* that is used to mark that the node is in the open list
Expand Down
2 changes: 1 addition & 1 deletion launch/local_planner.launch
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

<arg name="overlay_markers" default="false"/>

<arg name="cost_weight" default="4.0"/>
<arg name="cost_weight" default="500.0"/>
<arg name="max_line_of_sight_distance" default="2.0"/>+

<!-- GRIDM Generators Parameters -->
Expand Down
4 changes: 4 additions & 0 deletions src/Planners/AlgorithmBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ namespace Planners
{
addCollision(coordinates_, do_inflate_, inflate_steps_);
}
void AlgorithmBase::removeCollision(const Vec3i &coordinates_)
{
discrete_world_.setUnoccupied(coordinates_);
}
bool AlgorithmBase::detectCollision(const Vec3i &coordinates_)
{
if (discrete_world_.isOccupied(coordinates_))
Expand Down
3 changes: 3 additions & 0 deletions src/ROS/local_planner_ros_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,9 @@ class HeuristicLocalPlannerROS
0 <= global_path_local[it].y && global_path_local[it].y < m_local_grid3d_->m_gridSizeY &&
0 <= global_path_local[it].z && global_path_local[it].z < m_local_grid3d_->m_gridSizeZ)
{
local_goal.x = global_path_local[it].x;
local_goal.y = global_path_local[it].y;
local_goal.z = global_path_local[it].z;
it++;
}
else
Expand Down
4 changes: 3 additions & 1 deletion src/utils/ros/ROSInterfaces.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,10 @@ namespace Planners
{
float cost = _grid.getCellCost(i * resolution, j * resolution, k * resolution);
_algorithm.configureCellCost({i, j, k}, cost);
if(cost <= 0)
if(cost <= resolution)
_algorithm.addCollision({i, j, k});
else
_algorithm.removeCollision({i, j, k});
}
}
}
Expand Down

0 comments on commit 2a02afe

Please sign in to comment.