generated from tier4/ros2-project-template
-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
128 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
103 changes: 103 additions & 0 deletions
103
...la_decoders/include/nebula_decoders/nebula_decoders_velodyne/decoders/velodyne_packet.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
#pragma once | ||
|
||
#include <cstddef> | ||
#include <cstdint> | ||
#include <ctime> | ||
|
||
namespace nebula | ||
{ | ||
namespace drivers | ||
{ | ||
namespace velodyne_packet | ||
{ | ||
|
||
/** | ||
* Raw Velodyne packet constants and structures. | ||
*/ | ||
static const int SIZE_BLOCK = 100; | ||
static const int RAW_SCAN_SIZE = 3; // TODO: remove | ||
static const int RAW_CHANNEL_SIZE = 3; | ||
static const int SCANS_PER_BLOCK = 32; // TODO: remove | ||
static const int CHANNELS_PER_BLOCK = 32; | ||
static const int BLOCK_DATA_SIZE = (SCANS_PER_BLOCK * RAW_SCAN_SIZE); | ||
|
||
static const double ROTATION_RESOLUTION = 0.01; // [deg] | ||
static const uint16_t ROTATION_MAX_UNITS = 36000u; // [deg/100] | ||
|
||
static const size_t RETURN_MODE_INDEX = 1204; | ||
|
||
/** @todo make this work for both big and little-endian machines */ | ||
static const uint16_t UPPER_BANK = 0xeeff; | ||
static const uint16_t LOWER_BANK = 0xddff; | ||
|
||
/** Return Modes **/ | ||
static const uint16_t RETURN_MODE_STRONGEST = 55; | ||
static const uint16_t RETURN_MODE_LAST = 56; | ||
static const uint16_t RETURN_MODE_DUAL = 57; | ||
|
||
const int PACKET_SIZE = 1206; | ||
const int BLOCKS_PER_PACKET = 12; | ||
const int PACKET_STATUS_SIZE = 4; | ||
const int SCANS_PER_PACKET = (SCANS_PER_BLOCK * BLOCKS_PER_PACKET); | ||
const int POINTS_PER_PACKET = (SCANS_PER_PACKET * RAW_SCAN_SIZE); | ||
|
||
#pragma pack(push, 1) | ||
/** \brief Raw Velodyne data block. | ||
* | ||
* Each block contains data from either the upper or lower laser | ||
* bank. The device returns three times as many upper bank blocks. | ||
* | ||
* use stdint.h types, so things work with both 64 and 32-bit machines | ||
*/ | ||
typedef struct raw_block | ||
{ | ||
uint16_t header; ///< UPPER_BANK or LOWER_BANK | ||
uint16_t rotation; ///< 0-35999, divide by 100 to get degrees | ||
uint8_t data[BLOCK_DATA_SIZE]; | ||
} raw_block_t; | ||
|
||
/** \brief Raw Velodyne packet. | ||
* | ||
* revolution is described in the device manual as incrementing | ||
* (mod 65536) for each physical turn of the device. Our device | ||
* seems to alternate between two different values every third | ||
* packet. One value increases, the other decreases. | ||
* | ||
* \todo figure out if revolution is only present for one of the | ||
* two types of status fields | ||
* | ||
* status has either a temperature encoding or the microcode level | ||
*/ | ||
typedef struct raw_packet | ||
{ | ||
raw_block_t blocks[BLOCKS_PER_PACKET]; | ||
uint16_t revolution; | ||
uint8_t status[PACKET_STATUS_SIZE]; | ||
} raw_packet_t; | ||
#pragma pack(pop) | ||
|
||
/** used for unpacking the first two data bytes in a block | ||
* | ||
* They are packed into the actual data stream misaligned. I doubt | ||
* this works on big endian machines. | ||
*/ | ||
union two_bytes { | ||
uint16_t uint; | ||
uint8_t bytes[2]; | ||
}; | ||
|
||
/** \brief Velodyne echo types */ | ||
enum RETURN_TYPE { | ||
INVALID = 0, | ||
SINGLE_STRONGEST = 1, | ||
SINGLE_LAST = 2, | ||
DUAL_STRONGEST_FIRST = 3, | ||
DUAL_STRONGEST_LAST = 4, | ||
DUAL_WEAK_FIRST = 5, | ||
DUAL_WEAK_LAST = 6, | ||
DUAL_ONLY = 7 | ||
}; | ||
|
||
} // namespace hesai_packet | ||
} // namespace drivers | ||
} // namespace nebula |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters