diff --git a/src/core/communication/motor.rs b/src/core/communication/motor.rs index d72e5fd..d1236a1 100644 --- a/src/core/communication/motor.rs +++ b/src/core/communication/motor.rs @@ -11,7 +11,25 @@ pub struct MotorDriverShaftSpeed { } impl MotorDriverShaftSpeed { + pub fn speed_as_rpm(&self) -> f32 { + match self.shaft_speed { + Some(mut speed) => { + match self.unit { + Unit::Radians => {speed /= core::f32::consts::PI * 2.0;} + _ => {} + } + match self.time_scale { + TimeScale::PerSecond => {speed *= 60.0;} + _ => {} + } + speed + } + None => { + 0.0 + } + } + } } impl Display for MotorDriverShaftSpeed { diff --git a/src/core/positional.rs b/src/core/positional.rs index 03c7b20..bb414c5 100644 --- a/src/core/positional.rs +++ b/src/core/positional.rs @@ -147,24 +147,24 @@ impl Display for XYZAccel { } ///Structs that impl this trait, mean they are positions. Determine what type of position by reading the unit. -trait Position : XYZData { +pub trait Position : XYZData { } ///Structs that impl this trait mean they are Velocities. Determine what type of velocity by reading the unit. -trait Velocity : XYZData{ +pub trait Velocity : XYZData{ } ///Structs that impl this trait mean they are Accelerations. Determine what type of Acceleration by reading the unit. -trait Acceleration : XYZData{ +pub trait Acceleration : XYZData{ } ///This is the data backbone for the XYZ Position, Velocity, and Acceleration Data structs. ///They MUST implmenent this so it possible to easily and quickly get the data from the struct. ///Provides methods to check what type this is -trait XYZData { +pub trait XYZData { fn x(&self) -> Option; fn y(&self) -> Option; fn z(&self) -> Option;