Corentin Chauvin-Hameau – 2019-2020
Coverage Path Planning for an underwater robot surveying a marine farm
gp_nodelet.hpp
Go to the documentation of this file.
1 /**
2  * @file
3  *
4  * \brief Declaration of a nodelet for Gaussian Process mapping of an
5  * algae wall
6  * \author Corentin Chauvin-Hameau
7  * \date 2019
8  */
9 
10 #ifndef GP_NODELET_HPP
11 #define GP_NODELET_HPP
12 
13 #include "mf_mapping/UpdateGP.h"
14 #include "mf_mapping/LoadGP.h"
15 #include "mf_sensors_simulator/CameraOutput.h"
16 #include <tf2_ros/transform_listener.h>
17 #include <nodelet/nodelet.h>
18 #include <ros/ros.h>
19 #include <eigen3/Eigen/Dense>
20 #include <csignal>
21 #include <cmath>
22 #include <string>
23 #include <vector>
24 
25 
26 namespace mfcpp {
27 
28 
29 /**
30  * \brief Nodelet for a Gaussian Process mapping an algae wall
31  */
32 class GPNodelet: public nodelet::Nodelet {
33  public:
34  GPNodelet();
35  ~GPNodelet();
36 
37  /**
38  * \brief Function called at beginning of nodelet execution
39  */
40  virtual void onInit();
41 
42  private:
43  /**
44  * \brief 2D rectangular area
45  *
46  * \param min_x Minimal x coordinate
47  * \param max_x Maximal x coordinate
48  * \param min_y Minimal y coordinate
49  * \param max_y Maximal y coordinate
50  */
51  struct RectArea {
52  float min_x;
53  float max_x;
54  float min_y;
55  float max_y;
56  };
57 
58  // Typedefs
59  typedef std::vector<float> vec_f;
60 
61  // Static members
62  // Note: the timers need to be static since stopped by the SIGINT callback
63  static sig_atomic_t volatile b_sigint_; ///< Whether SIGINT signal has been received
64  static ros::Timer main_timer_; ///< Timer callback for the main function
65 
66  // Private members
67  ros::NodeHandle nh_; ///< Node handler (for topics and services)
68  ros::NodeHandle private_nh_; ///< Private node handler (for parameters)
69  ros::Subscriber camera_sub_; ///< Subscriber for the camera
70  ros::Publisher wall_img_pub_; ///< Publisher for an image of the wall GP
71  ros::Publisher cov_img_pub_; ///< Publisher for an image of the GP covariance
72  ros::Publisher gp_mean_pub_; ///< Publisher for the GP mean
73  ros::Publisher gp_cov_pub_; ///< Publisher for the GP covariance
74  ros::Publisher gp_eval_pub_; ///< Publisher for the evaluated GP over the wall
75  ros::ServiceServer update_gp_serv_; ///< Service server for updating the GP
76  ros::ServiceServer load_gp_serv_; ///< Service server for loading the GP
77  tf2_ros::Buffer tf_buffer_; ///< Tf2 buffer for getting tf transforms
78  tf2_ros::TransformListener tf_listener_; ///< Tf2 listener for getting tf transforms
79 
80  bool gp_initialised_; ///< Whether the Gaussian Process is initialised
81  bool gp_loaded_; ///< Whether the GP has been loaded from an external source
82  bool camera_msg_available_; ///< Whether a new camera message is available
83  bool tf_got_; ///< Whether transforms have been retrieved
84  mf_sensors_simulator::CameraOutput::ConstPtr camera_msg_; ///< Last camera message
85  float delta_x_; ///< Increment (m) in the x direction
86  float delta_y_; ///< Increment (m) in the y direction
87  unsigned int size_gp_; ///< Total size of the Gaussian Process
88  unsigned int size_img_; ///< Total size of the image
89  geometry_msgs::TransformStamped wall_camera_tf_; // Transform from wall to camera frames
90  float radius_obs_; ///< Radius of influence of an observation on the GP
91 
92  Eigen::VectorXf gp_mean_; ///< Mean of the Gaussian Process
93  Eigen::MatrixXf gp_cov_; ///< Covariance of the Gaussian Process
94  Eigen::MatrixXf gp_C_; ///< Covariance of the values of the mean of the GP
95  Eigen::MatrixXf gp_C_inv_; ///< Inverse of gp_C_
96  std::vector<unsigned int> idx_obs_; ///< Array of corresponding indices for observed states
97  Eigen::VectorXf x_coord_; ///< X coordinates of the state on the wall
98  Eigen::VectorXf y_coord_; ///< Y coordinates of the state on the wall
99  std::vector<float> out_values_; ///< Output values of the Gaussian Process
100  std::vector<bool> changed_pxl_; ///< Whether an output pixel has been updated
101 
102  /// \name ROS parameters
103  ///@{
104  float main_freq_; ///< Frequency of the main loop
105  std::string wall_frame_; ///< Name of the wall frame
106  std::string camera_frame_; ///< Name of the camera frame
107 
108  float camera_var_; ///< Max variance on camera measurements
109  float camera_decay_; ///< Exponential decay rate on camera measurements
110 
111  float matern_length_; ///< Lengthscale of the Matern kernel
112  float matern_var_; ///< Signal variance of the Matern kernel
113  float matern_thresh_; ///< Threshold to consider that the kernel value is 0
114  float gp_init_mean_; ///< Initial mean values of the Gaussian Process
115  float gp_noise_var_; ///< Noise variance of the Gaussian Process
116  float gp_cov_thresh_; ///< Threshold to consider a value as 0 in the covariance
117  float out_scale_; ///< Exponential scale factor for the output
118  ///< (higher value implies sharper transition between 0 and 1)
119 
120  float size_wall_x_; ///< Size (m) of the algae wall in the x direction
121  float size_wall_y_; ///< Size (m) of the algae wall in the y direction
122  int size_gp_x_; ///< Size of the Gaussian Process mean in the x direction
123  int size_gp_y_; ///< Size of the Gaussian Process mean in the y direction
124  int size_img_x_; ///< Size of the output image in the x direction
125  int size_img_y_; ///< Size of the output image in the y direction
126  ///@}
127 
128  /**
129  * \brief Main callback which is called by a timer
130  *
131  * \param timer_event Timer event information
132  */
133  void main_cb(const ros::TimerEvent &timer_event);
134 
135  /**
136  * \brief Gets necessary tf transforms
137  *
138  * \return Whether the transforms could be retrieved
139  */
140  bool get_tf();
141 
142  /**
143  * \brief SINGINT (Ctrl+C) callback to stop the nodelet properly
144  */
145  static void sigint_handler(int s);
146 
147  /**
148  * \brief Callback for the camera output
149  *
150  * \param msg Pointer to the camera message
151  */
152  void camera_cb(const mf_sensors_simulator::CameraOutputConstPtr &msg);
153 
154  /**
155  * \brief Service to update the Gaussian Process for several sets of measurements
156  */
157  bool update_gp_cb(mf_mapping::UpdateGP::Request &req,
158  mf_mapping::UpdateGP::Response &res);
159 
160  /**
161  * \brief Service to load the Gaussian Process mean
162  */
163  bool load_gp_cb(mf_mapping::LoadGP::Request &req,
164  mf_mapping::LoadGP::Response &res);
165 
166  /**
167  * \brief Transforms points from one frame to another
168  *
169  * \param[in] x_in X coordinate of the input points
170  * \param[in] y_in Y coordinate of the input points
171  * \param[in] z_in Z coordinate of the input points
172  * \param[out] x_out X coordinate of the transformed points
173  * \param[out] y_out Y coordinate of the transformed points
174  * \param[out] z_out Z coordinate of the transformed points
175  * \param[in] frame_in Frame of the input points
176  * \param[in] frame_out Frame of the output points
177  *
178  * \return Whether the points could be transformed
179  */
180  bool transform_points(const vec_f &x_in, const vec_f &y_in, const vec_f &z_in,
181  vec_f &x_out, vec_f &y_out, vec_f &z_out,
182  std::string frame_in, std::string frame_out);
183 
184  /**
185  * \brief Transforms points from one frame to another
186  *
187  * \param[in] x_in X coordinate of the input points
188  * \param[in] y_in Y coordinate of the input points
189  * \param[in] z_in Z coordinate of the input points
190  * \param[out] x_out X coordinate of the transformed points
191  * \param[out] y_out Y coordinate of the transformed points
192  * \param[out] z_out Z coordinate of the transformed points
193  * \param[in] transform Transform to apply
194  *
195  * \return Whether the points could be transformed
196  */
197  bool transform_points(const vec_f &x_in, const vec_f &y_in, const vec_f &z_in,
198  vec_f &x_out, vec_f &y_out, vec_f &z_out,
199  const geometry_msgs::TransformStamped &transform);
200 
201  /**
202  * \brief Initialises the Gaussian Process
203  */
204  void init_gp();
205 
206  /**
207  * \brief Camera sensor noise model
208  *
209  * Computes the variance on a camera measurement. The variance depends on
210  * the distance of the measured point: the greater the distance, the greater
211  * the variance is.
212  *
213  * \param distance Distance between the measured point and the camera origin
214  */
215  inline float camera_noise(float distance) const;
216 
217  /**
218  * \brief Matern 3/2 kernel function
219  *
220  * \param x1 X coordinate of the first point
221  * \param y1 Y coordinate of the first point
222  * \param x2 X coordinate of the second point
223  * \param y2 Y coordinate of the second point
224  */
225  inline double matern_kernel(double x1, double y1, double x2, double y2) const;
226 
227  /**
228  * \brief Populates indices correspondance for reordered states
229  *
230  * Used to reorder the state by putting observed states at the beginning
231  * and not observed states at the end.
232  *
233  * \param[in] size_obs Size of the observed state
234  * \param[in] size_nobs Size of the non observed state
235  * \param[in] min_x Minimal x index of the observed states
236  * \param[in] max_x Maximal x index of the observed states
237  * \param[in] min_y Minimal y index of the observed states
238  * \param[in] max_y Maximal y index of the observed states
239  * \param[out] idx_obs Array of corr. indices for obs states to populate
240  * \param[out] idx_nobs Array of corr. indices for not obs states to populate
241  */
242  void pop_reordered_idx(
243  unsigned int size_obs, unsigned int size_nobs,
244  unsigned int min_x, unsigned int max_x, unsigned int min_y, unsigned int max_y,
245  std::vector<unsigned int> &idx_obs, std::vector<unsigned int> &idx_nobs
246  ) const;
247 
248  /**
249  * \brief Notifies changing pixels during GP update
250  *
251  * \param coord Coordinates of the rectangular area of the observed state
252  */
253  void notif_changing_pxls(const RectArea &coord);
254 
255  /**
256  * \brief Builds vectors and matrices needed during Kalman update
257  *
258  * \note It assumes the following objects are already of the right size
259  *
260  * \param[in] idx_obs Array of corresponding indices for obs states
261  * \param[in] idx_nobs Array of corresponding indices for non obs states
262  * \param[out] mu Reordered state
263  * \param[out] mu_obs Observed part of the state
264  * \param[out] P Reordered covariance
265  * \param[out] P_obs Observed part of the covariance
266  * \param[out] B Off diagonal block matrix in the covariance
267  * \param[out] C_obs Covariance matrix of the GP for obs states
268  * \param[out] C_obs_inv Inverse of C_obs
269  * \param[out] x_coord X coordinates of the reordered state
270  * \param[out] y_coord Y coordinates of the reordered state
271  */
273  const std::vector<unsigned int> &idx_obs,
274  const std::vector<unsigned int> &idx_nobs,
275  Eigen::VectorXf &mu, Eigen::VectorXf &mu_obs,
276  Eigen::MatrixXf &P, Eigen::MatrixXf &P_obs, Eigen::MatrixXf &B,
277  Eigen::MatrixXf &C_obs, Eigen::MatrixXf &C_obs_inv,
278  Eigen::VectorXf &x_coord, Eigen::VectorXf &y_coord
279  ) const;
280 
281  /**
282  * \brief Fills GP mean and covariance from reordered objects
283  *
284  * \param[in] idx_obs Array of corresponding indices for obs states
285  * \param[in] idx_nobs Array of corresponding indices for non obs states
286  * \param[in] mu Reordered state
287  * \param[in] P Reordered covariance
288  * \param[out] gp_mean GP mean to fill
289  * \param[out] gp_cov GP covariance to fill
290  */
291  void update_reordered_gp(
292  const std::vector<unsigned int> &idx_obs,
293  const std::vector<unsigned int> &idx_nobs,
294  const Eigen::VectorXf &mu, const Eigen::MatrixXf &P,
295  Eigen::VectorXf &gp_mean, Eigen::MatrixXf &gp_cov
296  ) const;
297 
298  /**
299  * \brief Updates the Gaussian Process given measured data points
300  *
301  * \param[in] x_meas X coordinate of the measured data points (in wall frame=
302  * \param[in] y_meas Y coordinate of the measured data points (in wall frame=
303  * \param[in] z_meas Z coordinate of the measured data points (in wall frame=
304  * \param[in] distances Distances between the camera origin and the measured points
305  * \param[in] values Measured value of the points at coordinates (x, y)
306  * \param[in, out] gp_mean Mean of the Gaussian Process
307  * \param[in, out] gp_cov Covariance of the Gaussian Process
308  * \param[out] idx_obs Array of corresponding indices for obs states
309  * \param[out] obs_coord Coordinates of the rectangular area of the observed state
310  * \param[in] update_mean Whether to update the mean
311  */
312  void update_gp(
313  const vec_f &x_meas, const vec_f &y_meas, const vec_f &z_meas,
314  const vec_f &distances, const vec_f &values,
315  Eigen::VectorXf &gp_mean, Eigen::MatrixXf &gp_cov,
316  std::vector<unsigned int> &idx_obs,
317  RectArea &obs_coord,
318  bool update_mean = true
319  ) const;
320 
321  /**
322  * \brief Prepares objects needed for Gaussian Process evaluation
323  *
324  * \param[in] idx_obs Array of corresponding indices for obs states
325  * \param[in] gp_mean Mean of the Gaussian Process
326  * \param[out] x_obs X coordinates of the observed state
327  * \param[out] y_obs Y coordinates of the observed state
328  * \param[out] W Vector needed for evaluation (\f$ W = (C^{-1})_{obs} \mu_{obs} \f$)
329  */
330  void prepare_eval(
331  const std::vector<unsigned int> &idx_obs,
332  const Eigen::VectorXf &gp_mean,
333  Eigen::VectorXf &x_obs, Eigen::VectorXf &y_obs,
334  Eigen::VectorXf &W
335  ) const;
336 
337  /**
338  * \brief Evaluates the Gaussian Process at a given point
339  *
340  * \param x X coordinate of the evaluated point
341  * \param y Y coordinate of the evaluated point
342  * \param x_obs X coordinates of the observed state
343  * \param x_obs Y coordinates of the observed state
344  * \param W Vector needed for evaluation (\f$ W = (C^{-1})_{obs} \mu_{obs} \f$)
345  * \return Value of the evaluated Gaussian Process
346  */
347  float eval_gp(
348  float x, float y,
349  const Eigen::VectorXf &x_obs, const Eigen::VectorXf &y_obs,
350  const Eigen::VectorXf &W
351  ) const;
352 
353  /**
354  * \brief Publishes mean and covariance of the Gaussian Process
355  */
356  void publish_gp_state();
357 
358  /**
359  * \brief Publishes the evaluated GP and its covariance
360  */
361  void publish_gp_eval();
362 
363  /**
364  * \brief Evaluates the Lambert W (0 branch) function
365  *
366  * The Lambert W function solves the equation w*exp(w) = z with w = W0(z)
367  * when z >= 0. Uses Newton's method as indicated at
368  * https://en.wikipedia.org/wiki/Lambert_W_function#Numerical_evaluation
369  *
370  * \note This function is better implemented in Boost in versions >=1.69,
371  * which is not supported by ROS 1 (as of January 2020)
372  *
373  * \param z Positive real number
374  * \param precision Desired precision for the result
375  * \param init_w Initial point of Newton's evaluation
376  * \return The Lambert W function evaluated at z if z >= 0, 0 otherwise.
377  */
378  double lambert_w0(double z, double precision=0.01, double init_w=1.0) const;
379 
380  /**
381  * \brief Evaluates the Lambert W (-1 branch) function
382  *
383  * The Lambert W function solves the equation w*exp(w) = z with w = W0(z)
384  * when -1/e <= z < 0. Uses Newton's method as indicated at
385  * https://en.wikipedia.org/wiki/Lambert_W_function#Numerical_evaluation
386  *
387  * \note This function is better implemented in Boost in versions >=1.69,
388  * which is not supported by ROS 1 (as of January 2020)
389  *
390  * \param z Real number in [-1/e, 0)
391  * \param precision Desired precision for the result
392  * \param init_w Initial point of Newton's evaluation
393  * \return The Lambert W function evaluated at z if z is in the right bound,
394  * 0 otherwise.
395  */
396  double lambert_wm1(double z, double precision=0.01, double init_w=-2.0) const;
397 
398  /**
399  * \brief Applies Netwton's method to evaluate Lambert W function
400  *
401  * The initial point should be < -1.0 for branch -1 and > 0.0 for branch 0.
402  *
403  * \warning Does not care of bounds, so to use with care. Prefer using
404  * `GPNodelet::lambert_w0` and `GPNodelet::lambert_wm1`.
405  *
406  * \param z Real number in [-1/e, +inf)
407  * \param precision Desired precision for the result
408  * \param init_w Initial point of Newton's evaluation
409  * \return The Lambert W function evaluated at z.
410  */
411  double lambert_w(double z, double precision, double init_w) const;
412 
413 };
414 
415 
416 inline float GPNodelet::camera_noise(float distance) const
417 {
418  return camera_var_ * (1 - exp(-distance / camera_decay_));
419 }
420 
421 
422 inline double GPNodelet::matern_kernel(double x1, double y1, double x2, double y2) const
423 {
424  double d = sqrt(pow(x1-x2, 2) + pow(y1-y2, 2));
425  double term = sqrt(3) * d / matern_length_;
426 
427  return matern_var_ * (1 + term) * exp(-term);
428 }
429 
430 
431 
432 } // namespace mfcpp
433 
434 #endif
tf2_ros::Buffer tf_buffer_
Tf2 buffer for getting tf transforms.
Definition: gp_nodelet.hpp:77
Definition: common.hpp:23
ros::Publisher cov_img_pub_
Publisher for an image of the GP covariance.
Definition: gp_nodelet.hpp:71
void prepare_eval(const std::vector< unsigned int > &idx_obs, const Eigen::VectorXf &gp_mean, Eigen::VectorXf &x_obs, Eigen::VectorXf &y_obs, Eigen::VectorXf &W) const
Prepares objects needed for Gaussian Process evaluation.
Definition: gp.cpp:358
geometry_msgs::TransformStamped wall_camera_tf_
Definition: gp_nodelet.hpp:89
tf2_ros::TransformListener tf_listener_
Tf2 listener for getting tf transforms.
Definition: gp_nodelet.hpp:78
float size_wall_x_
Size (m) of the algae wall in the x direction.
Definition: gp_nodelet.hpp:120
ros::Publisher gp_mean_pub_
Publisher for the GP mean.
Definition: gp_nodelet.hpp:72
float main_freq_
Frequency of the main loop.
Definition: gp_nodelet.hpp:104
void camera_cb(const mf_sensors_simulator::CameraOutputConstPtr &msg)
Callback for the camera output.
Definition: gp_nodelet.cpp:178
static ros::Timer main_timer_
Timer callback for the main function.
Definition: gp_nodelet.hpp:64
float gp_noise_var_
Noise variance of the Gaussian Process.
Definition: gp_nodelet.hpp:115
double lambert_w(double z, double precision, double init_w) const
Applies Netwton&#39;s method to evaluate Lambert W function.
Definition: gp_nodelet.cpp:447
bool update_gp_cb(mf_mapping::UpdateGP::Request &req, mf_mapping::UpdateGP::Response &res)
Service to update the Gaussian Process for several sets of measurements.
Definition: gp_nodelet.cpp:204
ros::Subscriber camera_sub_
Subscriber for the camera.
Definition: gp_nodelet.hpp:69
float delta_y_
Increment (m) in the y direction.
Definition: gp_nodelet.hpp:86
float gp_init_mean_
Initial mean values of the Gaussian Process.
Definition: gp_nodelet.hpp:114
Eigen::MatrixXf gp_C_
Covariance of the values of the mean of the GP.
Definition: gp_nodelet.hpp:94
double lambert_w0(double z, double precision=0.01, double init_w=1.0) const
Evaluates the Lambert W (0 branch) function.
Definition: gp_nodelet.cpp:421
float matern_thresh_
Threshold to consider that the kernel value is 0.
Definition: gp_nodelet.hpp:113
Eigen::VectorXf gp_mean_
Mean of the Gaussian Process.
Definition: gp_nodelet.hpp:92
ros::NodeHandle nh_
Node handler (for topics and services)
Definition: gp_nodelet.hpp:67
void build_Kalman_objects(const std::vector< unsigned int > &idx_obs, const std::vector< unsigned int > &idx_nobs, Eigen::VectorXf &mu, Eigen::VectorXf &mu_obs, Eigen::MatrixXf &P, Eigen::MatrixXf &P_obs, Eigen::MatrixXf &B, Eigen::MatrixXf &C_obs, Eigen::MatrixXf &C_obs_inv, Eigen::VectorXf &x_coord, Eigen::VectorXf &y_coord) const
Builds vectors and matrices needed during Kalman update.
Definition: gp.cpp:131
float camera_var_
Max variance on camera measurements.
Definition: gp_nodelet.hpp:108
unsigned int size_gp_
Total size of the Gaussian Process.
Definition: gp_nodelet.hpp:87
ros::ServiceServer update_gp_serv_
Service server for updating the GP.
Definition: gp_nodelet.hpp:75
Eigen::MatrixXf gp_C_inv_
Inverse of gp_C_.
Definition: gp_nodelet.hpp:95
int size_img_x_
Size of the output image in the x direction.
Definition: gp_nodelet.hpp:124
std::vector< bool > changed_pxl_
Whether an output pixel has been updated.
Definition: gp_nodelet.hpp:100
unsigned int size_img_
Total size of the image.
Definition: gp_nodelet.hpp:88
ros::Publisher wall_img_pub_
Publisher for an image of the wall GP.
Definition: gp_nodelet.hpp:70
bool gp_initialised_
Whether the Gaussian Process is initialised.
Definition: gp_nodelet.hpp:80
void pop_reordered_idx(unsigned int size_obs, unsigned int size_nobs, unsigned int min_x, unsigned int max_x, unsigned int min_y, unsigned int max_y, std::vector< unsigned int > &idx_obs, std::vector< unsigned int > &idx_nobs) const
Populates indices correspondance for reordered states.
Definition: gp.cpp:65
double lambert_wm1(double z, double precision=0.01, double init_w=-2.0) const
Evaluates the Lambert W (-1 branch) function.
Definition: gp_nodelet.cpp:434
virtual void onInit()
Function called at beginning of nodelet execution.
Definition: gp_nodelet.cpp:53
float distance(const geometry_msgs::Point &p1, const geometry_msgs::Point &p2)
Computes the the euclidean distance between two positions.
Definition: common.hpp:69
float size_wall_y_
Size (m) of the algae wall in the y direction.
Definition: gp_nodelet.hpp:121
static void sigint_handler(int s)
SINGINT (Ctrl+C) callback to stop the nodelet properly.
Definition: gp_nodelet.cpp:170
ros::Publisher gp_eval_pub_
Publisher for the evaluated GP over the wall.
Definition: gp_nodelet.hpp:74
float matern_var_
Signal variance of the Matern kernel.
Definition: gp_nodelet.hpp:112
double matern_kernel(double x1, double y1, double x2, double y2) const
Matern 3/2 kernel function.
Definition: gp_nodelet.hpp:422
void init_gp()
Initialises the Gaussian Process.
Definition: gp.cpp:21
static sig_atomic_t volatile b_sigint_
Whether SIGINT signal has been received.
Definition: gp_nodelet.hpp:63
float eval_gp(float x, float y, const Eigen::VectorXf &x_obs, const Eigen::VectorXf &y_obs, const Eigen::VectorXf &W) const
Evaluates the Gaussian Process at a given point.
Definition: gp.cpp:385
float delta_x_
Increment (m) in the x direction.
Definition: gp_nodelet.hpp:85
bool tf_got_
Whether transforms have been retrieved.
Definition: gp_nodelet.hpp:83
2D rectangular area
Definition: gp_nodelet.hpp:51
bool load_gp_cb(mf_mapping::LoadGP::Request &req, mf_mapping::LoadGP::Response &res)
Service to load the Gaussian Process mean.
Definition: gp_nodelet.cpp:326
void update_reordered_gp(const std::vector< unsigned int > &idx_obs, const std::vector< unsigned int > &idx_nobs, const Eigen::VectorXf &mu, const Eigen::MatrixXf &P, Eigen::VectorXf &gp_mean, Eigen::MatrixXf &gp_cov) const
Fills GP mean and covariance from reordered objects.
Definition: gp.cpp:188
std::string wall_frame_
Name of the wall frame.
Definition: gp_nodelet.hpp:105
Nodelet for a Gaussian Process mapping an algae wall.
Definition: gp_nodelet.hpp:32
std::vector< unsigned int > idx_obs_
Array of corresponding indices for observed states.
Definition: gp_nodelet.hpp:96
std::vector< float > out_values_
Output values of the Gaussian Process.
Definition: gp_nodelet.hpp:99
Eigen::VectorXf y_coord_
Y coordinates of the state on the wall.
Definition: gp_nodelet.hpp:98
float camera_noise(float distance) const
Camera sensor noise model.
Definition: gp_nodelet.hpp:416
bool gp_loaded_
Whether the GP has been loaded from an external source.
Definition: gp_nodelet.hpp:81
void update_gp(const vec_f &x_meas, const vec_f &y_meas, const vec_f &z_meas, const vec_f &distances, const vec_f &values, Eigen::VectorXf &gp_mean, Eigen::MatrixXf &gp_cov, std::vector< unsigned int > &idx_obs, RectArea &obs_coord, bool update_mean=true) const
Updates the Gaussian Process given measured data points.
Definition: gp.cpp:234
Eigen::MatrixXf gp_cov_
Covariance of the Gaussian Process.
Definition: gp_nodelet.hpp:93
void publish_gp_state()
Publishes mean and covariance of the Gaussian Process.
Definition: gp_output.cpp:26
float radius_obs_
Radius of influence of an observation on the GP.
Definition: gp_nodelet.hpp:90
void main_cb(const ros::TimerEvent &timer_event)
Main callback which is called by a timer.
Definition: gp_nodelet.cpp:122
Eigen::VectorXf x_coord_
X coordinates of the state on the wall.
Definition: gp_nodelet.hpp:97
void notif_changing_pxls(const RectArea &coord)
Notifies changing pixels during GP update.
Definition: gp.cpp:107
void publish_gp_eval()
Publishes the evaluated GP and its covariance.
Definition: gp_output.cpp:50
bool get_tf()
Gets necessary tf transforms.
Definition: gp_nodelet.cpp:187
std::vector< float > vec_f
Definition: gp_nodelet.hpp:59
ros::ServiceServer load_gp_serv_
Service server for loading the GP.
Definition: gp_nodelet.hpp:76
mf_sensors_simulator::CameraOutput::ConstPtr camera_msg_
Last camera message.
Definition: gp_nodelet.hpp:84
ros::NodeHandle private_nh_
Private node handler (for parameters)
Definition: gp_nodelet.hpp:68
ros::Publisher gp_cov_pub_
Publisher for the GP covariance.
Definition: gp_nodelet.hpp:73
float matern_length_
Lengthscale of the Matern kernel.
Definition: gp_nodelet.hpp:111
int size_gp_x_
Size of the Gaussian Process mean in the x direction.
Definition: gp_nodelet.hpp:122
bool camera_msg_available_
Whether a new camera message is available.
Definition: gp_nodelet.hpp:82
bool transform_points(const vec_f &x_in, const vec_f &y_in, const vec_f &z_in, vec_f &x_out, vec_f &y_out, vec_f &z_out, std::string frame_in, std::string frame_out)
Transforms points from one frame to another.
float gp_cov_thresh_
Threshold to consider a value as 0 in the covariance.
Definition: gp_nodelet.hpp:116
float camera_decay_
Exponential decay rate on camera measurements.
Definition: gp_nodelet.hpp:109
std::string camera_frame_
Name of the camera frame.
Definition: gp_nodelet.hpp:106
int size_gp_y_
Size of the Gaussian Process mean in the y direction.
Definition: gp_nodelet.hpp:123