mapping.hpp
Go to the documentation of this file.
1 /*********************************************************************
2  * BSD 3-Clause License
3  *
4  * Copyright (c) 2020 Northwestern University
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions are met:
9  *
10  * * Redistributions of source code must retain the above copyright notice, this
11  * list of conditions and the following disclaimer.
12  *
13  * * Redistributions in binary form must reproduce the above copyright notice,
14  * this list of conditions and the following disclaimer in the documentation
15  * and/or other materials provided with the distribution.
16  *
17  * * Neither the name of the copyright holder nor the names of its
18  * contributors may be used to endorse or promote products derived from
19  * this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
25  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  *********************************************************************/
38 #ifndef MAPPING_HPP
39 #define MAPPING_HPP
40 
41 #include <armadillo>
42 
44 #include <sensor_msgs/LaserScan.h>
45 
46 namespace ergodic_exploration
47 {
48 using arma::mat;
49 using arma::vec;
50 
53 {
54 public:
59  OccupancyMapper(const mat& Tbs);
60 
68  bool updateMap(GridMap& grid, const sensor_msgs::LaserScan::ConstPtr& scan,
69  const vec& pose);
70 
71 private:
82  void rayTrace(GridMap& grid, int x0, int y0, int x1, int y1) const;
83 
93  void lineLow(GridMap& grid, int x0, int y0, int x1, int y1) const;
94 
104  void lineHigh(GridMap& grid, int x0, int y0, int x1, int y1) const;
105 
115  void lineDiag(GridMap& grid, int x0, int y0, int x1, int y1) const;
116 
125  void updateCell(GridMap& grid, int x, int y, double log) const;
126 
127 private:
128  mat Tbs_; // transform base link to laser scanner
129  double prior_, prob_occ_, prob_free_; // probabilities for cell states
130  double log_odds_prior_; // log odds prior
131  double log_odds_occ_; // log odds occupied
132  double log_odds_free_; // log odds free
133 };
134 } // namespace ergodic_exploration
135 #endif
ergodic_exploration::OccupancyMapper::Tbs_
mat Tbs_
Definition: mapping.hpp:128
ergodic_exploration::OccupancyMapper::rayTrace
void rayTrace(GridMap &grid, int x0, int y0, int x1, int y1) const
Bresenham's line algorithm on occupancy map.
Definition: mapping.cpp:130
ergodic_exploration::OccupancyMapper::log_odds_occ_
double log_odds_occ_
Definition: mapping.hpp:131
ergodic_exploration::OccupancyMapper::updateCell
void updateCell(GridMap &grid, int x, int y, double log) const
Update grid cell probability of occupancy.
Definition: mapping.cpp:341
ergodic_exploration::OccupancyMapper::prob_free_
double prob_free_
Definition: mapping.hpp:129
ergodic_exploration::OccupancyMapper::lineHigh
void lineHigh(GridMap &grid, int x0, int y0, int x1, int y1) const
Bresenham's algorithm for drawing lines upward.
Definition: mapping.cpp:283
ergodic_exploration::OccupancyMapper::prior_
double prior_
Definition: mapping.hpp:129
ergodic_exploration::OccupancyMapper::lineLow
void lineLow(GridMap &grid, int x0, int y0, int x1, int y1) const
Bresenham's algorithm for drawing lines downward.
Definition: mapping.cpp:245
ergodic_exploration::OccupancyMapper::updateMap
bool updateMap(GridMap &grid, const sensor_msgs::LaserScan::ConstPtr &scan, const vec &pose)
Update the occupancy grid map.
Definition: mapping.cpp:77
ergodic_exploration
Definition: basis.hpp:43
ergodic_exploration::GridMap
Constructs an 2D grid.
Definition: grid.hpp:79
ergodic_exploration::OccupancyMapper::lineDiag
void lineDiag(GridMap &grid, int x0, int y0, int x1, int y1) const
Bresenham's algorithm for drawing lines at +/- 45 deg.
Definition: mapping.cpp:321
ergodic_exploration::OccupancyMapper::log_odds_prior_
double log_odds_prior_
Definition: mapping.hpp:130
ergodic_exploration::OccupancyMapper::log_odds_free_
double log_odds_free_
Definition: mapping.hpp:132
ergodic_exploration::OccupancyMapper
Occupancy grid mapping.
Definition: mapping.hpp:52
grid.hpp
2D grid represented in row major order
ergodic_exploration::OccupancyMapper::prob_occ_
double prob_occ_
Definition: mapping.hpp:129
ergodic_exploration::OccupancyMapper::OccupancyMapper
OccupancyMapper(const mat &Tbs)
Constructor.
Definition: mapping.cpp:66


ergodic_exploration
Author(s): bostoncleek
autogenerated on Wed Mar 2 2022 00:17:13