10 #ifndef PLANNING_NODELET_HPP 11 #define PLANNING_NODELET_HPP 15 #include "mf_common/Float32Array.h" 16 #include "mf_common/Float32Array.h" 17 #include "mf_common/Array2D.h" 18 #include <nav_msgs/Path.h> 19 #include <geometry_msgs/Pose.h> 20 #include <geometry_msgs/TransformStamped.h> 21 #include <std_srvs/Empty.h> 22 #include <tf2_ros/transform_listener.h> 23 #include <nodelet/nodelet.h> 138 void main_cb(
const ros::TimerEvent &timer_event);
162 const std::vector<std::vector<float>> &vector2D);
171 const std::vector<mf_common::Float32Array> &array);
180 const mf_common::Array2D &array);
213 float max_elev_angle,
242 std::vector<Lattice> &lattices
263 std::vector<Lattice> &lattices,
264 const geometry_msgs::TransformStamped &transform
276 const geometry_msgs::TransformStamped &frame_ocean_tf,
300 std::vector<Lattice> &lattices_in,
301 std::vector<Lattice> &lattices_out
328 const std::vector<Lattice> &lattices
341 std::vector<LatticeNode*> &selected_vp
351 const std::vector<Lattice> &lattices,
352 const std::vector<LatticeNode*> &selected_vp
365 const std::vector<geometry_msgs::Pose> &selected_vp,
366 nav_msgs::Path &path,
367 std::vector<geometry_msgs::Pose> &waypoints
380 const geometry_msgs::Pose &end,
float resolution);
391 const std::vector<geometry_msgs::Pose> &waypoints,
431 bool disable_cb(std_srvs::Empty::Request &req, std_srvs::Empty::Response &res);
436 bool enable_cb(std_srvs::Empty::Request &req, std_srvs::Empty::Response &res);
444 inline geometry_msgs::Pose
tf_to_pose(
const geometry_msgs::TransformStamped &transf);
451 const geometry_msgs::TransformStamped &transf
454 geometry_msgs::Pose pose;
455 pose.position.x = transf.transform.translation.x;
456 pose.position.y = transf.transform.translation.y;
457 pose.position.z = transf.transform.translation.z;
458 pose.orientation.x = transf.transform.rotation.x;
459 pose.orientation.y = transf.transform.rotation.y;
460 pose.orientation.z = transf.transform.rotation.z;
461 pose.orientation.w = transf.transform.rotation.w;
int nbr_lattices_
Number of lattices for multi-lattices planning.
float plan_horizon_
Horizon (m) of the planning (for each lattice)
static void sigint_handler(int s)
SINGINT (Ctrl+C) callback to stop the nodelet properly.
void compute_info_gain(Lattice &lattice)
Computes information gain over a lattice of viewpoint.
std::vector< float > x_hit_pt_sel_
X coordinates of the hit points for the selected viewpoint (in ocean frame)
bool vert_motion_
Whether to allow motion in the vertical plane.
geometry_msgs::TransformStamped robot_ocean_tf_
Transform from robot to ocean frames.
ros::Subscriber state_sub_
Subscriber for the state of the robot.
Declaration of physical underwater robot model.
float path_res_
Spatial resolution (m) of the planned trajectory.
geometry_msgs::TransformStamped wall_ocean_tf_
Transform from wall to ocean frames.
ros::Subscriber gp_mean_sub_
Subscriber for the mean of the Gaussian Process.
float wall_orientation_
Orientation of the wall (absolute value)
void generate_lattice(Lattice &lattice)
Fills a lattice of possible waypoints based on motion model.
float lattice_res_
Resolution (m) of the waypoints lattice.
bool compute_lattice_gp(Lattice &lattice, ros::Time stamp)
Computes the diagonal of the covariance for each viewpoint of the lattice.
bool enable_cb(std_srvs::Empty::Request &req, std_srvs::Empty::Response &res)
Service server callback to enable planning.
tf2_ros::Buffer tf_buffer_
Buffer for tf2.
std::string camera_frame_
Camera frame.
int camera_width_
Number of pixels of the camera along width (-1 for actual camera size)
ros::NodeHandle nh_
Node handler (for topics and services)
geometry_msgs::TransformStamped ocean_camera_tf_
Transform from ocean to camera frames.
Class to represent a lattice.
bool disable_cb(std_srvs::Empty::Request &req, std_srvs::Empty::Response &res)
Service server callback to disable planning.
nav_msgs::Path straight_line_path(const geometry_msgs::Pose &start, const geometry_msgs::Pose &end, float resolution)
Interpolates a straight line path between two poses.
void fill_display_obj(const std::vector< Lattice > &lattices, const std::vector< LatticeNode * > &selected_vp)
Fills display objects.
std::vector< std::vector< float > > array_to_vector2D(const std::vector< mf_common::Float32Array > &array)
Converts a custom ROS array to a 2D std vector.
tf2_ros::TransformListener tf_listener_
Transform listener for tf2.
std::vector< float > last_gp_mean_
Last mean of the Gaussian Process.
nav_msgs::Path path_
Interpolated path between the waypoints (in ocean frame)
Eigen::Vector3f get_wall_orientation()
Gets horizontal unit vector along the wall with same orientation as the robot.
void state_cb(const mf_common::Float32Array msg)
Callback for the state of the robot.
float main_freq_
Frequency of the main loop.
ros::Publisher path_pub_
Publisher for the path.
geometry_msgs::TransformStamped robot_wall_tf_
Transform from robot to wall frames.
void transform_lattices(std::vector< Lattice > &lattices, const geometry_msgs::TransformStamped &transform)
Apply a TF transform to all nodes of a set of lattices.
ros::NodeHandle private_nh_
Private node handler (for parameters)
std::vector< geometry_msgs::Pose > lattice_
Lattice of possible waypoints in ocean frame.
geometry_msgs::TransformStamped ocean_wall_tf_
Transform from ocean to wall frames.
bool plan_trajectory()
Main function to compute a trajectory plan.
std::vector< double > state_type
Data type of the state.
void gp_mean_cb(const mf_common::Float32ArrayConstPtr msg)
Callback for Gaussian Process mean.
void pub_lattice_markers()
Publishes the waypoints lattice markers.
ros::ServiceClient update_gp_client_
Service client for updating the Gaussian Process.
std::vector< geometry_msgs::Pose > waypoints_
Waypoints to follow (in ocean frame)
ros::Subscriber gp_cov_sub_
Subscriber for the covariance of the Gaussian Process.
std::vector< std::vector< float > > last_gp_cov_
Last covariance of the Gaussian Process.
void generate_cart_lattice(float max_lat_angle, float max_elev_angle, float horizon, float resolution, Lattice &lattice)
Fills a cartesian lattice of possible waypoints.
RobotModel::state_type state_
State of the robot (in ocean frame)
nav_msgs::Path spline_path(const std::vector< geometry_msgs::Pose > &waypoints, float resolution, float speed)
Interpolates a spline path between a list of poses.
geometry_msgs::Pose tf_to_pose(const geometry_msgs::TransformStamped &transf)
Converts a tf transform to a pose, assuming the frames correspond.
bool cart_lattice_
Whether to create a cartesian lattice, or use motion model instead.
std::vector< geometry_msgs::Pose > selected_vp_
Selected view points in the lattice (in ocean frame)
bool check_planning_needed()
Checks whether planning is needed or not.
bool horiz_motion_
Whether to allow motion in the horizontal plane.
std::vector< float > bnd_depth_
Bounds on the depth (in wall frame) for waypoint selection.
std::vector< float > z_hit_pt_sel_
Z coordinates of the hit points for the selected viewpoint (in ocean frame)
std::vector< float > y_hit_pt_sel_
Y coordinates of the hit points for the selected viewpoint (in ocean frame)
std::string ocean_frame_
Ocean frame.
std::vector< LatticeNode * > select_viewpoints(const std::vector< Lattice > &lattices)
Selects a sequence of viewpoints maximising information gain over a list of lattices.
Class defining the robot model.
float max_elev_rudder_
Maximum angle of the elevation rudder.
ros::ServiceClient ray_multi_client_
Service client for raycasting at several camera poses.
static sig_atomic_t volatile b_sigint_
Whether SIGINT signal has been received.
virtual void onInit()
Function called at beginning of nodelet execution.
geometry_msgs::TransformStamped wall_robot_tf_
Transform from wall to robot frames.
static ros::Timer main_timer_
Timer callback for the main function.
RobotModel robot_model_
Robot model.
void add_node(const RobotModel::state_type &state, const geometry_msgs::TransformStamped &frame_ocean_tf, Lattice &lattice)
Adds a node given by its state to a lattice.
void connect_lattices(const RobotModel::state_type &init_state, std::vector< Lattice > &lattices_in, std::vector< Lattice > &lattices_out)
Connects lattices and removes viewpoints not dynamically reachable.
int lattice_size_vert_
Size of the lattice in the vertical direction (half size when single-lattice planning) ...
int lattice_size_horiz_
Size of the lattice in the horizontal direction (half size when single-lattice planning) ...
std::string wall_frame_
Wall frame.
bool linear_path_
Whether to create a linear path, or a spline one.
int camera_height_
Number of pixels of the camera along height (-1 for actual camera size)
float plan_speed_
Planned speed (m/s) of the robot.
void generate_lattices(const RobotModel::state_type &init_state, std::vector< Lattice > &lattices)
Generates several lattices along the wall.
std::string robot_frame_
Robot frame.
float max_lat_rudder_
Maximum angle of the lateral rudder.
bool get_tf()
Gets tf transforms.
bool planner_enabled_
Whether the planner should run.
bool replan_
Whether to replan from the current robot pose, or to plan from the last planned pose.
std::vector< mf_common::Float32Array > vector2D_to_array(const std::vector< std::vector< float >> &vector2D)
Converts a 2D std vector to a custom ROS array.
ros::ServiceServer disable_serv_
Service server to disable planning.
bool state_received_
Whether the state of the robot has been received.
ros::Publisher lattice_pub_
Publisher for the waypoints lattice.
bool mult_lattices_
Whether to use multi-lattices planning.
Declaration of useful classes for planning with lattices.
geometry_msgs::TransformStamped ocean_robot_tf_
Transform from ocean to robot frames.
Nodelet for path planning of an underwater robot surveying a marine farm.
void main_cb(const ros::TimerEvent &timer_event)
Main callback which is called by a timer.
ros::ServiceServer enable_serv_
Service server to enable planning.
Class to represent a node (viewpoint) of a lattice.
void gp_cov_cb(const mf_common::Array2DConstPtr msg)
Callback for Gaussian Process covariance.
ros::Publisher lattice_pose_pub_
Publisher for the waypoints lattice poses.
void filter_lattice(Lattice &lattice_in, Lattice &lattice_out)
Filters out waypoints that are not in given bounds.
std::vector< float > bnd_wall_dist_
Bounds on the distance to the wall for waypoint selection.
void generate_path(const std::vector< geometry_msgs::Pose > &selected_vp, nav_msgs::Path &path, std::vector< geometry_msgs::Pose > &waypoints)
Generates a spline trajectory between the selected points.