snark
db.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_DB_H_
20 #define SNARK_SENSORS_VELODYNE_DB_H_
21 
22 #include <boost/array.hpp>
23 #include <comma/base/types.h>
24 #include <Eigen/Core>
25 #include <snark/sensors/velodyne/impl/serializable_db.h>
26 
27 namespace snark { namespace velodyne {
28 
29 struct db
30 {
31  struct laser_data
32  {
33  struct angle
34  {
35  double value;
36  double sin;
37  double cos;
38 
39  angle();
40  angle( const angle& rhs );
41  angle( double v );
42  angle( double v, double s, double c );
43  };
44 
45  struct corrention_angles_type
46  {
47  angle rotational;
48  angle vertical;
49  };
50 
51  double horizontal_offset;
52 
53  double vertical_offset;
54 
55  double distance_correction;
56 
57  corrention_angles_type correction_angles;
58 
59  laser_data();
60 
61  laser_data( comma::uint32 id, double horizOffsetCorrection, double vertOffsetCorrection, double distCorrection, angle rotCorrection, angle vertCorrection );
62 
63  std::pair< ::Eigen::Vector3d, ::Eigen::Vector3d > ray( double range, double angle ) const;
64 
65  ::Eigen::Vector3d point( double range, double angle ) const;
66 
67  double range( double range ) const;
68 
69  double azimuth( double azimuth ) const;
70  };
71 
72  boost::array< laser_data, 64 > lasers;
73 
74  db();
75 
76  db( const db& db );
77 
78  db( const std::string& filename );
79 
80  static bool is_upper( unsigned int laser );
81 
82  static bool is_lower( unsigned int laser );
83 
84  void operator<<( std::istream& s );
85 };
86 
87 template < class Istream > inline void operator>>( Istream& s, db& db ) { db << s; }
88 
89 } } // namespace snark { namespace velodyne {
90 
91 #endif // SNARK_SENSORS_VELODYNE_DB_H_