Corentin Chauvin-Hameau – 2019-2020
Coverage Path Planning for an underwater robot surveying a marine farm
planning_logic.hpp
Go to the documentation of this file.
1 /**
2  * @file
3  *
4  * \brief Declaration of a base class node managing high level planning logic
5  * \author Corentin Chauvin-Hameau
6  * \date 2020
7  */
8 
9 #ifndef PLANNING_LOGIC_HPP
10 #define PLANNING_LOGIC_HPP
11 
12 #include <nav_msgs/Path.h>
13 #include <nav_msgs/Odometry.h>
14 #include <geometry_msgs/PoseStamped.h>
15 #include <geometry_msgs/Pose.h>
16 #include <ros/ros.h>
17 #include <eigen3/Eigen/Dense>
18 #include <fstream>
19 #include <string>
20 #include <vector>
21 
22 
23 namespace mfcpp {
24 
25 /**
26  * \brief Base class for a node managing high level planning logic
27  *
28  * The planner alternates between hard-coded path for transitions between lines,
29  * and informative path planner to survey a wall.
30  */
32  public:
33  PlanningLogic();
35 
36  /**
37  * \brief Runs the node
38  */
39  void run_node();
40 
41  private:
42  // Private members
43  ros::NodeHandle nh_; ///< Node handler
44  ros::Subscriber odom_sub_; ///< Subscriber for robot's odometry
45  ros::Publisher path_pub_; ///< Publisher for a path
46  ros::ServiceClient disable_planner_client_; ///< Client for disabling the path planner
47  ros::ServiceClient enable_planner_client_; ///< Client for enabling the path planner
48 
49  nav_msgs::Odometry odom_; ///< Odometry of the robot
50  nav_msgs::Path path_; ///< Path to publish
51  bool odom_received_; ///< Whether the odometry has been received
52  bool path_loaded_; ///< Whether the path was loaded with success
53  bool transition_pts_loaded_; ///< Whether the transition points have been loaded
54  bool transition_; ///< Whether the robot is following a transition path
55  std::vector<Eigen::Vector3f> transition_pts_; ///< Points marking start and end of transition paths
56 
57  /// \name ROS parameters
58  ///@{
59  float main_freq_; ///< Main frequency
60  ///@}
61 
62 
63  /**
64  * \brief Initialises the node and its parameters
65  */
66  void init_node();
67 
68  /**
69  * \brief Loads a path from a text file
70  *
71  * The text file contains waypoints that are then interpolated by a spline.
72  *
73  * \param[in] file_name Relative path of the file containing the waypoints
74  * \param[in] resolution Spatial resolution of the path
75  * \param[out] path Loaded path
76  */
77  void load_path(std::string file_name, float resolution, nav_msgs::Path &path);
78 
79  /**
80  * \brief Loads the points delimiting the transitions
81  *
82  * \param file_name Relative path of the file containing the points
83  */
84  void load_transition_pts(std::string file_name);
85 
86  /**
87  * \brief Finds the closest pose in a path
88  *
89  * \param[in] path List of poses
90  * \param[in] pose Current pose
91  * \return Closest pose to `pose` in `path`
92  */
93  geometry_msgs::Pose find_closest(
94  const std::vector<geometry_msgs::PoseStamped> &path,
95  const geometry_msgs::Pose &pose
96  );
97 
98  /**
99  * \brief Callback for the odometry
100  */
101  void odom_cb(const nav_msgs::Odometry msg);
102 
103 };
104 
105 
106 } // namespace mfcpp
107 
108 #endif
Base class for a node managing high level planning logic.
Definition: common.hpp:23
void load_transition_pts(std::string file_name)
Loads the points delimiting the transitions.
bool transition_pts_loaded_
Whether the transition points have been loaded.
nav_msgs::Odometry odom_
Odometry of the robot.
std::vector< Eigen::Vector3f > transition_pts_
Points marking start and end of transition paths.
ros::ServiceClient enable_planner_client_
Client for enabling the path planner.
ros::Subscriber odom_sub_
Subscriber for robot&#39;s odometry.
void run_node()
Runs the node.
void odom_cb(const nav_msgs::Odometry msg)
Callback for the odometry.
void init_node()
Initialises the node and its parameters.
void load_path(std::string file_name, float resolution, nav_msgs::Path &path)
Loads a path from a text file.
ros::Publisher path_pub_
Publisher for a path.
bool transition_
Whether the robot is following a transition path.
ros::ServiceClient disable_planner_client_
Client for disabling the path planner.
bool odom_received_
Whether the odometry has been received.
ros::NodeHandle nh_
Node handler.
geometry_msgs::Pose find_closest(const std::vector< geometry_msgs::PoseStamped > &path, const geometry_msgs::Pose &pose)
Finds the closest pose in a path.
bool path_loaded_
Whether the path was loaded with success.
nav_msgs::Path path_
Path to publish.