Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .github/workflows/cmake-linux-deb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: Load repository cache
run: sudo apt-get update --allow-releaseinfo-change
- name: Install Libs
run: sudo apt-get install -y --no-install-recommends libeigen3-dev libglew-dev freeglut3-dev libx11-dev libxi-dev libxrandr-dev libxinerama-dev libxcursor-dev libxext-dev libtbb-dev liblaszip-dev libopencv-dev libproj-dev
run: sudo apt-get install -y --no-install-recommends libeigen3-dev libglew-dev freeglut3-dev libx11-dev libxi-dev libxrandr-dev libxinerama-dev libxcursor-dev libxext-dev libtbb-dev liblaszip-dev libopencv-dev libproj-dev libbz2-dev

- uses: actions/checkout@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/cmake-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: Load repository cache
run: sudo apt-get update --allow-releaseinfo-change
- name: Install Libs
run: sudo apt-get install -y --no-install-recommends libx11-dev libxi-dev libxrandr-dev libxinerama-dev libxcursor-dev libxext-dev libtbb-dev libegl1-mesa-dev libglu1-mesa-dev libopencv-dev libproj-dev
run: sudo apt-get install -y --no-install-recommends libx11-dev libxi-dev libxrandr-dev libxinerama-dev libxcursor-dev libxext-dev libtbb-dev libegl1-mesa-dev libglu1-mesa-dev libopencv-dev libproj-dev libbz2-dev

- uses: actions/checkout@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/python-bindings-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
run: sudo apt-get update --allow-releaseinfo-change

- name: Install system libraries
run: sudo apt-get install -y --no-install-recommends libx11-dev libxi-dev libxrandr-dev libxinerama-dev libxcursor-dev libxext-dev libtbb-dev libegl1-mesa-dev libglu1-mesa-dev libopencv-dev libproj-dev
run: sudo apt-get install -y --no-install-recommends libx11-dev libxi-dev libxrandr-dev libxinerama-dev libxcursor-dev libxext-dev libtbb-dev libegl1-mesa-dev libglu1-mesa-dev libopencv-dev libproj-dev libbz2-dev

- uses: actions/checkout@v4
with:
Expand Down
62 changes: 62 additions & 0 deletions apps/console_tools/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,68 @@ if (MSVC)
target_compile_options(mcap_to_laz PRIVATE /bigobj)
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.
add_executable(
bag_to_laz mcap_to_laz.cpp
${REPOSITORY_DIRECTORY}/rosbags/Ros1Bag.h ${REPOSITORY_DIRECTORY}/rosbags/Ros1Bag.cpp
${REPOSITORY_DIRECTORY}/rosbags/McapWriter.h ${REPOSITORY_DIRECTORY}/rosbags/McapWriter.cpp
${REPOSITORY_DIRECTORY}/rosbags/MandeyeSessionWriter.h ${REPOSITORY_DIRECTORY}/rosbags/MandeyeSessionWriter.cpp
)
target_compile_definitions(bag_to_laz PRIVATE HDMAPPING_IMPORT_ROS1_BAG)
target_include_directories(
bag_to_laz
PRIVATE ${REPOSITORY_DIRECTORY}/rosbags
${LASZIP_INCLUDE_DIR}/LASzip/include)
target_link_libraries(
bag_to_laz
PRIVATE
mcap
ros1bag_compression
spdlog::spdlog
${PLATFORM_LASZIP_LIB}
${PLATFORM_MISCELLANEOUS_LIBS})

