19 #ifndef SNARK_SENSORS_VELODYNE_THIN_READER_H_
20 #define SNARK_SENSORS_VELODYNE_THIN_READER_H_
25 #include <snark/sensors/velodyne/thin/thin.h>
26 #include <snark/timing/time.h>
36 if( !std::cin.good() || std::cin.eof() ) {
return NULL; }
38 std::cin.read( reinterpret_cast< char* >( &size ), 2 );
39 if( std::cin.gcount() < 2 ) {
return NULL; }
40 std::cin.read( m_buf, size );
41 if( std::cin.gcount() < size ) {
return NULL; }
43 comma::int32 nanoseconds;
44 ::memcpy( &seconds, m_buf,
sizeof( comma::int64 ) );
45 ::memcpy( &nanoseconds, m_buf +
sizeof( comma::int64 ),
sizeof( comma::int32 ) );
46 m_timestamp = boost::posix_time::ptime( snark::timing::epoch, boost::posix_time::seconds( static_cast< long >( seconds ) ) + boost::posix_time::microseconds( nanoseconds / 1000 ) );
47 velodyne::thin::deserialize( m_packet, m_buf + timeSize );
48 return reinterpret_cast< char*
>( &m_packet );
53 boost::posix_time::ptime timestamp()
const {
return m_timestamp; }
56 enum { timeSize = 12 };
57 char m_buf[ velodyne::thin::maxBufferSize + timeSize ];
58 velodyne::packet m_packet;
59 boost::posix_time::ptime m_timestamp;
64 #endif // SNARK_SENSORS_VELODYNE_THIN_READER_H_