[37] | 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 |
|
---|
| 36 | /*!
|
---|
| 37 | * \brief The DataHeader struct
|
---|
| 38 | *
|
---|
| 39 | * The DataHeader struct describes general information about the message used with.
|
---|
| 40 | * On Sick LDMRS, DataHeader corresponds exactly to the very first data carried into the whole message.
|
---|
| 41 | * See [Ethernet data protocol LD-MRS, page 4](docs/BAMessdatenProtokoll_LDMRSen_8014492_20110601.pdf).
|
---|
| 42 | * > Warning : the data from the sensor is coded in Big Endian format.
|
---|
| 43 | */
|
---|
| 44 | struct DataHeader {
|
---|
| 45 | u_int32_t magicWord; //!< 0xAFFEC0C2 for the Sick LDMRS sensor (this value must be found in order to decode the message).
|
---|
| 46 | u_int32_t sizePreviousMessage; //!< Size in bytes of the previous message.
|
---|
| 47 | u_int32_t sizeCurrentMessage; //!< Size of the message content without the header (DataHeader).
|
---|
| 48 | // u_int8_t reserved
|
---|
| 49 | u_int8_t deviceId; //!< Unused in data received directly from LD-MRS sensors.
|
---|
| 50 | u_int16_t dataType; //!< Type of information carried into the message.
|
---|
| 51 | ///< Types used are :
|
---|
| 52 | ///< - Points : 0x2202
|
---|
| 53 | ///< - Objects : 0x2221
|
---|
| 54 | u_int64_t ntpTime; //!< Time of the sensor when the message is created
|
---|
| 55 | };
|
---|
[52] | 56 |
|
---|
| 57 |
|
---|
[37] | 58 | /*!
|
---|
| 59 | * \brief The ScanHeader struct
|
---|
| 60 | *
|
---|
| 61 | * General information about points measured.
|
---|
| 62 | * Data type is 0x2202
|
---|
| 63 | * @see DataHeader
|
---|
| 64 | *
|
---|
| 65 | * see Ethernet data protocol LD-MRS page 5
|
---|
| 66 | */
|
---|
| 67 | struct SICKLDMRS_API ScanHeader {
|
---|
| 68 | u_int16_t scanNumber; //!< Number of the scan since the sensor started measuring.
|
---|
| 69 | u_int16_t scannerStatus; //!< Status of the scanner
|
---|
| 70 | /**<
|
---|
| 71 | * - 0x0007: reserved,
|
---|
| 72 | * - 0x0008: set frequency reached,
|
---|
| 73 | * - 0x0010: external sync signal detected,
|
---|
| 74 | * - 0x0020: sync ok,
|
---|
| 75 | * - 0x0040: sync master (instead of slave),
|
---|
| 76 | * - 0xFF80: reserved
|
---|
| 77 | */
|
---|
| 78 |
|
---|
| 79 | u_int16_t phaseOffset; ///<
|
---|
| 80 | u_int64_t startNtpTime; //!< NTP time first measurement
|
---|
| 81 | u_int64_t endNtpTime; //!< NTP time last measurement
|
---|
| 82 | u_int16_t ticksPerRot; //!< Angle ticks per rotation (used to compute the real angle of a point)
|
---|
| 83 | int16_t startAngle; //!< Angle of the first measured value
|
---|
| 84 | int16_t endAngle; //!< Angle of the last measured value
|
---|
| 85 | u_int16_t numPoints; //!< Number of scanned points during this scan @see ScanPoint
|
---|
| 86 |
|
---|
| 87 | // mounting position; reference ?
|
---|
| 88 | // int16_t mountingYawAngle;
|
---|
| 89 | // int16_t mountingPitchAngle;
|
---|
| 90 | // int16_t mountingRollAngle;
|
---|
| 91 | // int16_t mountingX;
|
---|
| 92 | // int16_t mountingY;
|
---|
| 93 | // int16_t mountingZ;
|
---|
| 94 |
|
---|
| 95 | // u_int16_t reserved;
|
---|
| 96 |
|
---|
| 97 | };
|
---|
| 98 |
|
---|
| 99 |
|
---|
| 100 | /*!
|
---|
| 101 | * \brief The ScanPoint struct
|
---|
| 102 | *
|
---|
| 103 | * Used to describe a point.
|
---|
| 104 | * Data type 0x2202 @see DataHeader
|
---|
| 105 | */
|
---|
| 106 | struct SICKLDMRS_API ScanPoint{
|
---|
| 107 | u_char layerEcho; //!< 4 LSB : Layer (scan layer of the point)
|
---|
| 108 | //!< 4 MSB : Echo
|
---|
| 109 | u_char flags;
|
---|
| 110 | u_int16_t angle; //!< Angle in number of ticks. You can easily compute the real angle :
|
---|
| 111 | //!< \f$ angle (degree) = \frac{angle (ticks)}{ScanHeader.ticksPerRot}\f$ @see ScanHeader
|
---|
| 112 |
|
---|
| 113 | u_int16_t distance; //!< Distance of the point from the sensor in centimeters.
|
---|
| 114 | u_int16_t echoPulseWidth; //!< Width of echo pulse (cm)
|
---|
| 115 | // u_int16_t reserved;
|
---|
| 116 | };
|
---|
| 117 |
|
---|
| 118 | /*!
|
---|
| 119 | * \brief The ScanObject struct (not used)
|
---|
| 120 | *
|
---|
| 121 | * Used to describe an object.
|
---|
| 122 | * Data type 0x2221 @see DataHeader
|
---|
| 123 | */
|
---|
| 124 | struct SICKLDMRS_API ScanObject{
|
---|
| 125 | // TODO
|
---|
| 126 | };
|
---|
| 127 |
|
---|
| 128 |
|
---|
| 129 |
|
---|
| 130 | /*! \brief The SickLDMRS_dbt struct
|
---|
| 131 | *
|
---|
| 132 | * Data recorded in the DBITE file (.dbt).
|
---|
| 133 | */
|
---|
| 134 | typedef struct
|
---|
| 135 | {
|
---|
| 136 | u_int64_t timeStartFromSensor; //!< NTP time (creation of the message on sensor).
|
---|
| 137 | ScanHeader hScan; //!< General information about points recorded. @see ScanHeader
|
---|
[43] | 138 | road_time_t time; //!< DBT timestamp.
|
---|
| 139 | road_timerange_t timerange; //!< DBT timerange.
|
---|
[37] | 140 | int32_t dataPos; //!< The position of the data in the binary file associated to the dbt file (utc file).
|
---|
| 141 | } SickLDMRS_dbt;
|
---|
| 142 |
|
---|
| 143 |
|
---|
| 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
|
---|