Added new method for the controller struct.

This commit is contained in:
2026-06-12 19:00:16 -05:00
parent 21768597a4
commit e0e987f072
+11 -1
View File
@@ -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<T>
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<T: motor::Driver + motor::Sensor> Controller<T> {
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,
}
}
}