← All projectsApr 2025 to Oct 2026

autoBuilder, a PROS library for writing autonomous routines

A tool we used to write 21 autonomous routines for our High Stakes robot is now a PROS library. A team supplies command templates and one function that reports its robot's state, and the library prints the finished code.

A dark poster that reads autoBuilder, with a field showing a dashed robot path, a controller screen showing Point Goal, a terminal with a printed line of code, and a row of command names.
Illustration of autoBuilder with a sample path, the controller command picker, and the terminal lines it prints. The values are samples, not a recorded run.

The problem

Writing autonomous routines by hand meant guessing a coordinate, running the robot, seeing where it missed, and editing the number. During the High Stakes season I added a small tool to our code so I could push the robot to a spot with odometry running, pick a command on the controller, and press A to print the LemLib call with the live coordinates filled in. We used it to write 21 autonomous routines that season.

Watch a routine get built

Left and right on the controller step through the command list, and pressing A rumbles the controller and prints the C++ line. Commands that need no coordinates, like the clamp, print as-is, and the output pastes straight into the autonomous function.

PROS terminal
chassis.moveToPoint(-24.38, -23.91, 1500, goal, false);
clamp.set_value(true);
intake.move(127);
chassis.moveToPoint(-23.64, -46.52, 1500, regularPoint, false);
chassis.turnToHeading(91.83, 500, headingTurn, false);
chassis.moveToPoint(11.85, -46.71, 1500, regularPoint, false);
clamp.set_value(false);
intake.move(0);
A sample routine built with the repository's example commands. The positions are example values chosen for this demonstration, and the terminal lines are what the library's template-filling function produces for them.

Making it modular

The original version was tied to our robot in three places: button handling in main.cpp, hardcoded chassis command functions, and direct pose reads. I moved the button logic into a class in April 2025 and removed the chassis dependency in May 2025 to ship it as a PROS template (version 1.0.0) that only handles controller input, template substitution, and printing.

What main.cpp held in the April 2025 copy, and what the library takes in now.
The autoBuilder constructor at three commits: Apr 22 2025, May 4 2025, and Oct 20 2026.

What a team provides

A team gives it a list of commands (a name and a template string with {key} fields), a snapshot function that returns the values the fields can use, and its controller and screens. Our setup reports x, y, and theta. Another team can add a lift angle or a distance reading to the same function.

// Everything templates can reference as {key}. Add other subsystems here.
autoBuilder::State snapshot() {
  auto p = chassis.getPose();
  return {{"x", p.x}, {"y", p.y}, {"theta", p.theta}};
}
The snapshot function in our example setup, src/main.cpp. This is the only place that reads the robot's pose.

Try it

Drag the robot or move the sliders to change what the snapshot reports, pick a command or edit its template, and press A. The lift key and the Lift To command are not in the repository example. They are here to show a team adding its own value to the snapshot and using it in a template. A field the snapshot has no name for stays as written, as it does in the library.

Drag the robot
Snapshot: what the robot reports
Printed when A is pressedchassis.moveToPose(-24.38, -23.91, 271.46, 1500, regularPose, false);
PROS terminal
An in-browser version of the library's behavior. The template rule is the one in autoBuilder::render, and the lift key and Lift To command are added for this demonstration.

How it runs

run() checks the controller every 100 ms. Left and right move through the command list, and A takes one snapshot, fills the template, and prints the result to the terminal and the brain screen.

Code flow for autoBuilder, from run() to the printed line, drawn from src/autoBuilder.cpp.
State state = snapshot();
std::string out;
for (size_t i = 0; i < tpl.size();) {
  size_t end = tpl[i] == '{' ? tpl.find('}', i) : std::string::npos;
  auto it = end == std::string::npos ? state.end() : state.find(tpl.substr(i + 1, end - i - 1));
  if (it == state.end()) {
    out += tpl[i++];
    continue;
  }
  char buf[32];
  snprintf(buf, sizeof buf, "%.2f", it->second);
  out += buf;
  i = end + 1;
}
return out;
The body of render() in src/autoBuilder.cpp. It reads one snapshot and replaces each field it can find a value for.

More projects

All projects →