From 697869e68f7e44afa3b9983cadeee4cf6c91ec37 Mon Sep 17 00:00:00 2001 From: creeper5820 Date: Mon, 15 Dec 2025 16:15:05 +0800 Subject: [PATCH 1/2] Add more info for armor painting and modify crash method of panic --- src/utility/image/armor.cpp | 14 +++++++++----- src/utility/panic.cpp | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/utility/image/armor.cpp b/src/utility/image/armor.cpp index d7fe56e2..3472f1de 100644 --- a/src/utility/image/armor.cpp +++ b/src/utility/image/armor.cpp @@ -19,8 +19,6 @@ auto draw(Image& canvas, const Armor2D& armor) noexcept -> void { auto genre = get_enum_name(armor.genre); auto shape = get_enum_name(armor.shape); - auto conf_str = std::format("{:.2f} {} {}", armor.confidence, genre, shape); - auto first = cv::Point2f {}; auto prev = cv::Point2f {}; auto is_first = true; @@ -41,12 +39,18 @@ auto draw(Image& canvas, const Armor2D& armor) noexcept -> void { cv::line(opencv_mat, prev, first, color, 2, cv::LINE_AA); } - const auto thickness = 2; + const auto thickness = 1; const auto font = cv::FONT_HERSHEY_SIMPLEX; const auto scale = 0.6; + const auto white = cv::Scalar { 255, 255, 255 }; + + cv::putText(opencv_mat, "TR", armor.tr, font, scale, white, thickness, cv::LINE_AA); + cv::putText(opencv_mat, "BL", armor.bl, font, scale, white, thickness, cv::LINE_AA); + cv::putText(opencv_mat, "BR", armor.br, font, scale, white, thickness, cv::LINE_AA); - cv::putText(opencv_mat, conf_str, armor.tl + cv::Point2f { 0, -5 }, font, scale, color, - thickness, cv::LINE_AA); + auto info = std::format("{:.2f} {} {}", armor.confidence, genre, shape); + cv::putText(opencv_mat, info, armor.tl + cv::Point2f { 0, -5 }, font, scale, white, thickness, + cv::LINE_AA); } } diff --git a/src/utility/panic.cpp b/src/utility/panic.cpp index 1f140a76..b58a661f 100644 --- a/src/utility/panic.cpp +++ b/src/utility/panic.cpp @@ -41,7 +41,7 @@ auto panic(const std::string& message, const std::source_location& loc) -> void std::cerr << panic_tail << std::endl; - std::abort(); + throw std::runtime_error { "PANIC HERE" }; } } // namespace rmcs::util From 491cd2d58a868d313a90201f74ae304bb5dfde29 Mon Sep 17 00:00:00 2001 From: creeper5820 Date: Mon, 15 Dec 2025 16:21:30 +0800 Subject: [PATCH 2/2] Remove global exception capturer of main function --- src/runtime.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/runtime.cpp b/src/runtime.cpp index 3314c08a..a1f53770 100644 --- a/src/runtime.cpp +++ b/src/runtime.cpp @@ -17,7 +17,7 @@ using namespace rmcs; -auto main() -> int try { +auto main() -> int { using namespace std::chrono_literals; std::signal(SIGINT, [](int) { util::set_running(false); }); @@ -117,7 +117,4 @@ auto main() -> int try { } rclcpp_node.shutdown(); -} catch (const std::exception& e) { - using namespace rmcs; - util::panic(std::format("exception uncatched | {}", e.what())); }