Skip to content

Commit

Permalink
prune reposity
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhanyuGuo committed Jun 1, 2023
1 parent 09f135c commit a39c766
Show file tree
Hide file tree
Showing 36 changed files with 354 additions and 4,275 deletions.
Binary file added assets/a_star_ros.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/cover.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/d_star_lite_ros.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/d_star_ros.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/d_star_ros_old.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/demo.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/dijkstra_ros.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/dwa_ros.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/gbfs_ros.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/informed_rrt_ros.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/jps_ros.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/lpa_star_ros.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/pid_ros.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/rrt_connect_ros.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/rrt_ros.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/rrt_star_ros.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class JumpPointSearch : public global_planner::GlobalPlanner
* @param resolution costmap resolution
*/
JumpPointSearch(int nx, int ny, double resolution);

/**
* @brief Jump Point Search(JPS) implementation
* @param costs costmap
Expand All @@ -46,6 +47,7 @@ class JumpPointSearch : public global_planner::GlobalPlanner
*/
bool plan(const unsigned char* gloal_costmap, const Node& start, const Node& goal, std::vector<Node>& path,
std::vector<Node>& expand);

/**
* @brief detect whether current node has forced neighbor or not
* @param point current node
Expand All @@ -63,10 +65,8 @@ class JumpPointSearch : public global_planner::GlobalPlanner
Node jump(const Node& point, const Node& motion);

private:
// start and goal node
Node start_, goal_;
// costmap
const unsigned char* costs_;
Node start_, goal_; // start and goal node
const unsigned char* costs_; // costmap
};
} // namespace jps_planner
}
#endif // JUMP_POINT_SEARCH_H
46 changes: 23 additions & 23 deletions src/planner/global_planner/graph_planner/src/jump_point_search.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ bool JumpPointSearch::plan(const unsigned char* gloal_costmap, const Node& start
std::vector<Node>& path, std::vector<Node>& expand)
{
// copy
this->costs_ = gloal_costmap;
this->start_ = start, this->goal_ = goal;
costs_ = gloal_costmap;
start_ = start, goal_ = goal;

// open list
std::priority_queue<Node, std::vector<Node>, compare_cost> open_list;
Expand Down Expand Up @@ -71,15 +71,15 @@ bool JumpPointSearch::plan(const unsigned char* gloal_costmap, const Node& start
if (current == goal)
{
closed_list.insert(current);
path = this->_convertClosedListToPath(closed_list, start, goal);
path = _convertClosedListToPath(closed_list, start, goal);
return true;
}

// explore neighbor of current node
std::vector<Node> jp_list;
for (const auto& motion : motions)
{
Node jp = this->jump(current, motion);
Node jp = jump(current, motion);

// exists and not in CLOSED set
if (jp.id_ != -1 && closed_list.find(jp) == closed_list.end())
Expand Down Expand Up @@ -121,33 +121,33 @@ bool JumpPointSearch::detectForceNeighbor(const Node& point, const Node& motion)
// horizontal
if (x_dir && !y_dir)
{
if (this->costs_[this->grid2Index(x, y + 1)] >= this->lethal_cost_ * this->factor_ &&
this->costs_[this->grid2Index(x + x_dir, y + 1)] < this->lethal_cost_ * this->factor_)
if (costs_[grid2Index(x, y + 1)] >= lethal_cost_ * factor_ &&
costs_[grid2Index(x + x_dir, y + 1)] < lethal_cost_ * factor_)
return true;
if (this->costs_[this->grid2Index(x, y - 1)] >= this->lethal_cost_ * this->factor_ &&
this->costs_[this->grid2Index(x + x_dir, y - 1)] < this->lethal_cost_ * this->factor_)
if (costs_[grid2Index(x, y - 1)] >= lethal_cost_ * factor_ &&
costs_[grid2Index(x + x_dir, y - 1)] < lethal_cost_ * factor_)
return true;
}

// vertical
if (!x_dir && y_dir)
{
if (this->costs_[this->grid2Index(x + 1, y)] >= this->lethal_cost_ * this->factor_ &&
this->costs_[this->grid2Index(x + 1, y + y_dir)] < this->lethal_cost_ * this->factor_)
if (costs_[grid2Index(x + 1, y)] >= lethal_cost_ * factor_ &&
costs_[grid2Index(x + 1, y + y_dir)] < lethal_cost_ * factor_)
return true;
if (this->costs_[this->grid2Index(x - 1, y)] >= this->lethal_cost_ * this->factor_ &&
this->costs_[this->grid2Index(x - 1, y + y_dir)] < this->lethal_cost_ * this->factor_)
if (costs_[grid2Index(x - 1, y)] >= lethal_cost_ * factor_ &&
costs_[grid2Index(x - 1, y + y_dir)] < lethal_cost_ * factor_)
return true;
}

// diagonal
if (x_dir && y_dir)
{
if (this->costs_[this->grid2Index(x - x_dir, y)] >= this->lethal_cost_ * this->factor_ &&
this->costs_[this->grid2Index(x - x_dir, y + y_dir)] < this->lethal_cost_ * this->factor_)
if (costs_[grid2Index(x - x_dir, y)] >= lethal_cost_ * factor_ &&
costs_[grid2Index(x - x_dir, y + y_dir)] < lethal_cost_ * factor_)
return true;
if (this->costs_[this->grid2Index(x, y - y_dir)] >= this->lethal_cost_ * this->factor_ &&
this->costs_[this->grid2Index(x + x_dir, y - y_dir)] < this->lethal_cost_ * this->factor_)
if (costs_[grid2Index(x, y - y_dir)] >= lethal_cost_ * factor_ &&
costs_[grid2Index(x + x_dir, y - y_dir)] < lethal_cost_ * factor_)
return true;
}

Expand All @@ -163,16 +163,16 @@ bool JumpPointSearch::detectForceNeighbor(const Node& point, const Node& motion)
Node JumpPointSearch::jump(const Node& point, const Node& motion)
{
Node new_point = point + motion;
new_point.id_ = this->grid2Index(new_point.x_, new_point.y_);
new_point.id_ = grid2Index(new_point.x_, new_point.y_);
new_point.pid_ = point.id_;
new_point.h_ = std::sqrt(std::pow(new_point.x_ - this->goal_.x_, 2) + std::pow(new_point.y_ - this->goal_.y_, 2));
new_point.h_ = std::sqrt(std::pow(new_point.x_ - goal_.x_, 2) + std::pow(new_point.y_ - goal_.y_, 2));

// next node hit the boundary or obstacle
if (new_point.id_ < 0 || new_point.id_ >= this->ns_ || this->costs_[new_point.id_] >= this->lethal_cost_ * this->factor_)
if (new_point.id_ < 0 || new_point.id_ >= ns_ || costs_[new_point.id_] >= lethal_cost_ * factor_)
return Node(-1, -1, -1, -1, -1, -1);

// goal found
if (new_point == this->goal_)
if (new_point == goal_)
return new_point;

// diagonal
Expand All @@ -181,14 +181,14 @@ Node JumpPointSearch::jump(const Node& point, const Node& motion)
// if exists jump point at horizontal or vertical
Node x_dir = Node(motion.x_, 0, 1, 0, 0, 0);
Node y_dir = Node(0, motion.y_, 1, 0, 0, 0);
if (this->jump(new_point, x_dir).id_ != -1 || this->jump(new_point, y_dir).id_ != -1)
if (jump(new_point, x_dir).id_ != -1 || jump(new_point, y_dir).id_ != -1)
return new_point;
}

// exists forced neighbor
if (this->detectForceNeighbor(new_point, motion))
if (detectForceNeighbor(new_point, motion))
return new_point;
else
return this->jump(new_point, motion);
return jump(new_point, motion);
}
} // namespace jps_planner
11 changes: 6 additions & 5 deletions src/planner/global_planner/sample_planner/include/informed_rrt.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class InformedRRT : public RRTStar
* @param r optimization radius
*/
InformedRRT(int nx, int ny, double resolution, int sample_num, double max_dist, double r);

