From 0e5ba50fc0e77817772fb51a634d590e19b153c7 Mon Sep 17 00:00:00 2001 From: zzodo Date: Mon, 30 Oct 2023 17:42:53 +0900 Subject: [PATCH 1/5] Set CXX standard to 17 --- CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 94945af..d182342 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,8 @@ cmake_minimum_required(VERSION 2.8.3) project(file_player) -add_definitions(-std=c++11) +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) if (NOT CMAKE_BUILD_TYPE) set (CMAKE_BUILD_TYPE release) From 3f7e1bd6613fdd562f2d45196ef4d102e13f4006 Mon Sep 17 00:00:00 2001 From: zzodo Date: Mon, 30 Oct 2023 17:45:14 +0900 Subject: [PATCH 2/5] Remove warnings and default opencv version to 4.x --- src/ROSThread.cpp | 9 +++++---- src/ROSThread.h | 2 -- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/ROSThread.cpp b/src/ROSThread.cpp index 3081d8e..a02921e 100644 --- a/src/ROSThread.cpp +++ b/src/ROSThread.cpp @@ -7,7 +7,7 @@ using namespace std; struct PointXYZIRT { PCL_ADD_POINT4D; float intensity; - uint32_t t; + std::uint32_t t; int ring; EIGEN_MAKE_ALIGNED_OPERATOR_NEW @@ -15,7 +15,7 @@ struct PointXYZIRT { POINT_CLOUD_REGISTER_POINT_STRUCT (PointXYZIRT, (float, x, x) (float, y, y) (float, z, z) (float, intensity, intensity) - (uint32_t, t, t) (int, ring, ring) + (std::uint32_t, t, t) (int, ring, ring) ) @@ -593,7 +593,7 @@ ROSThread::RadarpolarThread() string current_radarpolar_name = data_folder_path_ + "/sensor_data/radar/polar" + "/" + to_string(data) + ".png"; cv::Mat radarpolar_image; - radarpolar_image = imread(current_radarpolar_name, CV_LOAD_IMAGE_GRAYSCALE); + radarpolar_image = imread(current_radarpolar_name, cv::IMREAD_GRAYSCALE); if(!radarpolar_image.empty()) { @@ -615,7 +615,7 @@ ROSThread::RadarpolarThread() string next_radarpolar_name = data_folder_path_ + "/radar/polar" +"/"+ radarpolar_file_list_[current_img_index+1]; cv::Mat radarpolar_image; - radarpolar_image = imread(next_radarpolar_name, CV_LOAD_IMAGE_COLOR); + radarpolar_image = imread(next_radarpolar_name, cv::IMREAD_COLOR); if(!radarpolar_image.empty()) { @@ -779,6 +779,7 @@ void ROSThread::SaveRosbag() //cout<<"Written: "< #include #include -#include -#include #include #include #include From fffc338d1e01f206348a82ab4cb29a49eacdba91 Mon Sep 17 00:00:00 2001 From: zzodo Date: Mon, 30 Oct 2023 17:47:02 +0900 Subject: [PATCH 3/5] Add lines for saving ouster points --- src/ROSThread.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/ROSThread.cpp b/src/ROSThread.cpp index a02921e..32b2471 100644 --- a/src/ROSThread.cpp +++ b/src/ROSThread.cpp @@ -1,4 +1,5 @@ #include +#include #include "ROSThread.h" @@ -780,6 +781,34 @@ void ROSThread::SaveRosbag() } } + // Ouster points + const std::filesystem::path ouster_path = std::filesystem::path(data_folder_path_) / "sensor_data" / "Ouster"; + const auto ouster_file_iterator = std::filesystem::directory_iterator{ouster_path}; + for (const auto& ouster_file: ouster_file_iterator) { + std::ifstream ouster_bin(ouster_file.path(), std::ios_base::binary); + + int num_points = 0; + pcl::PointCloud ouster_cloud; + while (!ouster_bin.eof()) { + PointXYZIRT point; + ouster_bin.read(reinterpret_cast(&point.x), sizeof(float)); + ouster_bin.read(reinterpret_cast(&point.y), sizeof(float)); + ouster_bin.read(reinterpret_cast(&point.z), sizeof(float)); + ouster_bin.read(reinterpret_cast(&point.intensity), sizeof(float)); + point.ring = (num_points % 64) + 1; + num_points++; + ouster_cloud.points.emplace_back(point); + } + ouster_bin.close(); + + sensor_msgs::PointCloud2 ouster_cloud2; + pcl::toROSMsg(ouster_cloud, ouster_cloud2); + const std::uint64_t ouster_stamp = std::stoull(ouster_file.path().stem()); + ouster_cloud2.header.stamp.fromNSec(ouster_stamp); + ouster_cloud2.header.frame_id = "ouster"; + bag.write("/os1_points", ouster_cloud2.header.stamp, ouster_cloud2); + } + cout<<"rosbag stored at: "< Date: Mon, 30 Oct 2023 19:30:48 +0900 Subject: [PATCH 4/5] Fix timestamp conversion uint64_t to int64_t --- src/ROSThread.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ROSThread.cpp b/src/ROSThread.cpp index 32b2471..44aaf2a 100644 --- a/src/ROSThread.cpp +++ b/src/ROSThread.cpp @@ -803,7 +803,7 @@ void ROSThread::SaveRosbag() sensor_msgs::PointCloud2 ouster_cloud2; pcl::toROSMsg(ouster_cloud, ouster_cloud2); - const std::uint64_t ouster_stamp = std::stoull(ouster_file.path().stem()); + const std::int64_t ouster_stamp = std::stoull(ouster_file.path().stem()); ouster_cloud2.header.stamp.fromNSec(ouster_stamp); ouster_cloud2.header.frame_id = "ouster"; bag.write("/os1_points", ouster_cloud2.header.stamp, ouster_cloud2); From 3ad4a25be8ba6f7a6fd6a3a32f13b77e5406b0e1 Mon Sep 17 00:00:00 2001 From: Dohoon Cho Date: Wed, 1 Nov 2023 20:16:14 +0900 Subject: [PATCH 5/5] Print ouster conversion progress message --- src/ROSThread.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/ROSThread.cpp b/src/ROSThread.cpp index 44aaf2a..5a66106 100644 --- a/src/ROSThread.cpp +++ b/src/ROSThread.cpp @@ -784,6 +784,9 @@ void ROSThread::SaveRosbag() // Ouster points const std::filesystem::path ouster_path = std::filesystem::path(data_folder_path_) / "sensor_data" / "Ouster"; const auto ouster_file_iterator = std::filesystem::directory_iterator{ouster_path}; + const std::size_t num_ouster_bins = std::distance(std::filesystem::directory_iterator{ouster_path}, std::filesystem::directory_iterator{}); + std::cout << "Found ouster bins: total " << num_ouster_bins << std::endl; + std::size_t num_processed_ouster = 0; for (const auto& ouster_file: ouster_file_iterator) { std::ifstream ouster_bin(ouster_file.path(), std::ios_base::binary); @@ -807,6 +810,7 @@ void ROSThread::SaveRosbag() ouster_cloud2.header.stamp.fromNSec(ouster_stamp); ouster_cloud2.header.frame_id = "ouster"; bag.write("/os1_points", ouster_cloud2.header.stamp, ouster_cloud2); + std::cout << "processing ouster: " << num_processed_ouster++ << "/" << num_ouster_bins << std::endl; } cout<<"rosbag stored at: "<