ev3_drivebase/drivebase/
speed.rs

1use super::DriveBase;
2use ev3dev_lang_rust::Ev3Error;
3
4impl DriveBase {
5    /// Sets the speed of both motors
6    ///
7    /// # Errors
8    ///
9    /// Errors if it can't set the speed of either motor
10    pub fn set_speed(&mut self, left_speed: i32, right_speed: i32) -> Result<(), Ev3Error> {
11        self.current_speed = left_speed.midpoint(right_speed);
12        self.left.set_speed_sp(left_speed)?;
13        self.right.set_speed_sp(right_speed)?;
14        Ok(())
15    }
16}