/**
* @brief RRT implementation
* @param costs costmap
Expand All @@ -47,11 +48,6 @@ class InformedRRT : public RRTStar
std::vector<Node>& expand);

protected:
// best planning cost
double c_best_;
// distance between start and goal
double c_min_;

/**
* @brief Sample in ellipse
* @param x random sampling x
Expand All @@ -65,6 +61,11 @@ class InformedRRT : public RRTStar
* @return Generated node
*/
Node _generateRandomNode();

protected:
double c_best_; // best planning cost
double c_min_; // distance between start and goal

};
} // namespace rrt_planner
#endif
13 changes: 5 additions & 8 deletions src/planner/global_planner/sample_planner/include/rrt.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,16 +92,13 @@ class RRT : public global_planner::GlobalPlanner
*/
double _angle(const Node& node1, const Node& node2);

// costmap copy
const unsigned char* costs_;
// start and goal node copy
Node start_, goal_;
protected:
const unsigned char* costs_; // costmap copy
Node start_, goal_; // start and goal node copy
// set of sample nodes
std::unordered_set<Node, NodeIdAsHash, compare_coordinates> sample_list_;
// max sample number
int sample_num_;
// max distance threshold
double max_dist_;
int sample_num_; // max sample number
double max_dist_; // max distance threshold
};
} // namespace rrt_planner
#endif // RRT_H
13 changes: 8 additions & 5 deletions src/planner/global_planner/sample_planner/include/rrt_connect.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class RRTConnect : public RRT
* @param max_dist max distance between sample points
*/
RRTConnect(int nx, int ny, double resolution, int sample_num, double max_dist);

/**
* @brief RRT implementation
* @param costs costmap
Expand All @@ -46,17 +47,19 @@ class RRTConnect : public RRT
std::vector<Node>& expand);

protected:
// Sampled list forward
std::unordered_set<Node, NodeIdAsHash, compare_coordinates> sample_list_f_;
// Sampled list backward
std::unordered_set<Node, NodeIdAsHash, compare_coordinates> sample_list_b_;

/**
* @brief convert closed list to path
* @param boundary connected node that the boudary of forward and backward
* @return ector containing path nodes
*/
std::vector<Node> _convertClosedListToPath(const Node& boundary);

protected:
// Sampled list forward
std::unordered_set<Node, NodeIdAsHash, compare_coordinates> sample_list_f_;
// Sampled list backward
std::unordered_set<Node, NodeIdAsHash, compare_coordinates> sample_list_b_;

};
} // namespace rrt_planner

Expand Down
3 changes: 2 additions & 1 deletion src/planner/global_planner/sample_planner/include/rrt_star.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ class RRTStar : public RRT
*/
Node _findNearestPoint(std::unordered_set<Node, NodeIdAsHash, compare_coordinates> list, Node& node);

double r_;
protected:
double r_; // optimization radius
};
} // namespace rrt_planner
#endif // RRT_H
Loading

0 comments on commit a39c766

Please sign in to comment.