gmcl_laser.h
Go to the documentation of this file.
1 //this package is based on amcl and has been modified to fit gmcl
2 /*
3  * Author: Mhd Ali Alshikh Khalil
4  * Date: 20 June 2021
5  *
6 */
7 
8 //amcl author clarification
9 /*
10  * Player - One Hell of a Robot Server
11  * Copyright (C) 2000 Brian Gerkey et al.
12  *
13  * This library is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU Lesser General Public
15  * License as published by the Free Software Foundation; either
16  * version 2.1 of the License, or (at your option) any later version.
17  *
18  * This library is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21  * Lesser General Public License for more details.
22  *
23  * You should have received a copy of the GNU Lesser General Public
24  * License along with this library; if not, write to the Free Software
25  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26  *
27  */
29 //
30 // Desc: LASER sensor model for AMCL
31 // Author: Andrew Howard
32 // Date: 17 Aug 2003
33 // CVS: $Id: amcl_laser.h 6443 2008-05-15 19:46:11Z gerkey $
34 //
36 
37 #ifndef AMCL_LASER_H
38 #define AMCL_LASER_H
39 
40 #include "gmcl_sensor.h"
41 #include "../map/map.h"
42 
43 namespace gmcl
44 {
45 
46 typedef enum
47 {
52 
53 // Laser sensor data
55 {
56  public:
57  static std::vector< GMCLLaserData* > sldata;
58  // lsensor = new AMCLSensorData;
60  virtual ~GMCLLaserData() {delete[] ranges;};
61  // Laser range data (range, bearing tuples)
62 
63  public: double (*ranges)[2] ;
64  public: int range_count ;
65 
66 
67 };
68  std::vector< GMCLLaserData* > GMCLLaserData::sldata;
69 
70 // Laseretric sensor model
71 class GMCLLaser : public GMCLSensor
72 {
73  // Default constructor
74 
75 
76  public: GMCLLaser(size_t max_beams, map_t* map);
77 
78  public: virtual ~GMCLLaser();
79 
80  public: void SetModelBeam(double z_hit,
81  double z_short,
82  double z_max,
83  double z_rand,
84  double sigma_hit,
85  double lambda_short,
86  double chi_outlier);
87 
88  public: void SetModelLikelihoodField(double z_hit,
89  double z_rand,
90  double sigma_hit,
91  double max_occ_dist);
92 
93  //a more probabilistically correct model - also with the option to do beam skipping
94  public: void SetModelLikelihoodFieldProb(double z_hit,
95  double z_rand,
96  double sigma_hit,
97  double max_occ_dist,
98  bool do_beamskip,
99  double beam_skip_distance,
100  double beam_skip_threshold,
102 
103  // Update the filter based on the sensor model. Returns true if the
104  // filter has been updated.
105  public: virtual bool UpdateSensor(pf_t *pf, GMCLSensorData *data) ;
106 
107  public: virtual double PoseWeight(pf_vector_t pose, GMCLLaserData *data) ;
108 
109  public: static bool ReUpdateSensor(pf_t *pf, GMCLSensorData *data)
110  {data->sensor->UpdateSensor(pf, data);
111  return true ;}
112 
113  // Set the laser's pose after construction
114  public: void SetLaserScan(lsensor_scan_t& laser_scan)
115  {
116  this->laser_pose = laser_scan.laser_pose;
117  this->range_max = laser_scan.range_max;
118  this->range_min = laser_scan.range_min;
119  }
120  // Determine the probability for the given pose
121  private: static void BeamModel(GMCLLaserData *data,
122  pf_sample_set_t* set);
123  // Determine the probability for the given pose
124  private: static void LikelihoodFieldModel(GMCLLaserData *data,
125  pf_sample_set_t* set);
126 
127  // Determine the probability for the given pose - more probablistic model
128  private: static void LikelihoodFieldModelProb(GMCLLaserData *data,
129  pf_sample_set_t* set);
130 
131  private: void reallocTempData(int max_samples, int max_obs);
132 
134 
135  // Current data timestamp
136  private: double time;
137 
138  // The laser map
139  private: map_t *map;
140 
141  // Laser offset relative to robot
142 
143  // Laser offset relative to robot
145 
146  public: float range_max , range_min ;
147 
148  // Max beams to consider
149  private: int max_beams;
150 
151  // Beam skipping parameters (used by LikelihoodFieldModelProb model)
152  private: bool do_beamskip;
153  private: double beam_skip_distance;
154  private: double beam_skip_threshold;
155  //threshold for the ratio of invalid beams - at which all beams are integrated to the likelihoods
156  //this would be an error condition
157  private: double beam_skip_error_threshold;
158 
159  //temp data that is kept before observations are integrated to each particle (requried for beam skipping)
160  private: int max_samples;
161  private: int max_obs;
162  private: double **temp_obs;
163 
164  // Laser model params
165  //
166  // Mixture params for the components of the model; must sum to 1
167  private: double z_hit;
168  private: double z_short;
169  private: double z_max;
170  private: double z_rand;
171  //
172  // Stddev of Gaussian model for laser hits.
173  private: double sigma_hit;
174  // Decay rate of exponential model for short readings.
175  private: double lambda_short;
176  // Threshold for outlier rejection (unused)
177  private: double chi_outlier;
178 };
179 
180 
181 }
182 
183 #endif
gmcl::LASER_MODEL_LIKELIHOOD_FIELD_PROB
@ LASER_MODEL_LIKELIHOOD_FIELD_PROB
Definition: gmcl_laser.h:50
gmcl::GMCLLaser::PoseWeight
virtual double PoseWeight(pf_vector_t pose, GMCLLaserData *data)
Definition: gmcl_laser.cpp:153
lsensor_scan_t
Definition: map.h:88
gmcl::GMCLLaser::temp_obs
double ** temp_obs
Definition: gmcl_laser.h:162
gmcl
Definition: gmcl_laser.h:43
gmcl::GMCLLaser::map
map_t * map
Definition: gmcl_laser.h:139
gmcl::GMCLLaserData::GMCLLaserData
GMCLLaserData()
Definition: gmcl_laser.h:59
gmcl::GMCLLaser::SetLaserScan
void SetLaserScan(lsensor_scan_t &laser_scan)
Definition: gmcl_laser.h:114
pf_vector_t
Definition: pf_vector.h:46
gmcl::GMCLSensorData
Definition: gmcl_sensor.h:93
gmcl::GMCLLaser::sigma_hit
double sigma_hit
Definition: gmcl_laser.h:173
gmcl::GMCLLaser::beam_skip_error_threshold
double beam_skip_error_threshold
Definition: gmcl_laser.h:157
gmcl::GMCLLaserData::~GMCLLaserData
virtual ~GMCLLaserData()
Definition: gmcl_laser.h:60
gmcl::GMCLLaser::SetModelLikelihoodFieldProb
void SetModelLikelihoodFieldProb(double z_hit, double z_rand, double sigma_hit, double max_occ_dist, bool do_beamskip, double beam_skip_distance, double beam_skip_threshold, double beam_skip_error_threshold)
Definition: gmcl_laser.cpp:108
gmcl::GMCLLaser::LikelihoodFieldModel
static void LikelihoodFieldModel(GMCLLaserData *data, pf_sample_set_t *set)
Definition: gmcl_laser.cpp:458
gmcl::GMCLLaser::max_obs
int max_obs
Definition: gmcl_laser.h:161
_pf_sample_set_t
Definition: pf.h:107
gmcl::GMCLLaser::range_max
float range_max
Definition: gmcl_laser.h:146
gmcl::GMCLSensor
Definition: gmcl_sensor.h:49
gmcl::GMCLLaser::SetModelBeam
void SetModelBeam(double z_hit, double z_short, double z_max, double z_rand, double sigma_hit, double lambda_short, double chi_outlier)
Definition: gmcl_laser.cpp:75
gmcl::GMCLLaserData::ranges
double(* ranges)[2]
Definition: gmcl_laser.h:63
data
data
gmcl::GMCLLaser::do_beamskip
bool do_beamskip
Definition: gmcl_laser.h:152
gmcl::LASER_MODEL_LIKELIHOOD_FIELD
@ LASER_MODEL_LIKELIHOOD_FIELD
Definition: gmcl_laser.h:49
_pf_t
Definition: pf.h:150
gmcl::GMCLLaser::z_max
double z_max
Definition: gmcl_laser.h:169
gmcl::GMCLSensor::pose
pf_vector_t pose
Definition: gmcl_sensor.h:73
gmcl::GMCLLaser::lambda_short
double lambda_short
Definition: gmcl_laser.h:175
gmcl::GMCLLaser::~GMCLLaser
virtual ~GMCLLaser()
Definition: gmcl_laser.cpp:64
gmcl::GMCLLaser::model_type
laser_model_t model_type
Definition: gmcl_laser.h:133
gmcl::GMCLLaser::UpdateSensor
virtual bool UpdateSensor(pf_t *pf, GMCLSensorData *data)
Definition: gmcl_laser.cpp:131
gmcl::GMCLLaser::z_rand
double z_rand
Definition: gmcl_laser.h:170
gmcl::GMCLLaser::max_samples
int max_samples
Definition: gmcl_laser.h:160
gmcl::GMCLLaser::beam_skip_distance
double beam_skip_distance
Definition: gmcl_laser.h:153
gmcl_sensor.h
gmcl::GMCLLaser::time
double time
Definition: gmcl_laser.h:136
gmcl::GMCLLaser::reallocTempData
void reallocTempData(int max_samples, int max_obs)
Definition: gmcl_laser.cpp:1321
gmcl::GMCLLaserData::sldata
static std::vector< GMCLLaserData * > sldata
Definition: gmcl_laser.h:57
gmcl::GMCLLaser::LikelihoodFieldModelProb
static void LikelihoodFieldModelProb(GMCLLaserData *data, pf_sample_set_t *set)
Definition: gmcl_laser.cpp:745
gmcl::GMCLLaser::BeamModel
static void BeamModel(GMCLLaserData *data, pf_sample_set_t *set)
Definition: gmcl_laser.cpp:211
gmcl::GMCLLaserData
Definition: gmcl_laser.h:54
gmcl::GMCLLaser::ReUpdateSensor
static bool ReUpdateSensor(pf_t *pf, GMCLSensorData *data)
Definition: gmcl_laser.h:109
gmcl::GMCLLaser::z_hit
double z_hit
Definition: gmcl_laser.h:167
gmcl::GMCLLaser::max_beams
int max_beams
Definition: gmcl_laser.h:149
gmcl::GMCLLaser::range_min
float range_min
Definition: gmcl_laser.h:146
gmcl::GMCLLaser::laser_pose
pf_vector_t laser_pose
Definition: gmcl_laser.h:144
gmcl::LASER_MODEL_BEAM
@ LASER_MODEL_BEAM
Definition: gmcl_laser.h:48
map_t
Definition: map.h:67
gmcl::laser_model_t
laser_model_t
Definition: gmcl_laser.h:46
gmcl::GMCLLaser::SetModelLikelihoodField
void SetModelLikelihoodField(double z_hit, double z_rand, double sigma_hit, double max_occ_dist)
Definition: gmcl_laser.cpp:94
gmcl::GMCLLaser::z_short
double z_short
Definition: gmcl_laser.h:168
gmcl::GMCLLaser::chi_outlier
double chi_outlier
Definition: gmcl_laser.h:177
gmcl::GMCLLaser::GMCLLaser
GMCLLaser(size_t max_beams, map_t *map)
Definition: gmcl_laser.cpp:52
gmcl::GMCLLaserData::range_count
int range_count
Definition: gmcl_laser.h:64
lsensor_scan_t::range_max
float range_max
Definition: map.h:94
gmcl::GMCLLaser::beam_skip_threshold
double beam_skip_threshold
Definition: gmcl_laser.h:154
lsensor_scan_t::range_min
float range_min
Definition: map.h:96
lsensor_scan_t::laser_pose
pf_vector_t laser_pose
Definition: map.h:90
gmcl::GMCLLaser
Definition: gmcl_laser.h:71


gmcl
Author(s): Mhd Ali Alshikh Khalil, adler1994@gmail.com
autogenerated on Wed Mar 2 2022 00:20:14