Skip to Content
VectorLib

TitanTron additions

Early lambdas, scaled IMU, point paths, live PID gains and odometry offsets from LemLib-TitanTron.

Team 38535A's LemLib-TitanTron fork adds the features below. They change nothing unless you use them, so LemLib programs behave exactly as before.

Early lambdas

Run code once, in its own task, the first time the robot gets within a range of the target: start the intake 12 inches out, or lift an arm partway through a turn. Blocking inside the lambda does not stall the motion.

chassis
    .move_to_point(0.0, 48.0, 4000)
    .early_lambda_range(12.0)
    .early_lambda(move || async move {
        sleep(Duration::from_millis(200)).await;
        println!("12 inches from the goal");
    })
    .await;

TitanTron takes a std::function<void()> and starts it with new pros::Task(...). The vexide equivalent of a task is a future, so the lambda returns one.

Turns compare the signed error

Like TitanTron, angular motions check error <= range without taking the absolute value, so a turn whose error is already negative fires its lambda on the first loop. Lateral motions use the distance, which is never negative.

Following points built at runtime

let points = vec![
    Pose::new(0.0, 0.0, 127.0), // x, y, speed at that point
    Pose::new(0.0, 24.0, 100.0),
    Pose::new(12.0, 40.0, 0.0),
];
chassis.follow(points, 10.0, 4000).await;

Tuning gains while the program runs

chassis.angular_pid().k_p += 0.1;
chassis.lateral_pid().k_d = 40.0;

The PID tuner is built on this.

Scaled IMU

ScalingImu multiplies the IMU's heading and rotation by a constant. See Correcting a drifting IMU.

Measuring tracking wheel offsets

chassis.calculate_odom_offsets().await turns in place ten times and returns [vertical1, vertical2, horizontal1, horizontal2], with -9999 for wheels that are not connected.

Don't use these numbers yet

TitanTron resets the wheels once, before the first of ten alternating turns, then divides each turn's total distance by that turn's angle alone. The turns cancel, so it returns about −offset/2: a wheel at −2.5 in comes back as 1.25. VectorLib reproduces this exactly because it is TitanTron's behaviour; a fix will come as a separate, deliberate change.

On this page