From 1ced285a416c0b01ccd5c693a056d5909588c297 Mon Sep 17 00:00:00 2001 From: hiikariri Date: Mon, 17 Jun 2024 04:53:35 +0700 Subject: [PATCH 1/3] feat: adapt main to remove ros arguments --- src/kansei_main.cpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/kansei_main.cpp b/src/kansei_main.cpp index 6d5e71d..80b05b5 100755 --- a/src/kansei_main.cpp +++ b/src/kansei_main.cpp @@ -33,9 +33,13 @@ int main(int argc, char * argv[]) { - rclcpp::init(argc, argv); + auto args = rclcpp::init_and_remove_ros_arguments(argc, argv); +<<<<<<< Updated upstream std::string port_name = "/dev/ttyUSB1"; +======= + std::string port_name = "/dev/serial/by-id/usb-Seeed_Seeed_XIAO_M0_E8D70AB55154305147202020FF050926-if00"; +>>>>>>> Stashed changes std::string path = ""; kansei::fallen::DeterminantType determinant_type; @@ -46,23 +50,23 @@ int main(int argc, char * argv[]) "Optional:\n" "-h, --help show this help message and exit\n"; - if (argc > 1) { - for (int i = 1; i < argc; i++) { - std::string arg = argv[i]; + if (args.size() > 1) { + for (int i = 1; i < args.size(); i++) { + std::string arg = args[i]; if (arg == "-h" || arg == "--help") { std::cout << help_message << std::endl; return 1; } else if (arg == "--path") { - if (i + 1 < argc) { - path = argv[i + 1]; + if (i + 1 < args.size()) { + path = args[i + 1]; i++; } else { std::cerr << "Error: --path requires a path argument" << std::endl; return 1; } } else if (arg == "--type") { - if (i + 1 < argc) { - std::string fallen_type = argv[i + 1]; + if (i + 1 < args.size()) { + std::string fallen_type = args[i + 1]; if (fallen_type == "orientation") { determinant_type = kansei::fallen::DeterminantType::ORIENTATION; } else if (fallen_type == "accelero") { From 8ff56fe02982a56e5f7d096c0a716ff552f2d2a3 Mon Sep 17 00:00:00 2001 From: hiikariri Date: Tue, 18 Jun 2024 02:12:35 +0700 Subject: [PATCH 2/3] fix: fix stashed problem --- src/kansei_main.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/kansei_main.cpp b/src/kansei_main.cpp index 80b05b5..844d110 100755 --- a/src/kansei_main.cpp +++ b/src/kansei_main.cpp @@ -35,11 +35,7 @@ int main(int argc, char * argv[]) { auto args = rclcpp::init_and_remove_ros_arguments(argc, argv); -<<<<<<< Updated upstream - std::string port_name = "/dev/ttyUSB1"; -======= std::string port_name = "/dev/serial/by-id/usb-Seeed_Seeed_XIAO_M0_E8D70AB55154305147202020FF050926-if00"; ->>>>>>> Stashed changes std::string path = ""; kansei::fallen::DeterminantType determinant_type; From 671b3dd7ead2f0cdbd4b202311b3ba7d85f25cfb Mon Sep 17 00:00:00 2001 From: hiikariri Date: Wed, 19 Jun 2024 17:36:28 +0700 Subject: [PATCH 3/3] fix: use constant reference to prevent variable copy --- src/kansei_main.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/kansei_main.cpp b/src/kansei_main.cpp index 844d110..c128936 100755 --- a/src/kansei_main.cpp +++ b/src/kansei_main.cpp @@ -35,7 +35,7 @@ int main(int argc, char * argv[]) { auto args = rclcpp::init_and_remove_ros_arguments(argc, argv); - std::string port_name = "/dev/serial/by-id/usb-Seeed_Seeed_XIAO_M0_E8D70AB55154305147202020FF050926-if00"; + std::string port_name = "/dev/ttyUSB1"; std::string path = ""; kansei::fallen::DeterminantType determinant_type; @@ -48,7 +48,7 @@ int main(int argc, char * argv[]) if (args.size() > 1) { for (int i = 1; i < args.size(); i++) { - std::string arg = args[i]; + const std::string& arg = args[i]; if (arg == "-h" || arg == "--help") { std::cout << help_message << std::endl; return 1; @@ -62,7 +62,7 @@ int main(int argc, char * argv[]) } } else if (arg == "--type") { if (i + 1 < args.size()) { - std::string fallen_type = args[i + 1]; + const std::string& fallen_type = args[i + 1]; if (fallen_type == "orientation") { determinant_type = kansei::fallen::DeterminantType::ORIENTATION; } else if (fallen_type == "accelero") {