Nav2 Navigation Stack - rolling  main
ROS 2 Navigation Stack
laser.cpp
1 /*
2  * Player - One Hell of a Robot Server
3  * Copyright (C) 2000 Brian Gerkey & Kasper Stoy
4  * gerkey@usc.edu kaspers@robotics.usc.edu
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  *
20  */
21 
22 #include <cmath>
23 
24 #include "nav2_amcl/sensors/laser/laser.hpp"
25 
26 namespace nav2_amcl
27 {
28 
29 Laser::Laser(size_t max_beams, map_t * map)
30 : max_samples_(0), max_obs_(0), temp_obs_(NULL)
31 {
32  max_beams_ = max_beams;
33  map_ = map;
34 }
35 
36 Laser::~Laser()
37 {
38  if (temp_obs_) {
39  for (int k = 0; k < max_samples_; k++) {
40  delete[] temp_obs_[k];
41  }
42  delete[] temp_obs_;
43  }
44 }
45 
46 void
47 Laser::reallocTempData(int new_max_samples, int new_max_obs)
48 {
49  if (temp_obs_) {
50  for (int k = 0; k < max_samples_; k++) {
51  delete[] temp_obs_[k];
52  }
53  delete[] temp_obs_;
54  }
55  max_obs_ = new_max_obs;
56  max_samples_ = fmax(max_samples_, new_max_samples);
57 
58  temp_obs_ = new double *[max_samples_]();
59  for (int k = 0; k < max_samples_; k++) {
60  temp_obs_[k] = new double[max_obs_]();
61  }
62 }
63 
64 void
65 Laser::SetLaserPose(pf_vector_t & laser_pose)
66 {
67  laser_pose_ = laser_pose;
68 }
69 
70 } // namespace nav2_amcl
Laser(size_t max_beams, map_t *map)
A Laser constructor.
Definition: laser.cpp:29
Definition: map.hpp:62