rawdata.h
Go to the documentation of this file.
1 /* -*- mode: C++ -*-
2  *
3  * Copyright (C) 2007 Austin Robot Technology, Yaxin Liu, Patrick Beeson
4  * Copyright (C) 2009, 2010, 2012 Austin Robot Technology, Jack O'Quin
5  * Copyright (C) 2017 Robosense, Tony Zhang
6  *
7  * License: Modified BSD Software License Agreement
8  *
9 
10  Copyright (C) 2010-2013 Austin Robot Technology, and others
11  All rights reserved.
12 
13 
14 Modified BSD License:
15 --------------------
16 
17  Redistribution and use in source and binary forms, with or without
18  modification, are permitted provided that the following conditions
19  are met:
20 
21  * Redistributions of source code must retain the above copyright
22  notice, this list of conditions and the following disclaimer.
23 
24  * Redistributions in binary form must reproduce the above
25  copyright notice, this list of conditions and the following
26  disclaimer in the documentation and/or other materials provided
27  with the distribution.
28 
29  * Neither the names of the University of Texas at Austin, nor
30  Austin Robot Technology, nor the names of other contributors may
31  be used to endorse or promote products derived from this
32  software without specific prior written permission.
33 
34  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
35  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
36  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
37  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
38  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
39  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
40  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
41  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
42  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
43  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
44  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
45 POSSIBILITY OF SUCH DAMAGE.
46  */
47 
58 #ifndef _RAWDATA_H
59 #define _RAWDATA_H
60 
61 #include <ros/ros.h>
62 #include <ros/package.h>
63 #include <rslidar_msgs/rslidarPacket.h>
64 #include <rslidar_msgs/rslidarScan.h>
65 #include "std_msgs/String.h"
66 #include <pcl/point_types.h>
67 #include <pcl_ros/point_cloud.h>
70 #include <stdio.h>
71 namespace rslidar_rawdata
72 {
73 // static const float ROTATION_SOLUTION_ = 0.18f; //水平角分辨率 10hz
74 static const int SIZE_BLOCK = 100;
75 static const int RAW_SCAN_SIZE = 3;
76 static const int SCANS_PER_BLOCK = 32;
77 static const int BLOCK_DATA_SIZE = (SCANS_PER_BLOCK * RAW_SCAN_SIZE); // 96
78 
79 static const float ROTATION_RESOLUTION = 0.01f;
80 static const uint16_t ROTATION_MAX_UNITS = 36000;
82 static const float DISTANCE_MAX = 200.0f;
83 static const float DISTANCE_MIN = 0.2f;
84 static const float DISTANCE_RESOLUTION = 0.01f;
85 static const float DISTANCE_RESOLUTION_NEW = 0.005f;
86 static const float DISTANCE_MAX_UNITS = (DISTANCE_MAX / DISTANCE_RESOLUTION + 1.0f);
88 static const uint16_t UPPER_BANK = 0xeeff; //
89 static const uint16_t LOWER_BANK = 0xddff;
90 
92 static const int RS16_FIRINGS_PER_BLOCK = 2;
93 static const int RS16_SCANS_PER_FIRING = 16;
94 static const float RS16_BLOCK_TDURATION = 100.0f; // [µs]
95 static const float RS16_DSR_TOFFSET = 3.0f; // [µs]
96 static const float RS16_FIRING_TOFFSET = 50.0f; // [µs]
97 
99 static const int RS32_FIRINGS_PER_BLOCK = 1;
100 static const int RS32_SCANS_PER_FIRING = 32;
101 static const float RS32_BLOCK_TDURATION = 50.0f; // [µs]
102 static const float RS32_DSR_TOFFSET = 3.0f; // [µs]
103 static const float RL32_FIRING_TOFFSET = 50.0f; // [µs]
104 
105 static const int TEMPERATURE_MIN = 31;
106 
114 // block
115 typedef struct raw_block
116 {
117  uint16_t header;
118  uint8_t rotation_1;
119  uint8_t rotation_2;
120  uint8_t data[BLOCK_DATA_SIZE]; // 96
121 } raw_block_t;
122 
129 {
130  uint16_t uint;
131  uint8_t bytes[2];
132 };
133 
134 static const int PACKET_SIZE = 1248;
135 static const int BLOCKS_PER_PACKET = 12;
136 static const int PACKET_STATUS_SIZE = 4;
137 static const int SCANS_PER_PACKET = (SCANS_PER_BLOCK * BLOCKS_PER_PACKET);
138 
151 typedef struct raw_packet
152 {
154  uint16_t revolution;
155  uint8_t status[PACKET_STATUS_SIZE];
156 } raw_packet_t;
157 
159 class RawData
160 {
161 public:
162  RawData();
163 
165  {
166  }
167 
168  /*load the cablibrated files: angle, distance, intensity*/
169  void loadConfigFile(ros::NodeHandle node, ros::NodeHandle private_nh);
170 
171  /*unpack the RS16 UDP packet and opuput PCL PointXYZI type*/
172  void unpack(const rslidar_msgs::rslidarPacket& pkt, pcl::PointCloud<pcl::PointXYZI>::Ptr pointcloud);
173 
174  /*unpack the RS32 UDP packet and opuput PCL PointXYZI type*/
175  void unpack_RS32(const rslidar_msgs::rslidarPacket& pkt, pcl::PointCloud<pcl::PointXYZI>::Ptr pointcloud);
176 
177  /*compute temperature*/
178  float computeTemperature(unsigned char bit1, unsigned char bit2);
179 
180  /*estimate temperature*/
181  int estimateTemperature(float Temper);
182 
183  /*calibrated the disctance*/
184  float pixelToDistance(int pixelValue, int passageway);
185 
186  /*calibrated the azimuth*/
187  int correctAzimuth(float azimuth_f, int passageway);
188 
189  /*calibrated the intensity*/
190  float calibrateIntensity(float inten, int calIdx, int distance);
191  float calibrateIntensity_old(float inten, int calIdx, int distance);
192 
193  /*estimate the packet type*/
194  int isABPacket(int distance);
195 
196  void processDifop(const rslidar_msgs::rslidarPacket::ConstPtr& difop_msg);
201  int block_num = 0;
204  int dis_resolution_mode = 0;
207 };
208 
209 float VERT_ANGLE[32];
210 float HORI_ANGLE[32];
211 float aIntensityCal[7][32];
212 float aIntensityCal_old[1600][32];
213 bool Curvesis_new = true;
214 int g_ChannelNum[32][51];
215 float CurvesRate[32];
216 
217 float temper = 31.0;
219 int numOfLasers = 16;
221 
222 } // namespace rslidar_rawdata
223 
224 #endif // __RAWDATA_H
float CurvesRate[32]
Definition: rawdata.h:215
static const int RAW_SCAN_SIZE
Definition: rawdata.h:75
static const float RS16_FIRING_TOFFSET
Definition: rawdata.h:96
static const int RS16_SCANS_PER_FIRING
Definition: rawdata.h:93
static const float DISTANCE_RESOLUTION_NEW
Definition: rawdata.h:85
float temper
Definition: rawdata.h:217
static const float RS32_BLOCK_TDURATION
Definition: rawdata.h:101
static const int SIZE_BLOCK
Definition: rawdata.h:74
static const float DISTANCE_MAX_UNITS
Definition: rawdata.h:86
uint16_t header
UPPER_BANK or LOWER_BANK.
Definition: rawdata.h:117
static const uint16_t ROTATION_MAX_UNITS
Definition: rawdata.h:80
static const int RS32_SCANS_PER_FIRING
Definition: rawdata.h:100
uint8_t data[BLOCK_DATA_SIZE]
combine rotation1 and rotation2 together to get 0-35999, divide by 100 to get degrees ...
Definition: rawdata.h:120
Raw Rsldar packet.
Definition: rawdata.h:151
static const int PACKET_SIZE
Definition: rawdata.h:134
TFSIMD_FORCE_INLINE tfScalar distance(const Vector3 &v) const
static const float DISTANCE_RESOLUTION
Definition: rawdata.h:84
static const int RS16_FIRINGS_PER_BLOCK
Definition: rawdata.h:92
float aIntensityCal_old[1600][32]
Definition: rawdata.h:212
struct rslidar_rawdata::raw_block raw_block_t
Raw rslidar data block.
static const int PACKET_STATUS_SIZE
Definition: rawdata.h:136
ros::Subscriber difop_sub_
Definition: rawdata.h:197
float aIntensityCal[7][32]
Definition: rawdata.h:211
static const int BLOCKS_PER_PACKET
Definition: rawdata.h:135
static const float ROTATION_RESOLUTION
Definition: rawdata.h:79
static const int BLOCK_DATA_SIZE
Definition: rawdata.h:77
float VERT_ANGLE[32]
Definition: rawdata.h:209
float HORI_ANGLE[32]
Definition: rawdata.h:210
int g_ChannelNum[32][51]
Definition: rawdata.h:214
static const float RS16_BLOCK_TDURATION
Definition: rawdata.h:94
static const float DISTANCE_MIN
Definition: rawdata.h:83
static const float DISTANCE_MAX
Definition: rawdata.h:82
static const uint16_t UPPER_BANK
Definition: rawdata.h:88
static const float RS16_DSR_TOFFSET
Definition: rawdata.h:95
static const int SCANS_PER_PACKET
Definition: rawdata.h:137
static const int TEMPERATURE_MIN
Definition: rawdata.h:105
static const uint16_t LOWER_BANK
Definition: rawdata.h:89
Raw rslidar data block.
Definition: rawdata.h:115
static const float RS32_DSR_TOFFSET
Definition: rawdata.h:102
struct rslidar_rawdata::raw_packet raw_packet_t
Raw Rsldar packet.
static const float RL32_FIRING_TOFFSET
Definition: rawdata.h:103
static const int RS32_FIRINGS_PER_BLOCK
Definition: rawdata.h:99
int tempPacketNum
Definition: rawdata.h:218
bool Curvesis_new
Definition: rawdata.h:213
static const int SCANS_PER_BLOCK
Definition: rawdata.h:76
RSLIDAR data conversion class.
Definition: rawdata.h:159
int TEMPERATURE_RANGE
Definition: rawdata.h:220


rslidar_pointcloud
Author(s): Tony Zhang , Tony Zhang, George Wang, Piyush Khandelwal, Jesse Vera
autogenerated on Mon Jun 10 2019 14:41:10