Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
906f3de
step 1: load recordings through a RecordingSource interface
michalpelka Nov 22, 2026
3626609
rosbags: read a log-time range of MCAP and ROS1 bag files
michalpelka Nov 22, 2026
9d5e854
step 1, raw viewer: open ROS1 bags and MCAP files directly
michalpelka Nov 22, 2026
d31e099
Windows: build lz4, zstd and bzip2 so bags can be compressed
michalpelka Nov 25, 2026
8499368
Recording sources: register kinds in a factory, BagSource class in he…
michalpelka Nov 26, 2026
672ea72
Open several ROS1 bags or MCAP files as one recording
michalpelka Nov 27, 2026
977c866
Show loading progress of ROS1 bags and MCAP files
michalpelka Nov 27, 2026
7ca1cda
Add a loading test campaign for ROS1 bags and MCAP files
michalpelka Nov 27, 2026
be86294
step 1: --gui opens the GUI with the given inputs
michalpelka Nov 27, 2026
cf9f76f
rosbags: read uncompressed ROS1 chunks with a wrong size field
michalpelka Nov 27, 2026
9b22c68
bag_loading_campaign: more PointCloud2 lidars, zip archives, MCAP rec…
michalpelka Nov 27, 2026
f7d4f68
Add hesai_pcap_to_laz: Hesai pcap / lidar_recorder session -> mandeye…
michalpelka Nov 27, 2026
52357c5
Open Hesai pcap captures directly in step 1 and the raw viewer
michalpelka Nov 27, 2026
731d09e
hesai_pcap_to_laz: read through the recording sources
michalpelka Nov 27, 2026
19acd21
Hesai pcap: take the IMU from the Mandeye IMU files when the lidar ha…
michalpelka Nov 27, 2026
ee8fb89
raw viewer: warn when a loaded recording shows nothing
michalpelka Nov 27, 2026
d12112d
Hesai pcap: read lidar_recorder's .pcap.zstd chunks
michalpelka Dec 2, 2026
9ab8c2f
step 1: clang-format the IMU offset log line
michalpelka Dec 2, 2026
06aee14
clang-format: check rosbags and recording_sources too
michalpelka Dec 2, 2026
4d5c197
rosbags tests: close the capture before removing it
michalpelka Dec 2, 2026
4348c13
rosbags: read MCAP through an ifstream to handle files over 2 GB on W…
michalpelka Dec 2, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,19 @@
[submodule "3rdparty/fbow"]
path = 3rdparty/fbow
url = https://github.com/rmsalinas/fbow.git
[submodule "3rdparty/lz4"]
path = 3rdparty/lz4
url = https://github.com/lz4/lz4.git
shallow = true
[submodule "3rdparty/zstd"]
path = 3rdparty/zstd
url = https://github.com/facebook/zstd.git
shallow = true
[submodule "3rdparty/bzip2"]
path = 3rdparty/bzip2
url = https://gitlab.com/bzip2/bzip2.git
shallow = true
[submodule "3rdparty/HesaiLidar_SDK_2.0"]
path = 3rdparty/HesaiLidar_SDK_2.0
url = https://github.com/HesaiTechnology/HesaiLidar_SDK_2.0.git
shallow = true
1 change: 1 addition & 0 deletions 3rdparty/HesaiLidar_SDK_2.0
Submodule HesaiLidar_SDK_2.0 added at 3346e7
1 change: 1 addition & 0 deletions 3rdparty/bzip2
Submodule bzip2 added at 6a8690
1 change: 1 addition & 0 deletions 3rdparty/lz4
Submodule lz4 added at ebb370
13 changes: 4 additions & 9 deletions 3rdparty/mcap/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,11 @@ target_include_directories(mcap INTERFACE ${mcap_SOURCE_DIR}/cpp/mcap/include)
# even for callers that only ever write Compression::None -- so the symbols
# must be linked unconditionally, not just when compression is actually used.
#
# On Windows there's no system package manager providing liblz4/libzstd dev
# packages (unlike apt on Linux / Homebrew on macOS), and no vendored/prebuilt
# copy of them here yet -- see 3rdpartyBinary/Proj for that pattern if this
# ever needs revisiting. Until then, disable mcap's LZ4/ZSTD code paths on
# Windows via its own escape hatch: reading uncompressed/other-codec mcaps
# still works, only Compression::Lz4/Zstd at write time become unavailable --
# fine since this repo's writer (rosbags/McapWriter) only ever writes
# Compression::None.
# Linux and macOS link the system liblz4/libzstd; Windows links the static
# lz4_static/zstd_static built from the lz4 and zstd submodules (see
# cmake/dependencies.cmake).
if(WIN32)
target_compile_definitions(mcap INTERFACE MCAP_COMPRESSION_NO_LZ4 MCAP_COMPRESSION_NO_ZSTD)
target_link_libraries(mcap INTERFACE lz4_static zstd_static)
else()
find_library(MCAP_LZ4_LIBRARY NAMES lz4)
find_library(MCAP_ZSTD_LIBRARY NAMES zstd)
Expand Down
1 change: 1 addition & 0 deletions 3rdparty/zstd
Submodule zstd added at f8745d
48 changes: 45 additions & 3 deletions apps/console_tools/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ target_link_libraries(
# mcap_to_laz: the inverse of laz_to_mcap -- MCAP/ROS2 bag -> mandeye session
# directory. Needs neither lidar_odometry_utils.cpp nor core: reading is
# rosbags/McapReader and writing is rosbags/MandeyeSessionWriter, so laszip +
# mcap + spdlog is the whole dependency set.
# mcap + spdlog (+ header-only Eigen) is the whole dependency set.
#
# McapWriter.cpp is compiled in even though nothing here writes bags: it holds
# the single MCAP_IMPLEMENTATION definition, which McapReader.cpp deliberately
Expand All @@ -101,6 +101,7 @@ add_executable(
target_include_directories(
mcap_to_laz
PRIVATE ${REPOSITORY_DIRECTORY}/rosbags
${EIGEN3_INCLUDE_DIR}
${LASZIP_INCLUDE_DIR}/LASzip/include)

target_link_libraries(
Expand All @@ -118,8 +119,7 @@ endif()
# bag_to_laz / laz_to_bag: the ROS1 bag twins of mcap_to_laz / laz_to_mcap,
# built from the same sources with a define that swaps the reader (writer) for
# rosbags/Ros1Bag -- no ROS installation needed. Reading compressed chunks needs
# ros1bag_compression and mcap (see cmake/dependencies.cmake); on Windows only
# uncompressed bags are read.
# ros1bag_compression and mcap (see cmake/dependencies.cmake).
add_executable(
bag_to_laz mcap_to_laz.cpp
${REPOSITORY_DIRECTORY}/rosbags/Ros1Bag.h ${REPOSITORY_DIRECTORY}/rosbags/Ros1Bag.cpp
Expand All @@ -130,6 +130,7 @@ target_compile_definitions(bag_to_laz PRIVATE HDMAPPING_IMPORT_ROS1_BAG)
target_include_directories(
bag_to_laz
PRIVATE ${REPOSITORY_DIRECTORY}/rosbags
${EIGEN3_INCLUDE_DIR}
${LASZIP_INCLUDE_DIR}/LASzip/include)
target_link_libraries(
bag_to_laz
Expand Down Expand Up @@ -183,6 +184,7 @@ endif()
add_executable(
ouster_pcap_to_laz ouster_pcap_to_laz.cpp
${REPOSITORY_DIRECTORY}/rosbags/OusterPcapReader.h ${REPOSITORY_DIRECTORY}/rosbags/OusterPcapReader.cpp
${REPOSITORY_DIRECTORY}/rosbags/PcapUdpReader.h ${REPOSITORY_DIRECTORY}/rosbags/PcapUdpReader.cpp
${REPOSITORY_DIRECTORY}/rosbags/MandeyeSessionWriter.h ${REPOSITORY_DIRECTORY}/rosbags/MandeyeSessionWriter.cpp
)

Expand All @@ -196,13 +198,52 @@ target_link_libraries(
ouster_pcap_to_laz
PRIVATE
spdlog::spdlog
hdmapping_zstd
${PLATFORM_LASZIP_LIB}
${PLATFORM_MISCELLANEOUS_LIBS})

if (MSVC)
target_compile_options(laz_to_mcap PRIVATE /bigobj)
endif()

# hesai_pcap_to_laz: a recording -> mandeye session directory, read through the recording sources
# (recording_sources/) exactly as lidar_odometry_step_1 reads it: Hesai .pcap / .pcap.zstd captures or a lidar_recorder
# session, or any other registered kind. The kinds register themselves, so their files are compiled in here.
include(${REPOSITORY_DIRECTORY}/recording_sources/recording_sources.cmake)
add_executable(
hesai_pcap_to_laz hesai_pcap_to_laz.cpp
${RECORDING_SOURCE_FILES}
${REPOSITORY_DIRECTORY}/apps/lidar_odometry_step_1/lidar_odometry_utils.h
${REPOSITORY_DIRECTORY}/apps/lidar_odometry_step_1/lidar_odometry_utils.cpp
${REPOSITORY_DIRECTORY}/rosbags/MandeyeSessionWriter.h ${REPOSITORY_DIRECTORY}/rosbags/MandeyeSessionWriter.cpp
)

target_include_directories(
hesai_pcap_to_laz
PRIVATE ${REPOSITORY_DIRECTORY}/apps/lidar_odometry_step_1
${REPOSITORY_DIRECTORY}/recording_sources
${REPOSITORY_DIRECTORY}/rosbags
${REPOSITORY_DIRECTORY}/core/include
${THIRDPARTY_DIRECTORY}
${THIRDPARTY_DIRECTORY}/glm
${EIGEN3_INCLUDE_DIR}
${THIRDPARTY_DIRECTORY}/tomlplusplus/include
${THIRDPARTY_DIRECTORY}/json/include
${LASZIP_INCLUDE_DIR}/LASzip/include
${THIRDPARTY_DIRECTORY}/observation_equations/codes
${THIRDPARTY_DIRECTORY}/vqf/vqf/cpp)

target_link_libraries(
hesai_pcap_to_laz
PRIVATE
${RECORDING_SOURCE_LIBRARIES}
unordered_dense::unordered_dense
spdlog::spdlog
${PLATFORM_LASZIP_LIB}
${PLATFORM_MISCELLANEOUS_LIBS}
${CORE_LIBRARIES}
imgui_raylib) # the bag kinds' option forms (bag_source_ui.cpp)

# bow_loop_closure_detect: headless verification tool for the automatic
# image-based (fbow) loop closure detector shared with step 2's GUI --
# loads a step-2 session + a CAMERA_0 folder and prints candidate pairs as
Expand Down Expand Up @@ -335,5 +376,6 @@ hdmapping_install_app(
laz_to_mcap
mcap_to_laz
ouster_pcap_to_laz
hesai_pcap_to_laz
session_intensity_panoramas
session_to_mcap)
173 changes: 173 additions & 0 deletions apps/console_tools/hesai_pcap_to_laz.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
// hesai_pcap_to_laz: a recording -> mandeye session directory, read through the recording sources exactly as
// lidar_odometry_step_1 reads it. Meant for Hesai captures (.pcap / .pcap.zstd files or a lidar_recorder session
// directory), but any registered recording kind converts the same way.
//
// Each chunk of the recording becomes one lidarNNNN.laz (all its points, nothing filtered); every IMU sample goes to the
// imuNNNN.csv of the chunk open at its time.

// See rosbags/McapWriter.h: the rosbags headers come before any standard header.
#include "MandeyeSessionWriter.h"

#include "recording_source_factory.h"

#include "console_progress.h"

#include <spdlog/spdlog.h>

#include <algorithm>
#include <cstdlib>
#include <filesystem>
#include <limits>
#include <string>
#include <vector>

namespace fs = std::filesystem;

namespace
{
void print_usage(const char* argv0)
{
spdlog::error("Usage: {} <input> [<input> ...] <output_session_dir>", argv0);
spdlog::error(" input a recording lidar_odometry_step_1 opens: Hesai .pcap / .pcap.zstd files or a");
spdlog::error(" lidar_recorder session directory (correction.dat next to them), ROS1 bags, MCAP files");
spdlog::error(" output_session_dir written as mandeye lidarNNNN.laz + imuNNNN.csv chunk pairs, one per");
spdlog::error(" chunk of the recording");
spdlog::error("No calibration.json or .sn file is written, so lidar_odometry_step_1 applies no extrinsics.");
}
} // namespace

int main(const int argc, const char** argv)
{
std::vector<fs::path> paths;
for (int i = 1; i < argc; ++i)
{
const std::string arg = argv[i];
if (arg.starts_with("--"))
{
spdlog::error("Unrecognized argument '{}'", arg);
print_usage(argv[0]);
return EXIT_FAILURE;
}
paths.emplace_back(arg);
}
if (paths.size() < 2)
{
print_usage(argv[0]);
return EXIT_FAILURE;
}
const fs::path session_dir = paths.back();
paths.pop_back();

const auto kind = RecordingSourceFactory::find(paths);
if (!kind)
{
spdlog::error("No recording kind reads '{}'", paths.front().string());
return EXIT_FAILURE;
}
std::string error;
const auto source = kind->open(paths, error);
if (!source)
{
spdlog::error("Cannot read '{}' as {}: {}", paths.front().string(), kind->name(), error);
return EXIT_FAILURE;
}
spdlog::info("Reading '{}' as {}: {} chunk(s)", paths.front().string(), kind->name(), source->chunkCount());

rosbags::MandeyeSessionWriter writer(session_dir);
if (!writer.isOpen())
{
spdlog::error("Cannot write session directory: {}", writer.error());
return EXIT_FAILURE;
}

Imu imu;
std::vector<InputFileSpan> imu_spans;
constexpr uint64_t kImuSteps = 1000;
ConsoleProgress imu_progress("Reading IMU", kImuSteps);
source->loadImu(
imu,
imu_spans,
[&](double fraction)
{
imu_progress.update(static_cast<uint64_t>(fraction * kImuSteps));
});
imu_progress.finish(imu.size());
std::sort(
imu.begin(),
imu.end(),
[](const auto& a, const auto& b)
{
return std::get<0>(a).first < std::get<0>(b).first;
});

// Every point: no filter.
PointFilter filter;
filter.omit_timestamp_zero = false;
filter.xy_inner = -1.0;
filter.xy_outer = std::numeric_limits<double>::infinity();

std::vector<double> chunk_start; // first point time of each written chunk
ConsoleProgress chunk_progress("Writing chunks", source->chunkCount());
for (size_t i = 0; i < source->chunkCount(); ++i)
{
const auto points = source->loadPoints(i, filter);
chunk_progress.update(i + 1);
if (points.empty())
continue;
std::vector<rosbags::McapPoint> out(points.size());
for (size_t k = 0; k < points.size(); ++k)
{
out[k].x = static_cast<float>(points[k].point.x());
out[k].y = static_cast<float>(points[k].point.y());
out[k].z = static_cast<float>(points[k].point.z());
out[k].intensity = points[k].intensity;
out[k].timestamp = points[k].timestamp;
}
if (!writer.beginChunk(static_cast<int>(chunk_start.size())) || !writer.addPoints(out) || !writer.endChunk())
{
spdlog::error("Failed writing {}: {}", source->chunkName(i), writer.error());
return EXIT_FAILURE;
}
chunk_start.push_back(points.front().timestamp);
}
chunk_progress.finish(source->chunkCount());
if (chunk_start.empty())
{
spdlog::error("No points in '{}' - nothing to write", paths.front().string());
return EXIT_FAILURE;
}

// Each IMU sample goes to the chunk open at its time; samples before all lidar data to the first chunk.
std::vector<std::vector<rosbags::McapImuSample>> per_chunk(chunk_start.size());
for (const auto& [timestamps, gyro, acc] : imu)
{
const double t = timestamps.first;
const auto it = std::upper_bound(chunk_start.begin(), chunk_start.end(), t);
const size_t index = it == chunk_start.begin() ? 0 : static_cast<size_t>(it - chunk_start.begin() - 1);
rosbags::McapImuSample s;
s.timestamp = t;
s.gyro_x = gyro.x();
s.gyro_y = gyro.y();
s.gyro_z = gyro.z();
s.acc_x = acc.x();
s.acc_y = acc.y();
s.acc_z = acc.z();
per_chunk[index].push_back(s);
}
for (size_t k = 0; k < per_chunk.size(); ++k)
{
if (!writer.writeImuChunk(static_cast<int>(k), per_chunk[k]))
{
spdlog::error("Failed writing IMU chunk {}: {}", k, writer.error());
return EXIT_FAILURE;
}
}

spdlog::info(
"Wrote {} chunk(s) to {}: {} point(s), {} IMU sample(s)",
chunk_start.size(),
session_dir.string(),
writer.pointsWritten(),
writer.imuSamplesWritten());
return EXIT_SUCCESS;
}
Loading
Loading