ldq.h
Go to the documentation of this file.
1 //
2 // The MIT License (MIT)
3 //
4 // Copyright (c) 2019 Livox. All rights reserved.
5 //
6 // Permission is hereby granted, free of charge, to any person obtaining a copy
7 // of this software and associated documentation files (the "Software"), to deal
8 // in the Software without restriction, including without limitation the rights
9 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 // copies of the Software, and to permit persons to whom the Software is
11 // furnished to do so, subject to the following conditions:
12 //
13 // The above copyright notice and this permission notice shall be included in
14 // all copies or substantial portions of the Software.
15 //
16 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 // SOFTWARE.
23 //
24 
25 // livox lidar data queue
26 
27 #ifndef LIVOX_ROS_DRIVER_LDQ_H_
28 #define LIVOX_ROS_DRIVER_LDQ_H_
29 
30 #include <stdint.h>
31 
32 namespace livox_ros {
33 
35 
36 #pragma pack(1)
37 
38 typedef struct {
43 
44 #pragma pack()
45 
46 typedef struct {
48  volatile uint32_t rd_idx;
49  volatile uint32_t wr_idx;
53 
54 inline static bool IsPowerOf2(uint32_t size) {
55  return (size != 0) && ((size & (size - 1)) == 0);
56 }
57 
58 inline static uint32_t RoundupPowerOf2(uint32_t size) {
59  uint32_t power2_val = 0;
60  for (int i = 0; i < 32; i++) {
61  power2_val = ((uint32_t)1) << i;
62  if (size <= power2_val) {
63  break;
64  }
65  }
66 
67  return power2_val;
68 }
69 
71 int InitQueue(LidarDataQueue *queue, uint32_t queue_size);
72 int DeInitQueue(LidarDataQueue *queue);
73 void ResetQueue(LidarDataQueue *queue);
74 void QueuePrePop(LidarDataQueue *queue, StoragePacket *storage_packet);
75 void QueuePopUpdate(LidarDataQueue *queue);
76 uint32_t QueuePop(LidarDataQueue *queue, StoragePacket *storage_packet);
81 uint32_t QueuePush(LidarDataQueue *queue, StoragePacket *storage_packet);
83  uint64_t time_rcv, uint32_t point_num);
84 
85 } // namespace livox_ros
86 #endif
static uint32_t RoundupPowerOf2(uint32_t size)
Definition: ldq.h:58
void QueuePrePop(LidarDataQueue *queue, StoragePacket *storage_packet)
Definition: ldq.cpp:77
void ResetQueue(LidarDataQueue *queue)
Definition: ldq.cpp:72
uint32_t QueueIsFull(LidarDataQueue *queue)
Definition: ldq.cpp:101
unsigned char uint8_t
Definition: stdint.h:125
uint32_t QueueUnusedSize(LidarDataQueue *queue)
Definition: ldq.cpp:97
unsigned int uint32_t
Definition: stdint.h:127
const uint32_t KEthPacketMaxLength
Definition: ldq.h:34
uint32_t QueuePushAny(LidarDataQueue *queue, uint8_t *data, uint32_t length, uint64_t time_rcv, uint32_t point_num)
Definition: ldq.cpp:120
unsigned __int64 uint64_t
Definition: stdint.h:137
uint32_t point_num
Definition: ldq.h:40
uint32_t QueueUsedSize(LidarDataQueue *queue)
Definition: ldq.cpp:93
uint64_t time_rcv
Definition: ldq.h:39
int InitQueue(LidarDataQueue *queue, uint32_t queue_size)
Definition: ldq.cpp:33
static bool IsPowerOf2(uint32_t size)
Definition: ldq.h:54
StoragePacket * storage_packet
Definition: ldq.h:47
uint32_t QueueIsEmpty(LidarDataQueue *queue)
Definition: ldq.cpp:105
volatile uint32_t rd_idx
Definition: ldq.h:48
void QueuePopUpdate(LidarDataQueue *queue)
Definition: ldq.cpp:84
uint32_t QueuePush(LidarDataQueue *queue, StoragePacket *storage_packet)
Definition: ldq.cpp:109
TFSIMD_FORCE_INLINE tfScalar length(const Quaternion &q)
int DeInitQueue(LidarDataQueue *queue)
Definition: ldq.cpp:55
volatile uint32_t wr_idx
Definition: ldq.h:49
uint32_t QueuePop(LidarDataQueue *queue, StoragePacket *storage_packet)
Definition: ldq.cpp:86


livox_ros_driver
Author(s): Livox Dev Team
autogenerated on Mon Mar 15 2021 02:40:46