add_executable(
laz_to_bag laz_to_mcap.cpp
${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/Ros1Bag.h ${REPOSITORY_DIRECTORY}/rosbags/Ros1Bag.cpp
${REPOSITORY_DIRECTORY}/rosbags/McapWriter.h ${REPOSITORY_DIRECTORY}/rosbags/McapWriter.cpp
)
target_compile_definitions(laz_to_bag PRIVATE HDMAPPING_EXPORT_ROS1_BAG)
target_include_directories(
laz_to_bag
PRIVATE ${REPOSITORY_DIRECTORY}/apps/lidar_odometry_step_1
${REPOSITORY_DIRECTORY}/core/include
${REPOSITORY_DIRECTORY}/rosbags
${THIRDPARTY_DIRECTORY} # csv.hpp (used by load_imu)
${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(
laz_to_bag
PRIVATE
mcap
ros1bag_compression
unordered_dense::unordered_dense
spdlog::spdlog
${PLATFORM_LASZIP_LIB}
${PLATFORM_MISCELLANEOUS_LIBS}
${CORE_LIBRARIES})

if (MSVC)
target_compile_options(bag_to_laz PRIVATE /bigobj)
target_compile_options(laz_to_bag PRIVATE /bigobj)
endif()

# ouster_pcap_to_laz: Ouster pcap + metadata JSON -> mandeye session directory.
# Same writer as mcap_to_laz; the pcap/packet decoding is rosbags/OusterPcapReader,
# so laszip + nlohmann json + spdlog is the whole dependency set.
Expand Down
97 changes: 97 additions & 0 deletions apps/console_tools/console_progress.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
#pragma once

#include <algorithm>
#include <chrono>
#include <cstdint>
#include <string>
#include <utility>

#include <spdlog/fmt/fmt.h>
#include <spdlog/spdlog.h>

/**
* @brief Progress of one long-running step of a console tool, reported through spdlog.
*
* Plain log lines rather than a redrawn bar, so it reads the same in a terminal, a pipe and a CI log,
* and interleaves cleanly with the tools' other messages.
*/
class ConsoleProgress
{
public:
/**
* @brief Starts the clock of a step.
* @param label Name of the step, printed at the start of each line.
* @param total Number of units of work, or 0 if unknown (only the count is reported then).
*/
ConsoleProgress(std::string label, uint64_t total)
: label_(std::move(label))
, total_(total)
, start_(Clock::now())
, last_report_(start_)
{
}

/**
* @brief Logs the progress, at most once per reporting interval. Cheap enough to call per point.
* @param done Units of work finished so far.
*/
void update(uint64_t done)
{
const auto now = Clock::now();
if (now - last_report_ < kReportInterval)
return;
last_report_ = now;
spdlog::info("{}: {}", label_, status(done));
}

/**
* @brief Logs the closing line of the step. The count may fall short of the total: messages skipped, read cut short.
* @param done Units of work finished.
*/
void finish(uint64_t done) const
{
spdlog::info("{}: done, {} in {}", label_, done, formatSeconds(elapsedSeconds()));
}

/**
* @brief Describes the progress, for tools that already log a line per unit of work.
* @param done Units of work finished so far.
* @return For example "42%, 1200/3000, 1m 20s left", or only the count if the total is unknown.
*/
std::string status(uint64_t done) const
{
if (total_ == 0)
return std::to_string(done);

const uint64_t clamped = std::min(done, total_);
const double fraction = static_cast<double>(clamped) / static_cast<double>(total_);
std::string text = fmt::format("{:.0f}%, {}/{}", fraction * 100.0, clamped, total_);
if (clamped > 0 && clamped < total_)
text += ", " + formatSeconds(elapsedSeconds() * (1.0 - fraction) / fraction) + " left";
return text;
}

private:
using Clock = std::chrono::steady_clock;
static constexpr std::chrono::seconds kReportInterval{ 2 };

double elapsedSeconds() const
{
return std::chrono::duration<double>(Clock::now() - start_).count();
}

static std::string formatSeconds(double seconds)
{
const auto whole = static_cast<uint64_t>(seconds + 0.5);
if (whole < 60)
return fmt::format("{}s", whole);
if (whole < 3600)
return fmt::format("{}m {}s", whole / 60, whole % 60);
return fmt::format("{}h {}m", whole / 3600, (whole % 3600) / 60);
}

std::string label_;
uint64_t total_;
Clock::time_point start_;
Clock::time_point last_report_;
};
Loading
Loading