snark
scan.h
1 // This file is part of snark, a generic and flexible library
2 // for robotics research.
3 //
4 // Copyright (C) 2011 The University of Sydney
5 //
6 // snark 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 3 of the License, or (at your option) any later version.
10 //
11 // snark is distributed in the hope that it will be useful, but WITHOUT ANY
12 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
14 // for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with snark. If not, see <http://www.gnu.org/licenses/>.
18 
19 #ifndef SNARK_SENSORS_VELODYNE_THIN_SCAN
20 #define SNARK_SENSORS_VELODYNE_THIN_SCAN
21 
22 #include <snark/sensors/velodyne/packet.h>
23 
24 namespace snark { namespace velodyne { namespace thin {
25 
26 class scan
27 {
28 public:
29  scan();
30  void thin( velodyne::packet& packet, double rate, double angularSpeed );
31  bool empty() const { return m_empty; }
32 private:
33  enum { m_size = 12 * 32 };
34  struct index
35  {
36  unsigned int idx;
37  unsigned int block;
38  unsigned int laser;
39  index() : idx( 0 ), block( 0 ), laser( 0 ) {}
40  const index& operator++()
41  {
42  ++idx;
43  if( block & 0x1 )
44  {
45  ++laser;
46  if( laser < 32 ) { --block; } else { laser = 0; ++block; }
47  }
48  else
49  {
50  ++block;
51  }
52  return *this;
53  }
54  bool operator==( const index& rhs ) const { return idx == rhs.idx; }
55  };
56  unsigned int m_scan;
57  unsigned int m_count;
58  bool m_closed;
59  unsigned int m_output;
60  bool m_outputCurrentscan;
61  bool m_empty;
62 };
63 
64 
65 } } } // namespace snark { namespace velodyne { namespace thin {
66 
67 #endif // SNARK_SENSORS_VELODYNE_THIN_SCAN
68