Skip to content

Commit

Permalink
testing actuators
Browse files Browse the repository at this point in the history
  • Loading branch information
hatomist committed Nov 15, 2024
1 parent 971cb6a commit 688af65
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 6 deletions.
2 changes: 1 addition & 1 deletion daemon/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ kos-kbot = { version = "0.1.0", path = "../platforms/kbot", optional = true }
kos-zeroth-01 = ["dep:kos-zeroth-01"]
kos-sim = ["dep:kos-sim"]
kos-stub = ["dep:kos-stub"]
default = ["kos-stub"]
default = ["kos-kbot"]

[[bin]]
name = "kos"
Expand Down
2 changes: 1 addition & 1 deletion daemon/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ async fn run_server(
platform: &(dyn Platform + Send + Sync),
operations_service: Arc<OperationsServiceImpl>,
) -> Result<(), Box<dyn std::error::Error>> {
let addr = "[::1]:50051".parse()?;
let addr = "0.0.0.0:50051".parse()?;
let mut server_builder = Server::builder();

let services = platform.create_services(operations_service.clone())?;
Expand Down
7 changes: 6 additions & 1 deletion platforms/kbot/src/hexmove.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ pub struct KBotIMU {
}

impl KBotIMU {
pub fn new(operations_service: Arc<OperationsServiceImpl>, interface: &str, can_id: u32, model: u32) -> Result<Self> {
pub fn new(
operations_service: Arc<OperationsServiceImpl>,
interface: &str,
can_id: u32,
model: u32,
) -> Result<Self> {
info!(
"Initializing KBotIMU with interface: {}, CAN ID: {}, model: {}",
interface, can_id, model
Expand Down
19 changes: 16 additions & 3 deletions platforms/kbot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use kos_core::kos_proto::{
};
use kos_core::services::{ActuatorServiceImpl, IMUServiceImpl};
use kos_core::{services::OperationsServiceImpl, Platform, ServiceEnum};
use robstride::MotorType;
use std::collections::HashMap;
use std::sync::Arc;

Expand Down Expand Up @@ -49,12 +50,24 @@ impl Platform for KbotPlatform {
) -> Result<Vec<ServiceEnum>> {
Ok(vec![
ServiceEnum::Imu(ImuServiceServer::new(IMUServiceImpl::new(Arc::new(
KBotIMU::new(operations_service.clone(), "can0", 1, 1).wrap_err("Failed to create IMU")?,
KBotIMU::new(operations_service.clone(), "can0", 1, 1)
.wrap_err("Failed to create IMU")?,
)))),
ServiceEnum::Actuator(ActuatorServiceServer::new(ActuatorServiceImpl::new(
Arc::new(
KBotActuator::new(operations_service, "/dev/ttyCH341USB0", HashMap::new(), None, None, None)
.wrap_err("Failed to create actuator")?,
KBotActuator::new(
operations_service,
"/dev/ttyCH341USB0",
HashMap::from([
(1, MotorType::Type04),
(2, MotorType::Type04),
(3, MotorType::Type04),
]),
None,
None,
None,
)
.wrap_err("Failed to create actuator")?,
),
))),
])
Expand Down

0 comments on commit 688af65

Please sign in to comment.