laserIMUCalibration
laserNAVCalib.h
Go to the documentation of this file.
1 
12 #ifndef _LASER_NAV_CALIB_H
13 #define _LASER_NAV_CALIB_H
14 
15 #include <vector>
16 
17 // convert rad 2 deg
18 #include "mathConstants.h"
19 
20 #include <pcl/common/common_headers.h>
21 
25 typedef pcl::PointCloud<pcl::PointNormal> pointCloud;
26 
30 typedef std::pair<pointCloud::Ptr, pointCloud::Ptr> last_and_latest;
31 
32 namespace filter
33 {
42 {
43 public:
50  };
51 private:
55  static const unsigned int nr_unknowns = 6;
59  static unsigned int scans_between_last_and_latest;
63  double sampled_scans;
67  unsigned int scan_counter;
77 
85  double pos_x, pos_y, pos_z, phi, theta, psi;
86 
90  pointCloud::Ptr cloud_to_draw;
94  pointCloud::Ptr last;
98  pointCloud::Ptr latest;
102  static pointCloud::Ptr last_to_draw;
106  static pointCloud::Ptr latest_to_draw;
110  std::vector< last_and_latest > data_set;
115  unsigned int nr_scan_pairs;
120  static size_t worst_pair;
124  static double worst_score;
128  static double avr_cal_err;
136  static bool downsampling;
140  static bool bilateral_filtering;
144  static bool calculate_normals;
148  static bool covariance_sampling;
152  static bool initial_aligning;
161  bool init;
165  std::stringstream filename;
166 
177  void print(
178  double pos_x, double pos_y, double pos_z
179  , double phi, double theta, double psi
180  , std::string name = "Transformation");
181 
189  void print(
190  Eigen::Affine3d* transformation_to_print
191  , std::string name = "Transformation");
192 
200  void print(
201  Eigen::Matrix4d* transformation_to_print
202  , std::string name = "Transformation");
203 
214  static bool exists(const std::string& name);
215 
227  static void plot(
228  std::string header
229  , std::string data
230  , std::string filename);
231 
243  static Eigen::Matrix4d getScanTransformationFrom(
244  pointCloud::Ptr last
245  , pointCloud::Ptr latest
246  , double* icp_fitness_score
247  , double iterations);
248 
258  static Eigen::Matrix4d getMovementFrom(
259  pointCloud::Ptr last
260  , pointCloud::Ptr latest);
261 
262  static double evaluateICPFitnessScore(
263  pointCloud::Ptr first
264  , pointCloud::Ptr second
265  , double pos_x
266  , double pos_y
267  , double pos_z
268  , double phi
269  , double theta
270  , double psi
271  );
272 
283  static void getMountingPose(
284  const double *par
285  , int m_dat
286  , const void *data
287  , double *fvec
288  , int *info );
289 
290 public:
304  double pos_x = 0.0, double pos_y = 0.0, double pos_z = 0.0
305  , double phi = math::c_DEG_TO_RAD * 0.0
306  , double theta = math::c_DEG_TO_RAD * 0.0
307  , double psi = math::c_DEG_TO_RAD * 0.0);
308 
312  virtual ~LaserNAVCalibration();
313 
319  const pointCloud::Ptr getLatestCloud(void)const;
320 
326  const pointCloud::Ptr getLastCloud(void)const;
327 
333  void setDownsampling(bool new_state);
338  bool getDownsampling(void);
339 
346  void setBilateralFiltering(bool new_state);
352  bool getBilateralFiltering(void);
353 
359  void setCalculateNormals(bool new_state);
365  bool getCalculateNormals(void);
366 
372  void setCovarianceSampling(bool new_state);
377  bool getCovarianceSampling(void);
378 
384  void setInitialAligning(bool new_state);
390  bool getInitialAligning(void);
391 
395  void addToDataSet(void);
396 
400  void resetDataSet(void);
401 
405  void optimizeDataSet(void);
406 
414  void setScansBetweenLastAndLatest(unsigned int scans_between_last_and_latest);
415 
420  virtual void update(pointCloud::Ptr cloud_to_draw);
421 };
422 } // filter
423 #endif // _LASER_NAV_CALIB_H
static bool bilateral_filtering
When true: bilateral-filtering is used (computes fpfh-features!)
unsigned int scan_counter
Counts the scans between last and latest point-cloud.
Definition: laserNAVCalib.h:67
void print(double pos_x, double pos_y, double pos_z, double phi, double theta, double psi, std::string name="Transformation")
Print the given transformation on command-line-interface.
void resetDataSet(void)
Reset/Remove all point-cloud-pairs from the data-set.
bool init
Initializes the optimization-array for the Levenberg-Marquardt using ctor. given parameters.
pointCloud::Ptr cloud_to_draw
The cloud-ptr provided by another source (work is based on this)
Definition: laserNAVCalib.h:90
static void getMountingPose(const double *par, int m_dat, const void *data, double *fvec, int *info)
Optimized the mounting-pose as part of the Levenberg-Marquardt.
const pointCloud::Ptr getLastCloud(void) const
Returns the last stable cloud.
static bool exists(const std::string &name)
Checks if the given filename-at-path exists.
double sampled_scans
Contains the number of all sampled scans.
Definition: laserNAVCalib.h:63
double mounting_pose[nr_unknowns]
The data-array used by the Levenberg-Marquardt lmmin-optimizer.
Definition: laserNAVCalib.h:81
bool getInitialAligning(void)
Retrieves if the initial alignment is activated.
double pos_x
Class-wide latest position (this is altered after optimization)
Definition: laserNAVCalib.h:85
static bool initial_aligning
When true: Initial Alignment is calculated using Sample-Consensus (untested)
bool getBilateralFiltering(void)
Retrieves if the bilateral filter is activated.
std::vector< last_and_latest > data_set
Holds the data-set of point-cloud-pairs (known as key-sequences in the thesis)
static e_registrationMethod ICPMethod
Selector for the calibration-method (not supported atm)
Filter to calibrate the Laser mounting Pose according to NAV-data.
Definition: laserNAVCalib.h:41
static Eigen::Matrix4d getMovementFrom(pointCloud::Ptr last, pointCloud::Ptr latest)
Retrieves the movement of the Navigation-Data between the last and latest point-cloud.
e_registrationMethod
Selector for the calibration-method (not supported atm)
Definition: laserNAVCalib.h:47
static const unsigned int nr_unknowns
Number of unknowns.
Definition: laserNAVCalib.h:55
std::pair< pointCloud::Ptr, pointCloud::Ptr > last_and_latest
Typedef for shorter call (used as data-set for the levenberg-marquardt data)
Definition: laserNAVCalib.h:30
pcl::PointCloud< pcl::PointNormal > pointCloud
Typedef for shorter call of point-cloud-pointer-type.
Definition: laserNAVCalib.h:25
void setCovarianceSampling(bool new_state)
Sets the covariance-sampling of point-normals.
virtual ~LaserNAVCalibration()
Virtual std. dtor.
void setInitialAligning(bool new_state)
Sets the initial alignment of point-normals.
static double worst_score
Holds the worst ICP-fitness-score for the according point-cloud-pair.
virtual void update(pointCloud::Ptr cloud_to_draw)
Updates the mounting-pose using Levenberg-Marquardt non-linear optimization.
double c_DEG_TO_RAD
void setBilateralFiltering(bool new_state)
Sets the bilateral filter.
static unsigned int scans_between_last_and_latest
Number of scans between point-cloud-pairs (those are simply dropped)
Definition: laserNAVCalib.h:59
bool add_to_data_set
Set to true on button press when the user requested to add a data-set to the key-sequences.
void setDownsampling(bool new_state)
Sets the filter voxel-grid.
static bool downsampling
When true: all point-clouds are downsampled using Voxel-Grids.
bool getCalculateNormals(void)
Retrieves if the bilateral filter is activated.
bool getDownsampling(void)
Retrieves if the voxel-grid filter is activated.
static bool calculate_normals
When true: calculate normals (basis for covariance-sampling and initial-alignment) ...
static void plot(std::string header, std::string data, std::string filename)
Plot the given header + data to file.
static size_t worst_pair
Index of the point-cloud-pair with the worst ICP-fitness-score.
static Eigen::Matrix4d getScanTransformationFrom(pointCloud::Ptr last, pointCloud::Ptr latest, double *icp_fitness_score, double iterations)
Retrieves the transformation from last to latest point-cloud.
pointCloud::Ptr last
Cloud-ptr that stores the last point-cloud.
Definition: laserNAVCalib.h:94
LaserNAVCalibration(double pos_x=0.0, double pos_y=0.0, double pos_z=0.0, double phi=math::c_DEG_TO_RAD *0.0, double theta=math::c_DEG_TO_RAD *0.0, double psi=math::c_DEG_TO_RAD *0.0)
std. ctor.
bool getCovarianceSampling(void)
Retrieves if the covariance-sampling is activated.
void setCalculateNormals(bool new_state)
Sets the calculation of point-normals.
pointCloud::Ptr latest
Cloud-ptr that stores the latest point-cloud.
Definition: laserNAVCalib.h:98
static double avr_cal_err
Mean of the summed ICP-fitness-score's (updated each iteration)
const pointCloud::Ptr getLatestCloud(void) const
Returns the latest stable cloud.
void optimizeDataSet(void)
Deletes the worst-pair according to its ICP-fitness-score.
bool calibration_wanted
Set to true when calibration is wanted.
Definition: laserNAVCalib.h:76
static double evaluateICPFitnessScore(pointCloud::Ptr first, pointCloud::Ptr second, double pos_x, double pos_y, double pos_z, double phi, double theta, double psi)
unsigned int nr_scan_pairs
holds the number of elements in the data-set (std::vector.size() takes too long)
bool plot_all_movements
Check all scans and plot all movements to a file.
Definition: laserNAVCalib.h:72
void addToDataSet(void)
Sets the boolean to add the point-clouds at the active index to the data-set-pairs.
static pointCloud::Ptr latest_to_draw
Cloud-ptr that stores the latest point-cloud that will be drawn (stable, switched after registration-...
std::stringstream filename
Variable to store a class-wide filename (can be used to group different plots according to a naming s...
static bool covariance_sampling
When true: Samples the point-cloud using covariance-matrices.
void setScansBetweenLastAndLatest(unsigned int scans_between_last_and_latest)
Sets the number of scans to skip between one registration.
unsigned int iterations
static pointCloud::Ptr last_to_draw
Cloud-ptr that stores the last point-cloud that will be drawn (stable, switched after registration-pr...