A simple cpp driver for Livox LiDAR. No ROS requirement.
Currently Livox only provides a official grab-to-go driver with ROS. And the cpp sample provided in Livox-SDK still needs extra development to get the point data.
This repo provides a simple cpp sample based on Livox-SDK that can let user get point data conveniently.
Point cloud from Livox AVIA with a integration time of 0.5 seconds
- Livox-SDK
- Point Cloud Library (only required if you want to build visualization example)
sudo apt install libpcl-dev
mkdir build
# BUILD_VISUAL_EXAMPLE is default to OFF
cmake -D BUILD_VISUAL_EXAMPLE=ON ..
make
Get instance for LidarDataSrc
livox::LidarDataSrc& data_src = livox::LidarDataSrc::GetInstance();
Intialize with auto-connection mode
data_src.Initialize(); // This enables auto-connect mode by default
Intialize with specified white-list
std::vector<std::string> white_list;
// Populate data ...
data_src.Initialize(white_list);
Set & get ingegrate time
data_src.SetIntegrateTime(0.1);
double t = data_src.IntegrateTime();
Get point data
std::vector<livox::PointXYZR> out = data_src.GetPtdataXYZR();
A full sample
int main(int argc, char const *argv[]){
livox::LidarDataSrc& data_src = livox::LidarDataSrc::GetInstance();
data_src.Initialize();
while(true){
std::vector<livox::PointXYZR> out = data_src.GetPtdataXYZR();
std::cout << "Point number: " << out.size() << std::endl;
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
}
return EXIT_SUCCESS;
}
You can find samples here
Livox LiDAR will continuously scan and return data. Integration Time is the desired time span of data integration for onr frame. The longer the time, the more data you will get when calling GetPtdataXYZR()
.
There are 2 buffers called prepare_data_q_
and ready_data_q_
respectively. Every time the sdk receives data, the data will be stored in prepare_data_q_
. Every time the integration time is reached, the frame is considered as complete and the content of prepare_data_q_
and ready_data_q_
will be swapped. And when you call GetPtdataXYZR()
, the data is parsed from ready_data_q_
.
- Estimate timestamp for every point
- Bug fixing: current imu data is blended in lidar point data