diff --git a/examples/cu_rp_balancebot/src/main.rs b/examples/cu_rp_balancebot/src/main.rs index 670e96a02..f85643f72 100644 --- a/examples/cu_rp_balancebot/src/main.rs +++ b/examples/cu_rp_balancebot/src/main.rs @@ -16,9 +16,10 @@ const SLAB_SIZE: Option = Some(1 * 1024 * 1024 * 1024); fn main() { static STOP_FLAG: AtomicBool = AtomicBool::new(false); let logger_path = "logs/balance.copper"; - if let Some(parent) = Path::new(logger_path).parent() { - fs::create_dir_all(parent).expect("Failed to create logs directory"); + if !parent.exists() { + fs::create_dir_all(parent).expect("Failed to create logs directory"); + } } let copper_ctx = basic_copper_setup(&PathBuf::from(logger_path), SLAB_SIZE, false, None) diff --git a/examples/cu_rp_balancebot/src/sim.rs b/examples/cu_rp_balancebot/src/sim.rs index 79ed01c0f..54cc3784a 100644 --- a/examples/cu_rp_balancebot/src/sim.rs +++ b/examples/cu_rp_balancebot/src/sim.rs @@ -13,7 +13,8 @@ use cu29::prelude::*; use cu29_helpers::{basic_copper_setup, CopperContext}; use cu_ads7883_new::ADSReadingPayload; use cu_rp_encoder::EncoderPayload; -use std::path::PathBuf; +use std::fs; +use std::path::{Path, PathBuf}; // To enable sim, it is just your regular macro with sim_mode true #[copper_runtime(config = "copperconfig.ron", sim_mode = true)] @@ -51,6 +52,12 @@ fn setup_copper(mut commands: Commands) { #[allow(clippy::identity_op)] const LOG_SLAB_SIZE: Option = Some(1 * 1024 * 1024 * 1024); let logger_path = "logs/balance.copper"; + if let Some(parent) = Path::new(logger_path).parent() { + if !parent.exists() { + fs::create_dir_all(parent).expect("Failed to create logs directory"); + } + } + // here we set up a mock clock so the simulation can take control of it. let (robot_clock, mock) = RobotClock::mock(); let copper_ctx = basic_copper_setup(