From 78ce842ba91b3e69d49d561419b0f2801ec0dc1e Mon Sep 17 00:00:00 2001 From: WT-MM Date: Fri, 15 Nov 2024 00:30:17 -0800 Subject: [PATCH 1/2] compile on mac --- daemon/Cargo.toml | 2 -- platforms/kbot/Cargo.toml | 4 +++- platforms/kbot/src/lib.rs | 29 +++++++++++++++++++++++++++++ 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/daemon/Cargo.toml b/daemon/Cargo.toml index 2978ada..775b0c6 100644 --- a/daemon/Cargo.toml +++ b/daemon/Cargo.toml @@ -21,8 +21,6 @@ tower = "0.5" kos-sim = { version = "0.1.0", path = "../platforms/sim", optional = true } kos-stub = { version = "0.1.0", path = "../platforms/stub", optional = true } kos-zeroth-01 = { version = "0.1.0", path = "../platforms/zeroth-01", optional = true } - -[target.'cfg(target_os = "linux")'.dependencies] kos-kbot = { version = "0.1.0", path = "../platforms/kbot", optional = true } [features] diff --git a/platforms/kbot/Cargo.toml b/platforms/kbot/Cargo.toml index 0bcf292..e5859e4 100644 --- a/platforms/kbot/Cargo.toml +++ b/platforms/kbot/Cargo.toml @@ -13,4 +13,6 @@ eyre = "0.6" tracing = "0.1" async-trait = "0.1" robstride = "0.2.8" -imu = "0.1.4" \ No newline at end of file + +[target.'cfg(target_os = "linux")'.dependencies] +imu = "0.1.4" diff --git a/platforms/kbot/src/lib.rs b/platforms/kbot/src/lib.rs index d32ed3c..9c28c2d 100644 --- a/platforms/kbot/src/lib.rs +++ b/platforms/kbot/src/lib.rs @@ -1,7 +1,11 @@ mod actuator; + +#[cfg(target_os = "linux")] mod hexmove; pub use actuator::*; + +#[cfg(target_os = "linux")] pub use hexmove::*; use eyre::{Result, WrapErr}; @@ -48,6 +52,7 @@ impl Platform for KbotPlatform { &self, operations_service: Arc, ) -> Result> { + #[cfg(target_os = "linux")] Ok(vec![ ServiceEnum::Imu(ImuServiceServer::new(IMUServiceImpl::new(Arc::new( KBotIMU::new(operations_service.clone(), "can0", 1, 1) @@ -73,6 +78,30 @@ impl Platform for KbotPlatform { .wrap_err("Failed to create actuator")?, ), ))), + ]); + + #[cfg(not(target_os = "linux"))] + Ok(vec![ + ServiceEnum::Actuator(ActuatorServiceServer::new(ActuatorServiceImpl::new( + Arc::new( + KBotActuator::new( + operations_service, + "/dev/ttyCH341USB0", + HashMap::from([ + (1, MotorType::Type04), + (2, MotorType::Type04), + (3, MotorType::Type04), + (4, MotorType::Type04), + (5, MotorType::Type04), + (6, MotorType::Type01), + ]), + None, + None, + None, + ) + .wrap_err("Failed to create actuator")?, + ), + ))), ]) } From e60c329584762a98e6e5c149b149a41f42885f51 Mon Sep 17 00:00:00 2001 From: WT-MM Date: Fri, 15 Nov 2024 00:32:00 -0800 Subject: [PATCH 2/2] format --- platforms/kbot/src/lib.rs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/platforms/kbot/src/lib.rs b/platforms/kbot/src/lib.rs index 9c28c2d..a855d4d 100644 --- a/platforms/kbot/src/lib.rs +++ b/platforms/kbot/src/lib.rs @@ -81,10 +81,9 @@ impl Platform for KbotPlatform { ]); #[cfg(not(target_os = "linux"))] - Ok(vec![ - ServiceEnum::Actuator(ActuatorServiceServer::new(ActuatorServiceImpl::new( - Arc::new( - KBotActuator::new( + Ok(vec![ServiceEnum::Actuator(ActuatorServiceServer::new( + ActuatorServiceImpl::new(Arc::new( + KBotActuator::new( operations_service, "/dev/ttyCH341USB0", HashMap::from([ @@ -100,9 +99,8 @@ impl Platform for KbotPlatform { None, ) .wrap_err("Failed to create actuator")?, - ), - ))), - ]) + )), + ))]) } fn shutdown(&mut self) -> eyre::Result<()> {