Skip to main content

Choose a Shot with Error Margin

Mediumdifficulty

Builder outcome and prerequisites

You'll build a selector that takes simulated shot results, a target distance, the speeds and angles your launcher can do, and how much error to allow for. It returns the best speed and angle and how many of the nearby shots went in. The rule is simple: count how many nearby shots go in, and keep the setting with the most.

A recovered flywheel can still release slightly faster or slower than expected. Compression changes, the hood settles differently, and the ball leaves at a slightly different angle. We want to compare commands under those variations before spending practice time on the robot.

Inspect the family from three views​

The workbench adapts the side view, shot-family view, and tolerance map from the Trajectory Simulation project. They are linked: select a command on the map and both trajectory views update.

The WebGL view places the vertical launch plane inside a three-dimensional field. Scoring family draws one tolerant scoring representative per sampled launch angle. Perturbation cloud draws 81 evenly spaced representatives from the selected command’s full error box. Orbit the field to see the goal depth and the fan of arcs; switch to the side view when you need exact height and distance. The paper’s model remains two-dimensional, so the 3D view adds spatial context without inventing lateral forces.

Each point in the tolerance map is a speed–angle pair. Dark points miss or never reach the descending rim event. The scoring band contains commands that enter. The gold rectangle moves with your chosen command and covers its tested perturbations; the dashed outline marks the measured command envelope.

Predict, compare, explain

Start with Fragile scoring shot. Predict whether its nearby arcs will mostly enter, then choose Perturbation cloud in the 3D view. Switch to Most tolerant shot, orbit the field with drag or arrow keys, and move the target farther away. Compare the two clouds, rectangles, and successful counts, not just the nominal paths.

Selection experimentWhich scoring command has more room for error?

Calculating the 25,403 trajectories once. Target changes will reuse this map.

Coverage ranks commands over a uniformly weighted stress box. It is not a predicted physical success probability.

Worked example: 494 successful perturbations​

At the 70-inch front-lip distance, the selector chooses 5.25 m/s and 58°. Around that command it checks speed offsets from −0.7 to +0.7 m/s in 0.025 m/s steps, and angle offsets from −1.5° to +1.5° in 0.1° steps.

There are 57 speed values × 31 angles = 1,767 trials. Of these, 494 enter, giving:

J=4941767≈0.280.J=\frac{494}{1767}\approx0.280.

The paper calls this a bounded make fraction. Here we label it coverage: the fraction of the specified stress box that enters in simulation. The chosen nominal command must itself enter. The selector maximizes coverage, breaking exact ties by lower speed and then lower angle. The best count need not put the nominal crossing in the center of the opening: it ranks the entire speed–angle neighborhood. Source: paper §5.5, Figure 5.

Why 0.280 and 93/100 are compatible

The stress box gives equal weight to every point across a deliberately wide range of errors. It was not fitted as a probability distribution for repeated shots. The physical result of 93/100 entries therefore does not contradict 0.280 coverage. The two numbers answer different questions.

The ±0.7 m/s and ±1.5° ranges are deliberately generous test margins, not measured shot-to-shot scatter.

Why these bounds, and how much do they matter?​

The speed margin comes from how much the launcher's wheel-to-ball speed ratio varied, about 12%, which is 0.56 to 0.79 m/s at these speeds (paper §5.5). The angle margin is bigger than the 0.3° difference between repeated video measurements, to leave room for the hood and release varying too.

Does the choice of margins matter much? The paper reran the selection at 19 distances from 60 to 105 inches with four different margin sizes, from (0.3 m/s,0.5∘)(0.3\ \mathrm{m/s}, 0.5^\circ) up to (0.9 m/s,2.0∘)(0.9\ \mathrm{m/s}, 2.0^\circ). The chosen speed changed by at most 0.125 m/s and the angle by at most 0.7°, so the answer isn't very sensitive to the exact margins.

Build it in two passes​

First write the simple version: for each setting, skip it if it misses, then try every nearby variation and count how many go in. Keep it around to check the fast version against.

Then speed it up. Simulate each speed and angle once and save where it crosses the rim, mark which ones go in at the target distance, and use running totals to count any rectangle of settings quickly. Both versions should pick the same answer. This all runs on a laptop; the robot only gets the resulting table.

Reuse the flight calculation​

For fixed physical parameters, the descending crossing X(v,θ)X(v,\theta) depends on the command, not on where we place the goal. Moving the goal changes only the entry interval. The experiment therefore calculates the expanded event map once, then applies the new interval to the cached crossings.

A prefix sum makes the rectangular count cheap: store cumulative entry counts, then add and subtract four corners to obtain the count inside any box. This is a faster way to evaluate the same selection rule; it does not change which command wins.

Changing the target distance means recomputing which shots go in, but not re-simulating them. Changing the release height, wind, or physics means re-simulating. The Python simulator doesn't notice changes to its physical constants on its own, so restart it after editing them, as its README says.

Why the map extends beyond the command envelope

Nominal commands lie within the measured 4.70–6.61 m/s, 42–58° envelope. Their possible perturbations can extend beyond that envelope. Clipping the test rectangle at its edge would silently test fewer errors and distort the comparison.

The event map therefore covers 4.00–7.30 m/s and 40.5–59.5°. Every deployed perturbation box fits inside it. The browser performs integration in a worker so the page remains usable while the map is prepared. Source: paper §5.4.

Trace the exported recommendation​

Read physics.py: _event_grid supplies cached crossings, _made_grid applies the opening, and _best_make_window_on_grid ranks equal-sized windows. find_optimal wraps the winner in shot parameters, while sweep_targets evaluates a distance series for export.

The output has an old field called p_make. Despite the name, it's the coverage, not a probability. Some old sigma fields are the margin sizes, not standard deviations.

The browser version uses the same rule with the paper's rounded measurements, and runs the simulation in the background so the page stays responsive.

Reference logic: rank candidates offline​

Visit commands in ascending speed, then ascending angle. Updating only for a strictly larger count preserves the tie rule:

Select the largest make-window count
Candidate chooseShot(List<Candidate> orderedCandidates) {
Candidate best = null;
for (Candidate candidate : orderedCandidates) {
if (!candidate.nominalEntry()) continue;
if (best == null || candidate.makeCount() > best.makeCount()) {
best = candidate;
}
}
return best;
}

Every candidate has to be tested with the same number of variations. A null result means nothing went in at all, not that you should guess a setting outside the table.

Export the evidence with the command​

For each distance, save the chosen speed and angle, the flight time, how many variations went in out of how many tried, the margins, and which version of the geometry and model you used, plus whether any input was clamped.

ExerciseWhich command wins?

A and B both enter and each has 1,767 perturbations. A succeeds on 410 and B on 494. C succeeds on 520, but its nominal trajectory misses. Which should the selector return?

Show solution

B. C is ineligible because the nominal command misses. Among the eligible commands, B has the larger successful count. Its coverage is approximately 0.280, not a predicted physical success probability.

Next: convert the model into robot commands.