Hybrid A* Planner
 All Classes Namespaces Files Functions Variables Friends Pages
path.h
1 #ifndef PATH_H
2 #define PATH_H
3 
4 #include <iostream>
5 #include <cstring>
6 #include <vector>
7 
8 #include <ros/ros.h>
9 #include <tf/transform_datatypes.h>
10 #include <nav_msgs/Path.h>
11 #include <geometry_msgs/PoseStamped.h>
12 #include <geometry_msgs/PoseArray.h>
13 #include <visualization_msgs/MarkerArray.h>
14 
15 #include "node3d.h"
16 #include "constants.h"
17 #include "helper.h"
18 namespace HybridAStar {
22 class Path {
23  public:
25  Path(bool smoothed = false) {
26  std::string pathTopic = "/path";
27  std::string pathNodesTopic = "/pathNodes";
28  std::string pathVehicleTopic = "/pathVehicle";
29 
30  if (smoothed) {
31  pathTopic = "/sPath";
32  pathNodesTopic = "/sPathNodes";
33  pathVehicleTopic = "/sPathVehicle";
34  this->smoothed = smoothed;
35  }
36 
37  // _________________
38  // TOPICS TO PUBLISH
39  pubPath = n.advertise<nav_msgs::Path>(pathTopic, 1);
40  pubPathNodes = n.advertise<visualization_msgs::MarkerArray>(pathNodesTopic, 1);
41  pubPathVehicles = n.advertise<visualization_msgs::MarkerArray>(pathVehicleTopic, 1);
42 
43  // CONFIGURE THE CONTAINER
44  path.header.frame_id = "path";
45  }
46 
47  // // __________
48  // // TRACE PATH
49  // /*!
50  // \brief Given a node pointer the path to the root node will be traced recursively
51  // \param node a 3D node, usually the goal node
52  // \param i a parameter for counting the number of nodes
53  // */
54  // void tracePath(const Node3D* node, int i = 0);
60  void updatePath(std::vector<Node3D> nodePath);
65  void addSegment(const Node3D& node);
71  void addNode(const Node3D& node, int i);
77  void addVehicle(const Node3D& node, int i);
78 
79  // ______________
80  // PUBLISH METHODS
81 
83  void clear();
85  void publishPath() { pubPath.publish(path); }
90 
91  private:
93  ros::NodeHandle n;
95  ros::Publisher pubPath;
97  ros::Publisher pubPathNodes;
99  ros::Publisher pubPathVehicles;
101  nav_msgs::Path path;
103  visualization_msgs::MarkerArray pathNodes;
105  visualization_msgs::MarkerArray pathVehicles;
107  bool smoothed = false;
108 };
109 }
110 #endif // PATH_H
void clear()
Clears the path.
Definition: path.cpp:10
A three dimensional node class that is at the heart of the algorithm.
Definition: node3d.h:14
This is a collection of constants that are used throughout the project.
Path(bool smoothed=false)
The default constructor initializing the path object and setting publishers for the same...
Definition: path.h:25
ros::NodeHandle n
A handle to the ROS node.
Definition: path.h:93
void addSegment(const Node3D &node)
Adds a segment to the path.
Definition: path.cpp:64
visualization_msgs::MarkerArray pathVehicles
Vehicle data structure for visualization.
Definition: path.h:105
visualization_msgs::MarkerArray pathNodes
Nodes data structure for visualization.
Definition: path.h:103
void publishPathNodes()
Publishes the nodes of the path.
Definition: path.h:87
void publishPath()
Publishes the path.
Definition: path.h:85
ros::Publisher pubPathVehicles
Publisher for the vehicle along the path.
Definition: path.h:99
bool smoothed
Value that indicates that the path is smoothed/post processed.
Definition: path.h:107
void publishPathVehicles()
Publishes the vehicle along the path.
Definition: path.h:89
void addNode(const Node3D &node, int i)
Adds a node to the path.
Definition: path.cpp:78
ros::Publisher pubPath
Publisher for the path as a spline.
Definition: path.h:95
void addVehicle(const Node3D &node, int i)
Adds a vehicle shape to the path.
Definition: path.cpp:110
ros::Publisher pubPathNodes
Publisher for the nodes on the path.
Definition: path.h:97
nav_msgs::Path path
Path data structure for visualization.
Definition: path.h:101
A class for tracing and visualizing the path generated by the Planner.
Definition: path.h:22
void updatePath(std::vector< Node3D > nodePath)
Given a node pointer the path to the root node will be traced recursively.
Definition: path.cpp:48
This is a collection of helper functions that are used throughout the project.