Skip to content

Commit

Permalink
Merge pull request #5 from kscalelabs/kos-kbot-dev
Browse files Browse the repository at this point in the history
Compile kbot on mac
  • Loading branch information
hatomist authored Nov 15, 2024
2 parents dbd6392 + e60c329 commit c9367e6
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 4 deletions.
2 changes: 0 additions & 2 deletions daemon/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
4 changes: 3 additions & 1 deletion platforms/kbot/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,6 @@ eyre = "0.6"
tracing = "0.1"
async-trait = "0.1"
robstride = "0.2.8"
imu = "0.1.4"

[target.'cfg(target_os = "linux")'.dependencies]
imu = "0.1.4"
29 changes: 28 additions & 1 deletion platforms/kbot/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down Expand Up @@ -48,6 +52,7 @@ impl Platform for KbotPlatform {
&self,
operations_service: Arc<OperationsServiceImpl>,
) -> Result<Vec<ServiceEnum>> {
#[cfg(target_os = "linux")]
Ok(vec![
ServiceEnum::Imu(ImuServiceServer::new(IMUServiceImpl::new(Arc::new(
KBotIMU::new(operations_service.clone(), "can0", 1, 1)
Expand All @@ -73,7 +78,29 @@ 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")?,
)),
))])
}

fn shutdown(&mut self) -> eyre::Result<()> {
Expand Down

0 comments on commit c9367e6

Please sign in to comment.