19 #ifndef SNARK_SENSORS_VELODYNE_PACKET_H_
20 #define SNARK_SENSORS_VELODYNE_PACKET_H_
22 #include <boost/array.hpp>
23 #include <boost/static_assert.hpp>
24 #include <comma/base/types.h>
25 #include <comma/packed/byte.h>
26 #include <comma/packed/little_endian.h>
27 #include <comma/packed/string.h>
28 #include <comma/packed/struct.h>
30 namespace snark {
namespace velodyne {
32 struct packet :
public comma::packed::packed_struct< packet, 1206 >
34 struct laser_return :
public comma::packed::packed_struct< laser_return, 3 >
36 comma::packed::uint16 range;
37 comma::packed::byte intensity;
40 struct laser_block :
public comma::packed::packed_struct< laser_block, 2 + 2 + 32 * sizeof( laser_return ) >
42 comma::packed::string< 2 > id;
43 comma::packed::uint16 rotation;
44 boost::array< laser_return, 32 > lasers;
47 struct status :
public comma::packed::packed_struct< status, 6 >
49 struct temperature :
public comma::packed::packed_struct< temperature, 6 >
51 comma::packed::byte fractions;
52 comma::packed::byte degrees;
53 comma::packed::string< 4 > text;
54 bool valid()
const {
return text() ==
"DegC"; }
57 struct version :
public comma::packed::packed_struct< version, 6 >
59 comma::packed::string< 2 > padding;
60 comma::packed::uint16 counter;
61 comma::packed::uint16 number;
62 bool valid()
const { return ::memcmp( data() + 2,
"DegC", 4 ) != 0; }
65 template <
class T >
const T& as()
const {
return reinterpret_cast< const T&
>( *this ); }
66 template <
class T > T& As() {
return reinterpret_cast< T&
>( *this ); }
67 boost::array< comma::packed::byte, 6 > value;
70 static const char* upper_block_id() {
return "\xFF\xEE"; }
72 static const char* lower_block_id() {
return "\xFF\xDD"; }
74 boost::array< laser_block, 12 > blocks;