1 | /*********************************************************************
|
---|
2 | // created: 2014/02/11 - 12:08
|
---|
3 | // filename: SickLDMRSData.h
|
---|
4 | //
|
---|
5 | // author: Cyril Fougeray
|
---|
6 | // Copyright Heudiasyc UMR UTC/CNRS 6599
|
---|
7 | //
|
---|
8 | // version: $Id: $
|
---|
9 | //
|
---|
10 | // purpose: Structures to store Sick LDMRS data
|
---|
11 | //
|
---|
12 | *********************************************************************/
|
---|
13 |
|
---|
14 | #ifndef __SICKLDMRS_DATA_H__
|
---|
15 | #define __SICKLDMRS_DATA_H__
|
---|
16 |
|
---|
17 | #include "Pacpus/kernel/cstdint.h"
|
---|
18 | #include "Pacpus/kernel/road_time.h"
|
---|
19 |
|
---|
20 | // Export macro for SickLDMRS DLL for Windows only
|
---|
21 | #ifdef WIN32
|
---|
22 | # ifdef SICKLDMRS_EXPORTS
|
---|
23 | // make DLL
|
---|
24 | # define SICKLDMRS_API __declspec(dllexport)
|
---|
25 | # else
|
---|
26 | // use DLL
|
---|
27 | # define SICKLDMRS_API __declspec(dllimport)
|
---|
28 | # endif
|
---|
29 | #else
|
---|
30 | // On other platforms, simply ignore this
|
---|
31 | # define SICKLDMRS_API
|
---|
32 | #endif
|
---|
33 |
|
---|
34 | namespace pacpus{
|
---|
35 | static const uint32_t MAX_SICKSCAN_POINT = 1100;
|
---|
36 | static const uint32_t MAX_SCAN_POINT_PER_LAYER = 1100;
|
---|
37 |
|
---|
38 | /*!
|
---|
39 | * \brief The DataHeader struct
|
---|
40 | *
|
---|
41 | * The DataHeader struct describes general information about the message used with.
|
---|
42 | * On Sick LDMRS, DataHeader corresponds exactly to the very first data carried into the whole message.
|
---|
43 | * See [Ethernet data protocol LD-MRS, page 4](docs/BAMessdatenProtokoll_LDMRSen_8014492_20110601.pdf).
|
---|
44 | * > Warning : the data from the sensor is coded in Big Endian format.
|
---|
45 | */
|
---|
46 | struct DataHeader {
|
---|
47 | uint32_t magicWord; //!< 0xAFFEC0C2 for the Sick LDMRS sensor (this value must be found in order to decode the message).
|
---|
48 | uint32_t sizePreviousMessage; //!< Size in bytes of the previous message.
|
---|
49 | uint32_t sizeCurrentMessage; //!< Size of the message content without the header (DataHeader).
|
---|
50 | // uint8_t reserved
|
---|
51 | uint8_t deviceId; //!< Unused in data received directly from LD-MRS sensors.
|
---|
52 | uint16_t dataType; //!< Type of information carried into the message.
|
---|
53 | ///< Types used are :
|
---|
54 | ///< - Points : 0x2202
|
---|
55 | ///< - Objects : 0x2221
|
---|
56 | uint64_t ntpTime; //!< Time of the sensor when the message is created
|
---|
57 | };
|
---|
58 |
|
---|
59 |
|
---|
60 | /*!
|
---|
61 | * \brief The ScanHeader struct
|
---|
62 | *
|
---|
63 | * General information about points measured.
|
---|
64 | * Data type is 0x2202
|
---|
65 | * @see DataHeader
|
---|
66 | *
|
---|
67 | * see Ethernet data protocol LD-MRS page 5
|
---|
68 | */
|
---|
69 | struct SICKLDMRS_API ScanHeader {
|
---|
70 | uint16_t scanNumber; //!< Number of the scan since the sensor started measuring.
|
---|
71 | uint16_t scannerStatus; //!< Status of the scanner
|
---|
72 | /**<
|
---|
73 | * - 0x0007: reserved,
|
---|
74 | * - 0x0008: set frequency reached,
|
---|
75 | * - 0x0010: external sync signal detected,
|
---|
76 | * - 0x0020: sync ok,
|
---|
77 | * - 0x0040: sync master (instead of slave),
|
---|
78 | * - 0xFF80: reserved
|
---|
79 | */
|
---|
80 |
|
---|
81 | uint16_t phaseOffset; ///<
|
---|
82 | uint64_t startNtpTime; //!< NTP time first measurement
|
---|
83 | uint64_t endNtpTime; //!< NTP time last measurement
|
---|
84 | uint16_t ticksPerRot; //!< Angle ticks per rotation (used to compute the real angle of a point)
|
---|
85 | int16_t startAngle; //!< Angle of the first measured value
|
---|
86 | int16_t endAngle; //!< Angle of the last measured value
|
---|
87 | uint16_t numPoints; //!< Number of scanned points during this scan @see ScanPoint
|
---|
88 |
|
---|
89 | // mounting position; reference ?
|
---|
90 | // int16_t mountingYawAngle;
|
---|
91 | // int16_t mountingPitchAngle;
|
---|
92 | // int16_t mountingRollAngle;
|
---|
93 | // int16_t mountingX;
|
---|
94 | // int16_t mountingY;
|
---|
95 | // int16_t mountingZ;
|
---|
96 |
|
---|
97 | // uint16_t reserved;
|
---|
98 |
|
---|
99 | };
|
---|
100 |
|
---|
101 |
|
---|
102 | /*!
|
---|
103 | * \brief The ScanPoint struct
|
---|
104 | *
|
---|
105 | * Used to describe a point.
|
---|
106 | * Data type 0x2202 @see DataHeader
|
---|
107 | */
|
---|
108 | struct SICKLDMRS_API ScanPoint{
|
---|
109 | uchar layerEcho; //!< 4 LSB : Layer (scan layer of the point)
|
---|
110 | //!< 4 MSB : Echo
|
---|
111 | uchar flags;
|
---|
112 | int16_t angle; //!< Angle in number of ticks. You can easily compute the real angle :
|
---|
113 | //!< \f$ angle (degree) = \frac{angle (ticks)}{ScanHeader.ticksPerRot}\f$ @see ScanHeader
|
---|
114 |
|
---|
115 | uint16_t distance; //!< Distance of the point from the sensor in centimeters.
|
---|
116 | uint16_t echoPulseWidth; //!< Width of echo pulse (cm)
|
---|
117 | // uint16_t reserved;
|
---|
118 | };
|
---|
119 |
|
---|
120 | /*!
|
---|
121 | * \brief The ScanObject struct (not used)
|
---|
122 | *
|
---|
123 | * Used to describe an object.
|
---|
124 | * Data type 0x2221 @see DataHeader
|
---|
125 | */
|
---|
126 | struct SICKLDMRS_API ScanObject{
|
---|
127 | // TODO
|
---|
128 | };
|
---|
129 |
|
---|
130 |
|
---|
131 |
|
---|
132 | /*! \brief The SickLDMRS_dbt struct
|
---|
133 | *
|
---|
134 | * Data recorded in the DBITE file (.dbt).
|
---|
135 | */
|
---|
136 | typedef struct
|
---|
137 | {
|
---|
138 | uint64_t timeStartFromSensor; //!< NTP time (creation of the message on sensor).
|
---|
139 | ScanHeader hScan; //!< General information about points recorded. @see ScanHeader
|
---|
140 | road_time_t time; //!< DBT timestamp.
|
---|
141 | road_timerange_t timerange; //!< DBT timerange.
|
---|
142 | int32_t dataPos; //!< The position of the data in the binary file associated to the dbt file (utc file).
|
---|
143 | } SickLDMRS_dbt;
|
---|
144 |
|
---|
145 | #ifdef SICKLDMRS_SH_MEM
|
---|
146 | /// Structure to write in shared memory, followed by the points.
|
---|
147 | typedef struct{
|
---|
148 | ScanHeader scanInfo; //!< General information about points recorded. @see ScanHeader
|
---|
149 | road_time_t time; //!< DBT timestamp
|
---|
150 | road_timerange_t timerange; //!< DBT timerange
|
---|
151 |
|
---|
152 | /// In shared memory, followed by ScanPoint[scanInfo.numPoints] @see ScanPoint
|
---|
153 |
|
---|
154 | } SickLDMRS_shMem;
|
---|
155 | #endif
|
---|
156 |
|
---|
157 | }
|
---|
158 |
|
---|
159 | #endif
|
---|