Corentin Chauvin-Hameau – 2019-2020
Coverage Path Planning for an underwater robot surveying a marine farm
robot_simulator.hpp
Go to the documentation of this file.
1 /**
2  * @file
3  *
4  * \brief Declaration of underwater robot simulator
5  * \author Corentin Chauvin-Hameau
6  * \date 2019
7  */
8 
9 #ifndef ROBOT_SIMULATOR_HPP
10 #define ROBOT_SIMULATOR_HPP
11 
13 #include "mf_robot_simulator/Command.h"
14 #include "mf_robot_simulator/CartesianCommand.h"
15 #include <geometry_msgs/Pose.h>
16 #include <ros/ros.h>
17 #include <vector>
18 
19 
20 namespace mfcpp {
21 
22 /**
23  * \brief Robot simulator
24  */
26  public:
29 
30  /**
31  * \brief Initialise the node and its parameters
32  */
33  void init_node();
34 
35  /**
36  * \brief Run the simulator
37  */
38  void run_node();
39 
40  /**
41  * \brief Display the current state
42  */
43  void disp_state();
44 
45  private:
46  // Private members
47  ros::NodeHandle nh_; ///< ROS node handler
48  ros::Subscriber control_input_sub_; ///< ROS subscriber for the control input
49  ros::Subscriber cart_input_sub_; ///< ROS subscriber for the debug cartesian control input
50  ros::Subscriber pose_input_sub_; ///< ROS subscriber for setting the pose
51  ros::Publisher odom_pub_; ///< ROS publisher for the odometry output
52  ros::Publisher state_pub_; ///< ROS publisher for the current state
53  ros::Publisher rviz_pub_; ///< ROS publisher for rviz markers
54  tf2_ros::TransformBroadcaster tf_br_; ///< Tf broadcaster
55 
56  RobotModel robot_model_; ///< Robot model
57  RobotModel::state_type state_; ///< Current state of the robot
58  RobotModel::input_type input_; ///< Current control input
59  std::vector<float> cart_input_; ///< Current debug cartesian control input
60 
61  /// \name ROS parameters
62  ///@{
63  float update_freq_; ///< State update frequency
64  std::string fixed_frame_; ///< Frame in which the pose is expressed
65  std::string robot_frame_; ///< Frame of the robot
66  float robot_length_; ///< Length of the robot (assuming cylindrical shape)
67  float robot_radius_; ///< Radius of the robot (assuming cylindrical shape)
68  int nbr_int_steps_; ///< Initial number of integration steps during the update
69  float bnd_delta_m_; ///< Bound on delta_m (ballast control)
70  RobotModel::input_type bnd_input_; ///< Bounds on the control input
71  ///@}
72 
73  /**
74  * \brief Callback for the control input
75  *
76  * \param Control input
77  */
78  void control_input_cb(const mf_robot_simulator::Command::ConstPtr &msg);
79 
80  /**
81  * \brief Callback for the debug cartesian control input
82  *
83  * \param Cartesian speed input
84  */
85  void cart_input_cb(const mf_robot_simulator::CartesianCommand::ConstPtr &msg);
86 
87  /**
88  * \brief Callback for setting the pose
89  *
90  * \param msg Pose in fixed frame
91  */
92  void pose_input_cb(const geometry_msgs::Pose::ConstPtr &msg);
93 
94  /**
95  * \brief Updates the robot state by integrating the ODE
96  *
97  * \param dt Duration of the update
98  */
99  void update_state(float dt);
100 
101  /**
102  * \brief Publishes the robot state
103  */
104  void publish_state();
105 
106 };
107 
108 
109 } // namespace mfcpp;
110 
111 #endif
float update_freq_
State update frequency.
Robot simulator.
Definition: common.hpp:23
Declaration of physical underwater robot model.
ros::Subscriber pose_input_sub_
ROS subscriber for setting the pose.
void init_node()
Initialise the node and its parameters.
ros::Publisher rviz_pub_
ROS publisher for rviz markers.
void control_input_cb(const mf_robot_simulator::Command::ConstPtr &msg)
Callback for the control input.
void pose_input_cb(const geometry_msgs::Pose::ConstPtr &msg)
Callback for setting the pose.
ros::Subscriber cart_input_sub_
ROS subscriber for the debug cartesian control input.
void run_node()
Run the simulator.
tf2_ros::TransformBroadcaster tf_br_
Tf broadcaster.
std::string fixed_frame_
Frame in which the pose is expressed.
std::vector< double > state_type
Data type of the state.
Definition: robot_model.hpp:51
int nbr_int_steps_
Initial number of integration steps during the update.
ros::Publisher state_pub_
ROS publisher for the current state.
RobotModel::input_type bnd_input_
void cart_input_cb(const mf_robot_simulator::CartesianCommand::ConstPtr &msg)
Callback for the debug cartesian control input.
Class defining the robot model.
Definition: robot_model.hpp:47
RobotModel::state_type state_
Current state of the robot.
std::vector< double > input_type
Data type of the input.
Definition: robot_model.hpp:54
void disp_state()
Display the current state.
void update_state(float dt)
Updates the robot state by integrating the ODE.
float bnd_delta_m_
Bound on delta_m (ballast control)
ros::Publisher odom_pub_
ROS publisher for the odometry output.
float robot_radius_
Radius of the robot (assuming cylindrical shape)
std::vector< float > cart_input_
Current debug cartesian control input.
void publish_state()
Publishes the robot state.
RobotModel robot_model_
Robot model.
ros::Subscriber control_input_sub_
ROS subscriber for the control input.
ros::NodeHandle nh_
ROS node handler.
RobotModel::input_type input_
Current control input.
float robot_length_
Length of the robot (assuming cylindrical shape)
std::string robot_frame_
Frame of the robot.