Skip to content

Commit

Permalink
Fixing #150 (#181)
Browse files Browse the repository at this point in the history
  • Loading branch information
gbin authored Dec 24, 2024
1 parent b5d7700 commit 43afb7c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
5 changes: 3 additions & 2 deletions examples/cu_rp_balancebot/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ const SLAB_SIZE: Option<usize> = 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)
Expand Down
9 changes: 8 additions & 1 deletion examples/cu_rp_balancebot/src/sim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -51,6 +52,12 @@ fn setup_copper(mut commands: Commands) {
#[allow(clippy::identity_op)]
const LOG_SLAB_SIZE: Option<usize> = 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(
Expand Down

0 comments on commit 43afb7c

Please sign in to comment.