Nav2 Navigation Stack - jazzy  jazzy
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 <sys/types.h>
23 #include <math.h>
24 #include <stdlib.h>
25 #include <assert.h>
26 
27 #include "nav2_amcl/sensors/laser/laser.hpp"
28 
29 namespace nav2_amcl
30 {
31 
32 Laser::Laser(size_t max_beams, map_t * map)
33 : max_samples_(0), max_obs_(0), temp_obs_(NULL)
34 {
35  max_beams_ = max_beams;
36  map_ = map;
37 }
38 
39 Laser::~Laser()
40 {
41  if (temp_obs_) {
42  for (int k = 0; k < max_samples_; k++) {
43  delete[] temp_obs_[k];
44  }
45  delete[] temp_obs_;
46  }
47 }
48 
49 void
50 Laser::reallocTempData(int new_max_samples, int new_max_obs)
51 {
52  if (temp_obs_) {
53  for (int k = 0; k < max_samples_; k++) {
54  delete[] temp_obs_[k];
55  }
56  delete[] temp_obs_;
57  }
58  max_obs_ = new_max_obs;
59  max_samples_ = fmax(max_samples_, new_max_samples);
60 
61  temp_obs_ = new double *[max_samples_]();
62  for (int k = 0; k < max_samples_; k++) {
63  temp_obs_[k] = new double[max_obs_]();
64  }
65 }
66 
67 void
68 Laser::SetLaserPose(pf_vector_t & laser_pose)
69 {
70  laser_pose_ = laser_pose;
71 }
72 
73 } // namespace nav2_amcl
Laser(size_t max_beams, map_t *map)
A Laser constructor.
Definition: laser.cpp:32
Definition: map.hpp:62