1use serde::{Serialize, Deserialize};
2
3use crate::{SyncActuator, Setup};
4use crate::act::parent::{ActuatorParent, RatioActuatorParent};
5
6#[derive(Debug, Serialize, Deserialize)]
12pub struct Gear<C : SyncActuator> {
13 pub ctrl : C,
15
16 pub ratio : f32
18}
19
20impl<C : SyncActuator> Gear<C> {
21 pub fn new(ctrl : C, ratio : f32) -> Self {
24 Self {
25 ctrl,
26 ratio
27 }
28 }
29}
30
31impl<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