19 #ifndef SNARK_SENSORS_VELODYNE_VELODYNESTREAM_H_
20 #define SNARK_SENSORS_VELODYNE_VELODYNESTREAM_H_
25 #include <snark/sensors/velodyne/stream.h>
26 #include <snark/visiting/eigen.h>
33 boost::posix_time::ptime timestamp;
35 comma::uint32 intensity;
36 std::pair< ::Eigen::Vector3d, ::Eigen::Vector3d > ray;
44 template <
typename S >
49 ,
bool outputInvalidpoints
50 , boost::optional< std::size_t > from = boost::optional< std::size_t >(), boost::optional< std::size_t > to = boost::optional< std::size_t >() );
52 template <
typename P >
54 ,
const velodyne::db& db
55 ,
bool outputInvalidpoints
56 , boost::optional< std::size_t > from = boost::optional< std::size_t >(), boost::optional< std::size_t > to = boost::optional< std::size_t >() );
65 boost::optional< std::size_t > m_to;
68 template <
typename S >
70 , boost::optional< std::size_t > from
71 , boost::optional< std::size_t > to ):
72 m_stream( new S, outputInvalidpoints ),
76 if( from ) {
while( m_stream.scan() < *from ) { m_stream.skipscan(); } }
79 template <
typename S >
80 template <
typename P >
81 velodyne_stream< S >::velodyne_stream (
const P& p,
const velodyne::db& db,
bool outputInvalidpoints
82 , boost::optional< std::size_t > from
83 , boost::optional< std::size_t > to ):
84 m_stream( new S( p ), outputInvalidpoints ),
88 if( from ) {
while( m_stream.scan() < *from ) { m_stream.skipscan(); } }
93 template <
typename S >
96 if( m_to && m_stream.scan() > *m_to )
103 if( r == NULL ) {
return false; }
107 m_point.valid = !comma::math::equal( r->
range, 0 );
108 m_point.ray = m_db.lasers[ m_point.id ].ray( r->
range, r->
azimuth );
109 m_point.range = m_db.lasers[ m_point.id ].range( r->
range );
110 m_point.scan = m_stream.scan();
111 m_point.azimuth = m_db.lasers[ m_point.id ].azimuth( r->
azimuth );
121 velodyne_stream(
const comma::csv::options& options ): m_stream( std::cin, options ) {}
127 comma::csv::input_stream< velodyne_point > m_stream;
148 namespace comma {
namespace visiting {
150 template <>
struct traits< snark::velodyne_point >
154 v.apply(
"t", p.timestamp );
155 v.apply(
"id", p.id );
156 v.apply(
"intensity", p.intensity );
157 v.apply(
"ray", p.ray );
158 v.apply(
"azimuth", p.azimuth );
159 v.apply(
"range", p.range );
160 v.apply(
"valid", p.valid );
161 v.apply(
"scan", p.scan );
164 template <
typename K,
typename V >
static void visit(
const K&,
const snark::velodyne_point& p, V& v )
166 v.apply(
"t", p.timestamp );
167 v.apply(
"id", p.id );
168 v.apply(
"intensity", p.intensity );
169 v.apply(
"ray", p.ray );
170 v.apply(
"azimuth", p.azimuth );
171 v.apply(
"range", p.range );
172 v.apply(
"valid", p.valid );
173 v.apply(
"scan", p.scan );
179 #endif // SNARK_SENSORS_VELODYNE_VELODYNESTREAM_H_