Skip to Content
VectorLib

Driver control

Tank, arcade and curvature drive with LemLib's drive curves.

tank, arcade and curvature take raw joystick values (−127 to 127) and apply the throttle and steer curves you gave the chassis, with LemLib's exact integer maths.

async fn driver(&mut self) {
    loop {
        let state = self.controller.state().unwrap_or_default();
        let left_y = i32::from(state.left_stick.y_raw());
        let right_x = i32::from(state.right_stick.x_raw());
        // throttle, turn, disable drive curve, desaturate bias
        self.chassis.arcade(left_y, right_x, false, 0.5);
        sleep(Duration::from_millis(10)).await;
    }
}
MethodArguments
tank(left, right, disable_drive_curve)Left and right stick Y
arcade(throttle, turn, disable_drive_curve, desaturate_bias)When the motors saturate, desaturate_bias 0 keeps the throttle, 1 keeps the turn; LemLib's default is 0.5
curvature(throttle, turn, disable_drive_curve)Falls back to arcade when the throttle is 0

Use DEFAULT_DRIVE_CURVE for LemLib's default curve, ExpoDriveCurve::new(deadband, min_output, curve) for an exponential one, or implement the DriveCurve trait for your own.