From 8f8bf45f02a493c711b3b9c26bd9e722125999a4 Mon Sep 17 00:00:00 2001 From: Chi Huu Huynh <73843190+Chi-EEE@users.noreply.github.com> Date: Fri, 19 Apr 2024 11:43:56 +0100 Subject: [PATCH] Fix compilation --- app/rpi/daemon/src/main.cpp | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/app/rpi/daemon/src/main.cpp b/app/rpi/daemon/src/main.cpp index 2b94c0c8..23e13dd9 100644 --- a/app/rpi/daemon/src/main.cpp +++ b/app/rpi/daemon/src/main.cpp @@ -59,7 +59,7 @@ class rpi_daemon : public daemon configuration->camera_index = reader.GetInteger("Camera", "camera_index", 0); configuration->setCameraFps(reader.GetInteger("Camera", "camera_fps", 60)); - configuration->use_camera = reader.GetBool("Camera", "use_camera", true); + configuration->use_camera = reader.GetBoolean("Camera", "use_camera", true); #ifdef __linux const std::string default_lidar_port = "/dev/ttyUSB0"; #else @@ -68,7 +68,7 @@ class rpi_daemon : public daemon const std::string lidar_port = reader.GetString("Lidar", "lidar_port", default_lidar_port); dlog::info(fmt::format("Using lidar port: {}", lidar_port)); configuration->lidar_port = lidar_port; - configuration->use_lidar = reader.GetBool("Lidar", "use_lidar", true); + configuration->use_lidar = reader.GetBoolean("Lidar", "use_lidar", true); configuration->behaviour_tree_update_ms_interval = std::chrono::milliseconds(reader.GetInteger("BehaviourTree", "behaviour_tree_update_ms_interval", 100)); @@ -203,13 +203,27 @@ class rpi_daemon : public daemon dlog::alert("Could not load 'rpi_daemon.service'\n"); return; } - std::string host = reader.GetString("Host", "host", ""); - dlog::info(fmt::format(R"(Reloading daemon with host: "{}"\n)", host)); + std::shared_ptr configuration = std::make_shared(Configuration{}); + + const std::string host = reader.GetString("RaspberryPi", "host", ""); + dlog::info(fmt::format("Started daemon with host: {}", host)); + configuration->host = host; - std::shared_ptr configuration = std::make_shared(Configuration{ - host, - }); + configuration->camera_index = reader.GetInteger("Camera", "camera_index", 0); + configuration->setCameraFps(reader.GetInteger("Camera", "camera_fps", 60)); + configuration->use_camera = reader.GetBoolean("Camera", "use_camera", true); +#ifdef __linux + const std::string default_lidar_port = "/dev/ttyUSB0"; +#else + const std::string default_lidar_port = "COM3"; +#endif + const std::string lidar_port = reader.GetString("Lidar", "lidar_port", default_lidar_port); + dlog::info(fmt::format("Using lidar port: {}", lidar_port)); + configuration->lidar_port = lidar_port; + configuration->use_lidar = reader.GetBoolean("Lidar", "use_lidar", true); + + configuration->behaviour_tree_update_ms_interval = std::chrono::milliseconds(reader.GetInteger("BehaviourTree", "behaviour_tree_update_ms_interval", 100)); this->any_configuration_empty = host.empty(); if (this->any_configuration_empty)