Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/smac planner include orientation flexibility #4127

Draft
wants to merge 51 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
e1b1f24
Include goal heading mode to allow bidirectional and all direction goals
stevedanomodolor Feb 14, 2024
d1c5627
Merge branch 'main' into feat/smac_planner_include_orientation_flexib…
stevedanomodolor Mar 25, 2024
cedfd53
reset controller server back to previous state
stevedanomodolor Mar 25, 2024
39be473
reset controller server back to previous stat: remove cycle duration
stevedanomodolor Mar 25, 2024
a3261a7
prune goals that are in collission
stevedanomodolor Mar 27, 2024
1eb23a7
Merge branch 'main' into feat/smac_planner_include_orientation_flexib…
stevedanomodolor Mar 28, 2024
10900a4
comment improvement
stevedanomodolor Apr 2, 2024
6659e8b
Merge branch 'feat/smac_planner_include_orientation_flexibility' of g…
stevedanomodolor Apr 2, 2024
67e3bf3
Merge branch 'ros-planning:main' into feat/smac_planner_include_orien…
stevedanomodolor Apr 3, 2024
5ac4d41
WIP
stevedanomodolor Apr 15, 2024
81c8ea8
WIP
stevedanomodolor Apr 15, 2024
49f1635
WIP
stevedanomodolor Apr 16, 2024
ea2c921
Improve ways in which we handle distance heuritis.
stevedanomodolor Apr 16, 2024
c0abe18
ensure that we remove the correct goal coordiate and split into nodet…
stevedanomodolor Apr 18, 2024
3675d48
removing param
stevedanomodolor Apr 23, 2024
4f10498
Merge branch 'main' into feat/smac_planner_include_orientation_flexib…
stevedanomodolor May 8, 2024
eff8859
increase test coverage
stevedanomodolor May 8, 2024
1a34ea3
Improvement based on review
stevedanomodolor May 14, 2024
bdffac3
Merge branch 'ros-navigation:main' into feat/smac_planner_include_ori…
stevedanomodolor Jun 1, 2024
232a1a7
wip
stevedanomodolor Oct 8, 2024
05262f5
fix bidirectional goal
stevedanomodolor Oct 8, 2024
14a1441
return config back to normal
stevedanomodolor Oct 10, 2024
5ce2c7e
remove duplicate vector
stevedanomodolor Oct 10, 2024
fe5dc61
code cleanup
stevedanomodolor Oct 10, 2024
3607b00
missing param
stevedanomodolor Oct 10, 2024
5939bf2
insert missing end of file newline
stevedanomodolor Oct 10, 2024
cd631f5
remove extra space
stevedanomodolor Oct 10, 2024
c0ac181
Update nav2_smac_planner/src/a_star.cpp
stevedanomodolor Oct 17, 2024
b18ba84
Update a_star.cpp
stevedanomodolor Oct 17, 2024
92e2ee8
Merge branch 'ros-navigation:main' into feat/smac_planner_include_ori…
stevedanomodolor Oct 18, 2024
66537c8
fix https://github.com/ros-navigation/navigation2/pull/4127\#discussi…
stevedanomodolor Nov 18, 2024
e06f1db
remove unnecessary local variable
stevedanomodolor Nov 18, 2024
d5a3776
dont need to break after throw
stevedanomodolor Nov 18, 2024
3acc50e
readd removed line
stevedanomodolor Nov 18, 2024
9419977
readd removed line
stevedanomodolor Nov 18, 2024
18dba40
move line of code out of loop
stevedanomodolor Nov 18, 2024
7c1f439
linter fixes
stevedanomodolor Nov 18, 2024
dd008b8
[RotationShimController] fix: rotate on short paths (#4716)
gennartan Oct 15, 2024
56b4975
Improve Docking panel (#4717)
ajtudela Oct 15, 2024
9d6e75a
Added parameter `rotate_to_heading_once` (#4721)
ikhann Oct 16, 2024
d81e157
[RotationShimController] fix: rotate to goal heading (#4724)
gennartan Oct 17, 2024
defa146
fix https://github.com/ros-navigation/navigation2/pull/4127\#discussi…
stevedanomodolor Nov 18, 2024
fd9d66f
remove unnecessary local variable
stevedanomodolor Nov 18, 2024
75a53aa
dont need to break after throw
stevedanomodolor Nov 18, 2024
1f03314
readd removed line
stevedanomodolor Nov 18, 2024
cdcabc9
readd removed line
stevedanomodolor Nov 18, 2024
124d163
move line of code out of loop
stevedanomodolor Nov 18, 2024
38b94ec
linter fixes
stevedanomodolor Nov 18, 2024
44ec788
include testing
stevedanomodolor Nov 18, 2024
18ef671
Merge branch 'feat/smac_planner_include_orientation_flexibility' of g…
stevedanomodolor Nov 18, 2024
a573dc3
include more testing
stevedanomodolor Nov 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 20 additions & 7 deletions nav2_smac_planner/include/nav2_smac_planner/a_star.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,15 @@
#ifndef NAV2_SMAC_PLANNER__A_STAR_HPP_
#define NAV2_SMAC_PLANNER__A_STAR_HPP_

#include <vector>
#include <iostream>
#include <unordered_map>
#include <unordered_set>
#include <functional>
#include <memory>
#include <queue>
#include <tuple>
#include <utility>
#include <vector>

#include "nav2_costmap_2d/costmap_2d.hpp"
#include "nav2_core/planner_exceptions.hpp"
Expand Down Expand Up @@ -49,6 +52,7 @@ class AStarAlgorithm
typedef NodeT * NodePtr;
typedef robin_hood::unordered_node_map<uint64_t, NodeT> Graph;
typedef std::vector<NodePtr> NodeVector;
typedef std::unordered_set<NodePtr> NodeSet;
typedef std::pair<float, NodeBasic<NodeT>> NodeElement;
typedef typename NodeT::Coordinates Coordinates;
typedef typename NodeT::CoordinateVector CoordinateVector;
Expand Down Expand Up @@ -90,6 +94,8 @@ class AStarAlgorithm
* or planning time exceeded
* @param max_planning_time Maximum time (in seconds) to wait for a plan, createPath returns
* false after this timeout
* @param lookup_table_size Size of the lookup table to store heuristic values
* @param dim_3_size Number of quantization bins
*/
void initialize(
const bool & allow_unknown,
Expand Down Expand Up @@ -129,7 +135,8 @@ class AStarAlgorithm
void setGoal(
const float & mx,
const float & my,
const unsigned int & dim_3);
const unsigned int & dim_3,
const GoalHeadingMode & goal_heading_mode = GoalHeadingMode::DEFAULT);

/**
* @brief Set the starting pose for planning, as a node index
Expand All @@ -155,10 +162,16 @@ class AStarAlgorithm
NodePtr & getStart();

/**
* @brief Get pointer reference to goal node
* @return Node pointer reference to goal node
* @brief Get pointer reference to goals node
* @return unordered_set of node pointers reference to the goals nodes
*/
NodeSet & getGoals();

/**
* @brief Get pointer reference to goals coordinates
* @return vector of goals coordinates reference to the goals coordinates
*/
NodePtr & getGoal();
CoordinateVector & getGoalsCoordinates();

/**
* @brief Get maximum number of on-approach iterations after within threshold
Expand Down Expand Up @@ -260,9 +273,9 @@ class AStarAlgorithm
unsigned int _dim3_size;
SearchInfo _search_info;

Coordinates _goal_coordinates;
CoordinateVector _goals_coordinates;
NodePtr _start;
NodePtr _goal;
NodeSet _goalsSet;

Graph _graph;
NodeQueue _queue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <functional>
#include <list>
#include <memory>
#include <unordered_set>
#include <string>
#include <vector>

Expand All @@ -35,7 +36,9 @@ class AnalyticExpansion
{
public:
typedef NodeT * NodePtr;
typedef std::unordered_set<NodePtr> NodeSet;
typedef typename NodeT::Coordinates Coordinates;
typedef typename NodeT::CoordinateVector CoordinateVector;
typedef std::function<bool (const uint64_t &, NodeT * &)> NodeGetter;

/**
Expand Down Expand Up @@ -79,16 +82,18 @@ class AnalyticExpansion
/**
* @brief Attempt an analytic path completion
* @param node The node to start the analytic path from
* @param goal The goal node to plan to
* @param goals_node set of goals node to plan to
* @param goals_coords vector of goal coordinates to plan to
* @param getter Gets a node at a set of coordinates
* @param iterations Iterations to run over
* @param best_cost Best heuristic cost to propertionally expand more closer to the goal
* @return Node pointer reference to goal node if successful, else
* return nullptr
* @return Node pointer reference to goal node with the best score out of the goals node if
* successful, else return nullptr
*/
NodePtr tryAnalyticExpansion(
const NodePtr & current_node,
const NodePtr & goal_node,
const NodeSet & goals_node,
const CoordinateVector & goals_coords,
const NodeGetter & getter, int & iterations, int & best_cost);

/**
Expand Down
35 changes: 35 additions & 0 deletions nav2_smac_planner/include/nav2_smac_planner/constants.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ enum class MotionModel
STATE_LATTICE = 4,
};

enum class GoalHeadingMode
{
UNKNOWN = 0,
DEFAULT = 1,
BIDIRECTIONAL = 2,
ALL_DIRECTION = 3,
};

inline std::string toString(const MotionModel & n)
{
switch (n) {
Expand Down Expand Up @@ -59,6 +67,33 @@ inline MotionModel fromString(const std::string & n)
}
}

inline std::string toString(const GoalHeadingMode & n)
{
switch (n) {
case GoalHeadingMode::DEFAULT:
return "DEFAULT";
case GoalHeadingMode::BIDIRECTIONAL:
return "BIDIRECTIONAL";
case GoalHeadingMode::ALL_DIRECTION:
return "ALL_DIRECTION";
default:
return "Unknown";
}
}

inline GoalHeadingMode fromStringToGH(const std::string & n)
{
if (n == "DEFAULT") {
return GoalHeadingMode::DEFAULT;
} else if (n == "BIDIRECTIONAL") {
return GoalHeadingMode::BIDIRECTIONAL;
} else if (n == "ALL_DIRECTION") {
return GoalHeadingMode::ALL_DIRECTION;
} else {
return GoalHeadingMode::UNKNOWN;
}
}

const float UNKNOWN_COST = 255.0;
const float OCCUPIED_COST = 254.0;
const float INSCRIBED_COST = 253.0;
Expand Down
22 changes: 21 additions & 1 deletion nav2_smac_planner/include/nav2_smac_planner/node_2d.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,16 @@ class Node2D
: x(x_in), y(y_in)
{}

inline bool operator==(const Coordinates & rhs) const
{
return this->x == rhs.x && this->y == rhs.y;
}

inline bool operator!=(const Coordinates & rhs) const
{
return !(*this == rhs);
}

float x, y;
};
typedef std::vector<Coordinates> CoordinateVector;
Expand All @@ -75,6 +85,15 @@ class Node2D
return this->_index == rhs._index;
}

/**
* @brief setting continuous coordinate search poses (in partial-cells)
* @param Pose pose
*/
inline void setPose(const Coordinates & pose_in)
{
pose = pose_in;
}

/**
* @brief Reset method for new search
*/
Expand Down Expand Up @@ -224,7 +243,7 @@ class Node2D
*/
static float getHeuristicCost(
const Coordinates & node_coords,
const Coordinates & goal_coordinates);
const CoordinateVector & goals_coords);

/**
* @brief Initialize the neighborhood to be used in A*
Expand Down Expand Up @@ -264,6 +283,7 @@ class Node2D
bool backtracePath(CoordinateVector & path);

Node2D * parent;
Coordinates pose;
static float cost_travel_multiplier;
static std::vector<int> _neighbors_grid_offsets;

Expand Down
6 changes: 3 additions & 3 deletions nav2_smac_planner/include/nav2_smac_planner/node_hybrid.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,12 @@ class NodeHybrid
: x(x_in), y(y_in), theta(theta_in)
{}

inline bool operator==(const Coordinates & rhs)
inline bool operator==(const Coordinates & rhs) const
{
return this->x == rhs.x && this->y == rhs.y && this->theta == rhs.theta;
}

inline bool operator!=(const Coordinates & rhs)
inline bool operator!=(const Coordinates & rhs) const
{
return !(*this == rhs);
}
Expand Down Expand Up @@ -371,7 +371,7 @@ class NodeHybrid
*/
static float getHeuristicCost(
const Coordinates & node_coords,
const Coordinates & goal_coordinates);
const CoordinateVector & goals_coords);

/**
* @brief Initialize motion models
Expand Down
6 changes: 3 additions & 3 deletions nav2_smac_planner/include/nav2_smac_planner/node_lattice.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ class NodeLattice
*/
static float getHeuristicCost(
const Coordinates & node_coords,
const Coordinates & goal_coordinates);
const CoordinateVector & goals_coords);

/**
* @brief Initialize motion models
Expand Down Expand Up @@ -408,8 +408,8 @@ class NodeLattice
bool backtracePath(CoordinateVector & path);

/**
* \brief add node to the path
* \param current_node
* @brief add node to the path
* @param current_node
*/
void addNodeToPath(NodePtr current_node, CoordinateVector & path);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ class SmacPlannerHybrid : public nav2_core::GlobalPlanner
bool _debug_visualizations;
std::string _motion_model_for_search;
MotionModel _motion_model;
GoalHeadingMode _goal_heading_mode;
rclcpp_lifecycle::LifecyclePublisher<nav_msgs::msg::Path>::SharedPtr _raw_plan_publisher;
rclcpp_lifecycle::LifecyclePublisher<visualization_msgs::msg::MarkerArray>::SharedPtr
_planned_footprints_publisher;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ class SmacPlannerLattice : public nav2_core::GlobalPlanner
_planned_footprints_publisher;
rclcpp_lifecycle::LifecyclePublisher<geometry_msgs::msg::PoseArray>::SharedPtr
_expansions_publisher;
GoalHeadingMode _goal_heading_mode;
std::mutex _mutex;
rclcpp_lifecycle::LifecycleNode::WeakPtr _node;

Expand Down
Loading
Loading