diff --git a/src/core/logic/motor.rs b/src/core/logic/motor.rs index b961b0f..81a98a1 100644 --- a/src/core/logic/motor.rs +++ b/src/core/logic/motor.rs @@ -11,11 +11,12 @@ use crate::core::logic::pid; /// ## Usage /// /// Creating this allows for the controller a motor via a simple PID f32 signed Speed command, rather than u16 speed commands +/// Notice that this also TAKES the motor from your manual controller, you loose access to the manual hand control you had before. pub struct Controller where T: motor::Driver + motor::Sensor, { - pub motor: T, + motor: T, max_speed: Speed, pid: pid::PID, current_direction: Direction, @@ -38,4 +39,13 @@ impl Controller { self.motor .set_speed_and_direction(motor_command, self.current_direction); } + + pub fn new(motor: T, max_speed: Speed, pid: pid::PID) -> Self { + Controller { + motor: motor, + max_speed: max_speed, + pid: pid, + current_direction: Direction::CCW, + } + } }