syact/act/comps/
gear.rs

1use serde::{Serialize, Deserialize};
2
3use crate::{SyncActuator, Setup};
4use crate::act::parent::{ActuatorParent, RatioActuatorParent};
5
6/// A gear component
7/// 
8/// # Gears
9/// 
10/// 
11#[derive(Debug, Serialize, Deserialize)]
12pub struct Gear<C : SyncActuator> {
13    /// Steppercontrol for the motor of the bearing
14    pub ctrl : C,
15    
16    /// Angle ration from motor to bearing (velocity_b / velocity_m)
17    pub ratio : f32
18}
19
20impl<C : SyncActuator> Gear<C> {
21    /// Creates a new `Gearbearing`
22    /// - `device`: The parent component driving the cylinder
23    pub fn new(ctrl : C, ratio : f32) -> Self {
24        Self {
25            ctrl,
26            ratio
27        }
28    }
29}
30
31// Parent
32    impl<C : SyncActuator> Setup for Gear<C> {
33        fn setup(&mut self) -> Result<(), crate::Error> {
34            self.ctrl.setup() 
35        }
36    }
37
38    impl<C : SyncActuator> ActuatorParent for Gear<C> {
39        type Child = C;
40
41        fn child(&self) -> &Self::Child {
42            &self.ctrl
43        }
44
45        fn child_mut(&mut self) -> &mut Self::Child {
46            &mut self.ctrl
47        }
48    }
49
50    impl<C : SyncActuator> RatioActuatorParent for Gear<C> {
51        fn ratio(&self) -> f32 {
52            self.ratio
53        }
54    }
55//