scansegment_parser_output.h
Go to the documentation of this file.
1 #include "sick_scan/sick_scan_base.h" /* Base definitions included in all header files, added by add_sick_scan_base_header.py. Do not edit this line. */
2 /*
3  * @brief class ScanSegmentParserOutput is the output container for unpacked and converted msgpack and compact data for multiScan136 and picoScan.
4  * In case of multiScan136, ScanSegmentParserOutput has 16 groups (layers), each group has 3 echos, each echo has a list of LidarPoint data in catesian coordinates
5  * (x, y, z in meter and intensity). In case of picoScan, ScanSegmentParserOutput has 1 layer.
6  *
7  * Usage example for msgpack data:
8  *
9  * std::ifstream msgpack_istream("polarscan_testdata_000.msg", std::ios::binary);
10  * sick_scansegment_xd::ScanSegmentParserOutput scansegment_output;
11  * sick_scansegment_xd::MsgPackParser::Parse(msgpack_istream, scansegment_output);
12  *
13  * sick_scansegment_xd::MsgPackParser::WriteCSV({ scansegment_output }, "polarscan_testdata_000.csv")
14  *
15  * for (int groupIdx = 0; groupIdx < scansegment_output.scandata.size(); groupIdx++)
16  * {
17  * for (int echoIdx = 0; echoIdx < scansegment_output.scandata[groupIdx].size(); echoIdx++)
18  * {
19  * std::vector<sick_scansegment_xd::ScanSegmentParserOutput::LidarPoint>& scanline = scansegment_output.scandata[groupIdx][echoIdx];
20  * std::cout << (groupIdx + 1) << ". group, " << (echoIdx + 1) << ". echo: ";
21  * for (int pointIdx = 0; pointIdx < scanline.size(); pointIdx++)
22  * {
23  * sick_scansegment_xd::ScanSegmentParserOutput::PointXYZI& point = scanline[pointIdx];
24  * std::cout << (pointIdx > 0 ? "," : "") << "(" << point.x << "," << point.y << "," << point.z << "," << point.i << ")";
25  * }
26  * std::cout << std::endl;
27  * }
28  * }
29  *
30  * Copyright (C) 2020 Ing.-Buero Dr. Michael Lehning, Hildesheim
31  * Copyright (C) 2020 SICK AG, Waldkirch
32  *
33  * Licensed under the Apache License, Version 2.0 (the "License");
34  * you may not use this file except in compliance with the License.
35  * You may obtain a copy of the License at
36  *
37  * http://www.apache.org/licenses/LICENSE-2.0
38  *
39  * Unless required by applicable law or agreed to in writing, software
40  * distributed under the License is distributed on an "AS IS" BASIS,
41  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
42  * See the License for the specific language governing permissions and
43  * limitations under the License.
44  *
45  * All rights reserved.
46  *
47  * Redistribution and use in source and binary forms, with or without
48  * modification, are permitted provided that the following conditions are met:
49  *
50  * * Redistributions of source code must retain the above copyright
51  * notice, this list of conditions and the following disclaimer.
52  * * Redistributions in binary form must reproduce the above copyright
53  * notice, this list of conditions and the following disclaimer in the
54  * documentation and/or other materials provided with the distribution.
55  * * Neither the name of SICK AG nor the names of its
56  * contributors may be used to endorse or promote products derived from
57  * this software without specific prior written permission
58  * * Neither the name of Ing.-Buero Dr. Michael Lehning nor the names of its
59  * contributors may be used to endorse or promote products derived from
60  * this software without specific prior written permission
61  *
62  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
63  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
64  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
65  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
66  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
67  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
68  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
69  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
70  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
71  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
72  * POSSIBILITY OF SUCH DAMAGE.
73  *
74  * Authors:
75  * Michael Lehning <michael.lehning@lehning.de>
76  *
77  * Copyright 2020 SICK AG
78  * Copyright 2020 Ing.-Buero Dr. Michael Lehning
79  *
80  */
81 #ifndef __SICK_SCANSEGMENT_XD_PARSER_OUTPUT_H
82 #define __SICK_SCANSEGMENT_XD_PARSER_OUTPUT_H
83 
85 
86 namespace sick_scansegment_xd
87 {
88  /*
89  * @brief class ScanSegmentParserConfig is a container for configuration and settings for multiScan and picoScan parser
90  */
92  {
93  public:
94  int imu_latency_microsec = 0; // imu latency in microseconds
95  };
96 
97 
98  /*
99  * @brief class CompactImuData is a container for imu data in compact format
100  */
102  {
103  public:
104  bool valid = false;
105  float acceleration_x = 0; // 4 bytes float in m/s^2, acceleration along the x-axis including gravity
106  float acceleration_y = 0; // 4 bytes float in m/s^2, acceleration along the y-axis including gravity
107  float acceleration_z = 0; // 4 bytes float in m/s^2, acceleration along the z-axis including gravity
108  float angular_velocity_x = 0; // 4 bytes float in rad/s
109  float angular_velocity_y = 0; // 4 bytes float in rad/s
110  float angular_velocity_z = 0; // 4 bytes float in rad/s
111  float orientation_w = 0; // 4 bytes float, orientation quaternion w
112  float orientation_x = 0; // 4 bytes float, orientation quaternion x
113  float orientation_y = 0; // 4 bytes float, orientation quaternion y
114  float orientation_z = 0; // 4 bytes float, orientation quaternion z
115  std::string to_string() const; // returns a human readable description of the imu data
116  };
117 
119  {
120  public:
121 
123 
124  /*
125  * @brief class LidarPoint is a data point in cartesian coordinates with x, y, z in meter and an intensity value.
126  * Additionally, polar coordinates with azimuth and elevation in radians and distance in meter are given plus the
127  * group index (0 up to 15 for multiScan136) and the echo index (0 up to 2).
128  */
130  {
131  public:
132  LidarPoint() : x(0), y(0), z(0), i(0), range(0), azimuth(0), elevation(0), groupIdx(0), echoIdx(0), pointIdx(0), lidar_timestamp_microsec(0), reflectorbit(0) {}
133  LidarPoint(float _x, float _y, float _z, float _i, float _range, float _azimuth, float _elevation, int _groupIdx, int _echoIdx, int _pointIdx, uint64_t _lidar_timestamp_microsec, uint8_t _reflector_bit)
134  : x(_x), y(_y), z(_z), i(_i), range(_range), azimuth(_azimuth), elevation(_elevation), groupIdx(_groupIdx), echoIdx(_echoIdx), pointIdx(_pointIdx), lidar_timestamp_microsec(_lidar_timestamp_microsec), reflectorbit(_reflector_bit) {}
135  float x; // cartesian x coordinate in meter
136  float y; // cartesian y coordinate in meter
137  float z; // cartesian z coordinate in meter
138  float i; // intensity
139  float range; // polar coordinate range in meter
140  float azimuth; // polar coordinate azimuth in radians
141  float elevation; // polar coordinate elevation in radians
142  int groupIdx; // group index (layer), 0 <= groupIdx < 16 for multiScan136
143  int echoIdx; // echo index, 0 <= echoIdx < 3 for multiScan136
144  int pointIdx; // point index, 0 <= pointIdx < 30 resp. 0 <= pointIdx < 240 for multiScan136
145  uint64_t lidar_timestamp_microsec; // lidar timestamp in microseconds
146  uint8_t reflectorbit; // optional reflector bit, 0 or 1, default: 0
147  };
148 
149  /*
150  * @brief type Scanline is a vector of LidarPoint data. multiScan136 and picoScan transmit up to 3 echos, each echo is a Scanline.
151  */
152  class Scanline
153  {
154  public:
155  std::vector<LidarPoint> points; // list of all scan points
156  };
157 
158  /*
159  * @brief type Scangroup is a vector of Scanlines. multiScan136 transmits 16 groups (layers), each group has max. 3 echos (3 scanlines).
160  */
161  class Scangroup
162  {
163  public:
169  std::vector<Scanline> scanlines;
170  };
171 
172  /*
173  * @brief scandata contains all data of a msgpack or compact scan.
174  */
175  std::vector<Scangroup> scandata;
176 
177  /*
178  * @brief optional imu data
179  */
181 
182  /*
183  * @brief Timestamp of scandata (message received time or measurement time)
184  */
185  std::string timestamp; // timestamp in string format "<seconds>.<mikroseconds>"
186  uint32_t timestamp_sec; // seconds part of timestamp
187  uint32_t timestamp_nsec; // nanoseconds part of timestamp
188 
189  /*
190  * @brief Counter for each message (each scandata decoded from msgpack or compact data)
191  */
194  };
195 
196  /*
197  * @brief return a formatted timestamp "<sec>.<millisec>".
198  * @param[in] sec second part of timestamp
199  * @param[in] nsec nanosecond part of timestamp
200  * @return "<sec>.<millisec>"
201  */
202  std::string Timestamp(uint32_t sec, uint32_t nsec);
203 
204  /*
205  * @brief return a timestamp of the current time (i.e. std::chrono::system_clock::now() formatted by "YYYY-MM-DD hh-mm-ss.msec").
206  */
207  std::string Timestamp(const std::chrono::system_clock::time_point& now);
208 }
209 #endif // __SICK_SCANSEGMENT_XD_PARSER_OUTPUT_H
sick_scansegment_xd::ScanSegmentParserOutput::LidarPoint::range
float range
Definition: scansegment_parser_output.h:139
sick_scansegment_xd::ScanSegmentParserOutput::LidarPoint::elevation
float elevation
Definition: scansegment_parser_output.h:141
sick_scansegment_xd::ScanSegmentParserOutput::imudata
CompactImuData imudata
Definition: scansegment_parser_output.h:180
sick_scansegment_xd::ScanSegmentParserOutput::LidarPoint::LidarPoint
LidarPoint(float _x, float _y, float _z, float _i, float _range, float _azimuth, float _elevation, int _groupIdx, int _echoIdx, int _pointIdx, uint64_t _lidar_timestamp_microsec, uint8_t _reflector_bit)
Definition: scansegment_parser_output.h:133
sick_scansegment_xd::Timestamp
std::string Timestamp(uint32_t sec, uint32_t nsec)
Definition: scansegment_parser_output.cpp:100
sick_scansegment_xd::ScanSegmentParserOutput::LidarPoint::echoIdx
int echoIdx
Definition: scansegment_parser_output.h:143
sick_scansegment_xd::CompactImuData::acceleration_z
float acceleration_z
Definition: scansegment_parser_output.h:107
sick_scansegment_xd::ScanSegmentParserOutput::ScanSegmentParserOutput
ScanSegmentParserOutput()
Definition: scansegment_parser_output.cpp:90
sick_scansegment_xd::ScanSegmentParserOutput::LidarPoint::z
float z
Definition: scansegment_parser_output.h:137
sick_scansegment_xd::ScanSegmentParserOutput::LidarPoint::azimuth
float azimuth
Definition: scansegment_parser_output.h:140
sick_scansegment_xd::ScanSegmentParserOutput::LidarPoint::lidar_timestamp_microsec
uint64_t lidar_timestamp_microsec
Definition: scansegment_parser_output.h:145
sick_scansegment_xd::CompactImuData::orientation_z
float orientation_z
Definition: scansegment_parser_output.h:114
sick_scansegment_xd::ScanSegmentParserOutput::timestamp_nsec
uint32_t timestamp_nsec
Definition: scansegment_parser_output.h:187
sick_scansegment_xd
Definition: include/sick_scansegment_xd/common.h:138
sick_scansegment_xd::ScanSegmentParserOutput::LidarPoint::pointIdx
int pointIdx
Definition: scansegment_parser_output.h:144
sick_scansegment_xd::CompactImuData::angular_velocity_x
float angular_velocity_x
Definition: scansegment_parser_output.h:108
sick_scansegment_xd::ScanSegmentParserOutput::LidarPoint::groupIdx
int groupIdx
Definition: scansegment_parser_output.h:142
sick_scansegment_xd::ScanSegmentParserOutput::Scangroup::timestampStop_sec
uint32_t timestampStop_sec
Definition: scansegment_parser_output.h:167
sick_scansegment_xd::CompactImuData::to_string
std::string to_string() const
Definition: compact_parser.cpp:150
sick_scansegment_xd::ScanSegmentParserOutput::Scangroup::timestampStart_sec
uint32_t timestampStart_sec
Definition: scansegment_parser_output.h:165
sick_scansegment_xd::CompactImuData::angular_velocity_y
float angular_velocity_y
Definition: scansegment_parser_output.h:109
sick_ros_wrapper.h
sick_scansegment_xd::ScanSegmentParserOutput::segmentIndex
int segmentIndex
Definition: scansegment_parser_output.h:192
sick_scansegment_xd::CompactImuData::acceleration_x
float acceleration_x
Definition: scansegment_parser_output.h:105
sick_scansegment_xd::ScanSegmentParserOutput::LidarPoint::y
float y
Definition: scansegment_parser_output.h:136
ROS::now
ROS::Time now(void)
Definition: ros_wrapper.cpp:116
sick_scansegment_xd::ScanSegmentParserConfig::imu_latency_microsec
int imu_latency_microsec
Definition: scansegment_parser_output.h:94
nsec
uint32_t nsec(const rosTime &time)
Definition: sick_ros_wrapper.h:175
sick_scansegment_xd::ScanSegmentParserOutput::LidarPoint::reflectorbit
uint8_t reflectorbit
Definition: scansegment_parser_output.h:146
sick_scansegment_xd::ScanSegmentParserOutput
Definition: scansegment_parser_output.h:118
sick_scansegment_xd::ScanSegmentParserOutput::telegramCnt
int telegramCnt
Definition: scansegment_parser_output.h:193
sick_scansegment_xd::ScanSegmentParserOutput::LidarPoint::x
float x
Definition: scansegment_parser_output.h:135
sick_scansegment_xd::ScanSegmentParserOutput::LidarPoint
Definition: scansegment_parser_output.h:129
sick_scansegment_xd::ScanSegmentParserOutput::Scangroup::timestampStop_nsec
uint32_t timestampStop_nsec
Definition: scansegment_parser_output.h:168
sec
uint32_t sec(const rosTime &time)
Definition: sick_ros_wrapper.h:174
sick_scansegment_xd::ScanSegmentParserOutput::LidarPoint::i
float i
Definition: scansegment_parser_output.h:138
sick_scansegment_xd::CompactImuData::angular_velocity_z
float angular_velocity_z
Definition: scansegment_parser_output.h:110
sick_scansegment_xd::ScanSegmentParserOutput::Scangroup::scanlines
std::vector< Scanline > scanlines
Definition: scansegment_parser_output.h:169
sick_scansegment_xd::ScanSegmentParserOutput::timestamp_sec
uint32_t timestamp_sec
Definition: scansegment_parser_output.h:186
sick_scan_base.h
sick_scansegment_xd::CompactImuData::orientation_x
float orientation_x
Definition: scansegment_parser_output.h:112
sick_scansegment_xd::ScanSegmentParserOutput::scandata
std::vector< Scangroup > scandata
Definition: scansegment_parser_output.h:175
sick_scansegment_xd::ScanSegmentParserOutput::Scanline
Definition: scansegment_parser_output.h:152
sick_scansegment_xd::ScanSegmentParserOutput::Scangroup::Scangroup
Scangroup()
Definition: scansegment_parser_output.h:164
sick_scansegment_xd::ScanSegmentParserOutput::LidarPoint::LidarPoint
LidarPoint()
Definition: scansegment_parser_output.h:132
sick_scansegment_xd::CompactImuData::acceleration_y
float acceleration_y
Definition: scansegment_parser_output.h:106
sick_scansegment_xd::CompactImuData::orientation_w
float orientation_w
Definition: scansegment_parser_output.h:111
sick_scansegment_xd::ScanSegmentParserConfig
Definition: scansegment_parser_output.h:91
sick_scansegment_xd::ScanSegmentParserOutput::Scangroup::timestampStart_nsec
uint32_t timestampStart_nsec
Definition: scansegment_parser_output.h:166
sick_scansegment_xd::CompactImuData
Definition: scansegment_parser_output.h:101
sick_scansegment_xd::CompactImuData::orientation_y
float orientation_y
Definition: scansegment_parser_output.h:113
sick_scansegment_xd::ScanSegmentParserOutput::Scanline::points
std::vector< LidarPoint > points
Definition: scansegment_parser_output.h:155
sick_scansegment_xd::CompactImuData::valid
bool valid
Definition: scansegment_parser_output.h:104
sick_scansegment_xd::ScanSegmentParserOutput::Scangroup
Definition: scansegment_parser_output.h:161
sick_scansegment_xd::ScanSegmentParserOutput::timestamp
std::string timestamp
Definition: scansegment_parser_output.h:185


sick_scan_xd
Author(s): Michael Lehning , Jochen Sprickerhof , Martin Günther
autogenerated on Fri Oct 25 2024 02:47:10