Skip to content

Commit

Permalink
add name
Browse files Browse the repository at this point in the history
  • Loading branch information
Steve Nguyen committed Oct 7, 2024
1 parent 1aaa643 commit f28795e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/fake_motor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ impl<const N: usize> Default for FakeMotorsIO<N> {
}

impl<const N: usize> RawMotorsIO<N> for FakeMotorsIO<N> {
/// Get the name of the controller
fn name(&self) -> String {
format!("MotorsController<{:?}>", N)
}

fn is_torque_on(&mut self) -> Result<[bool; N]> {
Ok(self.torque_on)
}
Expand Down
5 changes: 5 additions & 0 deletions src/motors_controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ use crate::{Limit, RawMotorsIO, Result, PID};
pub trait MotorsController<const N: usize> {
fn io(&mut self) -> &mut dyn RawMotorsIO<N>;

/// Get the name of the controller
fn name(&self) -> String {
format!("MotorsController<{:?}>", N)
}

/// Get the offsets of the motors (in radians)
fn offsets(&self) -> [Option<f64>; N];
/// Get the reduction of the motors
Expand Down
1 change: 1 addition & 0 deletions src/motors_io.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::{Result, PID};

pub trait RawMotorsIO<const N: usize> {
fn name(&self) -> String;
/// Check if the motors are ON or OFF
fn is_torque_on(&mut self) -> Result<[bool; N]>;
/// Enable/Disable the torque
Expand Down

0 comments on commit f28795e

Please sign in to comment.