9 #ifndef FARM_NODELET_HPP 10 #define FARM_NODELET_HPP 14 #include "mf_farm_simulator/FarmSimulatorConfig.h" 16 #include <visualization_msgs/Marker.h> 17 #include <visualization_msgs/MarkerArray.h> 18 #include <dynamic_reconfigure/server.h> 19 #include <nodelet/nodelet.h> 51 dynamic_reconfigure::Server<mf_farm_simulator::FarmSimulatorConfig>
reconf_srv_;
109 void main_cb(
const ros::TimerEvent& timer_event);
122 void reconfigure_cb(mf_farm_simulator::FarmSimulatorConfig &config,
138 void init_cb(
const ros::TimerEvent &timer_event);
258 std::vector<std::vector<float>> img,
259 const std::vector<tf2::Vector3> &coord)
const;
271 std::normal_distribution<T> distribution(mu, sigma);
279 std::uniform_real_distribution<T> distribution(a, b);
286 std::bernoulli_distribution distribution(p);
ros::NodeHandle private_nh_
Private node handler (for parameters)
float std_width_algae_
Standard deviation on algae width.
float buoys_diameter_
Diameter (m) of each buoy.
int nbr_lines_
Number of algae lines.
Declaration of 2D perlin noise generator.
T rand_gaussian(T mu, T sigma)
Draw a random number from a Gaussian distribution.
ros::Publisher rviz_pub_
ROS publisher for Rviz.
std::mt19937 random_generator_
Random number initialiser.
float anchors_diameter_
Diameter (m) of the cylindrical anchors.
float offset_lines_
Lateral distance (m) between each line.
float bnd_gamma_lines_
Bound such that gamma is sampled in [mean-bnd, mean+bnd].
int height_disease_heatmap_
Height of the algae disease heatmap.
PerlinNoiseGenerator perlin_
For randomising the heatmaps.
float std_length_algae_
Standard deviation on algae length.
bool reconfigure_initialised_
Whether the dynamic reconfigure callback has been called once.
Declaration of common structures and functions for farm simulator.
void init_algae_lines()
Initialise the algae lines.
Arguments used to create a Rviz maker.
void pub_rviz_markers(float duration) const
Displays objects by publishing Rviz markers.
ros::NodeHandle nh_
Node handler (for topics and services)
void pub_algae()
Publishes the position and heatmap of the algae.
float bnd_phi_lines_
Bound such that phi is sampled in [mean-bnd, mean+bnd].
float depth_lines_
Distance (m) between water surface and line.
int nbr_buoys_
Number of buoys on each floating rope.
float anchors_height_
Height (m) of the cylindrical anchors.
int width_disease_heatmap_
Width of the algae disease heatmap.
float phi_lines_
Mean of phi angle for algae line generation.
Declaration of common Rviz display functions.
float psi_algae_
Mean of the algae orientation.
float thickness_algae_
Thickness of an alga (for collision detection)
void pop_img_marker(visualization_msgs::Marker &marker, std::vector< std::vector< float >> img, const std::vector< tf2::Vector3 > &coord) const
Populates a triangle marker for displaying images.
bool randomise_algae_
Whether to randomise size and orientation of algae.
float theta_lines_
Mean of theta angle for algae line generation.
bool randomise_lines_
Whether to randomise the position of each line.
void reconfigure_cb(mf_farm_simulator::FarmSimulatorConfig &config, uint32_t level)
Callback for dynamic reconfigure.
float alga_miss_rate_
Probability to have a missing alga.
std::random_device random_device_
Seed initialiser for random number generation.
float main_loop_freq_
Frequency of the main loop.
void main_cb(const ros::TimerEvent &timer_event)
Main callback which is called by a timer.
bool disp_disease_
Whether to display the disease heatmaps.
void init_anchors(AlgaeLine &line, unsigned int i)
Init anchors of a specific algae line.
void pop_algae_marker(visualization_msgs::Marker &marker, MarkerArgs args) const
Populates a marker for displaying the algae.
int height_grid_heatmap_
Height of the grid for perlin noise generation.
int nbr_algae_
Number of algae per line.
float depth_water_
Distance (m) between water surface and seafloor.
float width_algae_
Mean of the width of an alga.
void pop_algae_heatmaps(visualization_msgs::Marker &marker, MarkerArgs args) const
Populates a marker for displaying the disease heatmaps.
void pop_buoys_marker(visualization_msgs::Marker &marker, MarkerArgs args) const
Populates a marker for displaying the buoys.
virtual void onInit()
Function called at beginning of nodelet execution.
std::vector< AlgaeLine > algae_lines_
Vector of all the algae in the farm.
float thickness_ropes_
Diameter (m) of each line.
void pop_ropes_marker(visualization_msgs::Marker &marker, MarkerArgs args) const
Populates a marker for displaying the ropes.
float length_lines_
Length (m) of each line.
int random_seed_
Seed for random numbers (0 for random seed)
static ros::Timer main_timer_
Timer callback for the main function.
ros::Publisher algae_pub_
ROS publisher for the algae.
void init_cb(const ros::TimerEvent &timer_event)
Callback for the oneshot initialisation timer.
float disease_ratio_
Ratio of alga disease (0->fully sane, 1->fully sick)
Line on which algae grow.
void init_ropes(AlgaeLine &line)
Init ropes of an algae line.
float length_algae_
Mean of the length of an alga.
float std_psi_algae_
Standard deviation on algae orientation.
T rand_uniform(T a, T b)
Draw a random number from a uniform distribution.
static void sigint_handler(int s)
SINGINT (Ctrl+C) callback to stop the nodelet properly.
static ros::Timer init_timer_
Timer callback for the init function.
Nodelet class for farm simulation.
dynamic_reconfigure::Server< mf_farm_simulator::FarmSimulatorConfig > reconf_srv_
Dynamic reconfigure server.
static sig_atomic_t volatile b_sigint_
Whether SIGINT signal has been received.
bool init_done_
Whether the farm initialisation has been done.
void init_algae(AlgaeLine &line)
Init algae of an algae line.
float bnd_theta_lines_
Bound such that theta is sampled in [mean-bnd, mean+bnd].
bool rand_bernoulli(double p)
Draw a random number from a bernoulli distribution.