Moving Autonomously

Arguably the most fundamental task with regard to creating a good autonomous routine is ensuring consistent and accurate movement of the chassis. Robotic autonomous movement is an unsolved problem even among professional engineers, so it is obviously a difficult task. OkapiLib makes it easy to get reasonably accurate autonomous movements.

The basis for this autonomous movement is the ChassisController class. Take a look at its API for more detailed info on it. We'll use a ChassisControllerIntegrated for this tutorial; using the V5 motors' onboard PID makes setup a much quicker and easier process (No PID tuning needed!).

Let's start by creating the ChassisControllerIntegrated with drive motors in ports 1 and 2:

std::shared_ptr<ChassisController> chassis =
    .withMotors(1, -2)
    // Green gearset, 4 in wheel diam, 11.5 in wheel track
    .withDimensions(AbstractMotor::gearset::green, {{4_in, 11.5_in}, imev5GreenTPR})

Now that we've created a ChassisController, let's start moving around. There are two fundamental movement types: moveDistance and turnAngle, for moving forward/backward and turning on a point.

// Move 1 meter to the first goal
// Turn 90 degrees to face second goal
// Drive 1 and a half feet toward second goal