Shooter, shot table and turret

The robot's shooter on the Assemblies tab: its devices, turret, mount and region, and exporting the shot table the robot aims from.

The robot's shooter on the Assemblies tab, with its launch point, turret and hood beside it.
The robot's shooter on the Assemblies tab, with its launch point, turret and hood beside it.

The shooter

Devices your robot code marks @Assembly(type = Assembly.Type.SHOOTER, ...) (the library's AGENTS.md, "Adding an assembly") make up the robot's shooter, listed on the Assemblies tab by the part each plays: flywheel, hood, turret, feeder (what pushes balls along) and gate (what holds them back from the flywheel and lets them through). Select Shooter to set it up in the middle of the tab, with the Shooter Sim's own builder. Beside the builder's cards:

  • Devices: each device's Group (devices in one group move together) and Direction. A hood's or turret's device also has a Gear (the gear ratio: degrees the hood or turret turns per degree of the device, as the robot design's gear ratios are given: 0.5 for a 2:1 reduction) and, unless it is the device chosen to give the part's angle (below), a Center (the part's angle with the device at its zero). Leave them blank for the robot's defaults; a "?" beside each heading says what it is. Each flywheel group after the first (a pincher's second shaft) has a speed as a share of the first group's, explained by its "?": a share tunes a shaft whose wheel grips the ball differently, and a stacked shooter's motors all turn one shaft, so its shares must stay at 1.
  • Turret: its range of motion from the turret's zero, how it turns (the whole shooter, or only the guide), the gear ratio of the device whose angle is the turret's (the same setting as that device's Gear on the Devices tab, blank for 1), and each turret group's slice of the range. For a servo with a known range (the design's Range, else its model's), a line says how far it reaches: its range times the gear ratio, halved, either side of the zero -- in the warning colour when the range of motion goes past it, since the robot refuses shots past the servo's reach. Under Target out of range the turret does what is chosen while the target is outside its range: no turret angle points at it, the robot must turn, and firing waits until the shot is on target. Each choice's "?" and its tooltip in the list say what it does:
    • Wait at its end, then swing across (the default): it stops at the end it reached while following the target. If the robot keeps turning until the other end would point closer to the target by more than the Swing margin, it swings across its whole range to that end in one move and waits there, following the target again when it comes into range on that side.
    • Do nothing: it stops where it is, and follows the target again once the robot has turned it back into range.
    • Wait at the end closer to the target: it swings across the moment the other end points closer, so with the target straight behind the robot small turns can swing it back and forth.

    A shooter with no turret reads No turret: the robot turns to aim, with why in its "?", and offers Shooter points in its place. The page keeps each label short: the sentences are the tooltips of the "?" icons (widgets/info_icon.py), shown on hover and on a click.

  • Mount: the robot's Facing from the shooter's zero (the same setting as Facing beside the robot views, and as Shooter points on the Turret tab, the other way round), the angles a hood that moves reaches, and the fastest the robot moves while shooting (see below); then two settings for the simulated robot: the time between balls and whether each element fired is put back on the field. The launch point is set beside the robot views (below).
  • Region: where on the field the robot shoots at each target from (see below).

Beside the robot views. With the Shooter row selected on the Assemblies tab, or the shooter clicked in an Orthographic view, the right-hand column sets:

  • Launch point: where the ball's flight starts -- Forward of center, Left of center and Above the floor. It is the point the shot table is worked out from, and the point the robot reads its shot at on the field. Its height is the shooter's launch height: the Shooter Sim builder's Launch height is held at it, with why. The ball leaves from this one point whatever the turret's angle, so for a turret that turns the whole shooter, put it on the turret's axis: where the ball really leaves, a few centimetres off the axis and turning round it, is not modelled, and the shot lands up to that offset from where the shot table says.
  • Turret angle from: which of the devices your code marks as the shooter's TURRET gives the turret's angle -- or None, for a shooter fixed on the robot, which the robot turns to aim. That device's zero is the turret's zero (a servo at the middle of its travel, a motor at its encoder's 0), the turret's angle is the device's angle times its Gear Ratio (set on the Turret tab), by its Direction, and it is the device ShooterAim turns. Other turret devices follow it as their slices of the range.
  • Facing: the angle of the robot's front from the turret's zero, left positive: 180° when the turret's zero shoots out of the back, −30° when it points 30° left of the front. With no turret (None (fixed direction; the robot turns to aim)) it reads Shooter points: the direction the shooter is fixed in, from the robot's front, left positive -- 0° out of the front, 180° out of the back. It is the same setting, the other way round.
  • Hood angle from: which of the devices your code marks as the shooter's HOOD sets the hood angle -- or None, for a shooter fixed at one hood angle -- and Hood angle at zero, the hood angle with that device at its zero. The hood angle is that plus the device's angle times its Gear Ratio, by its Direction. A servo's zero is the middle of its travel, and left empty it is the middle of the hood's angles; a motor's zero is its encoder's 0, wherever the robot resets it, so a hood motor needs it set (and each other hood motor its Center) before the shot table exports.
  • With no hood device (None (fixed hood angle)), Hood angle at zero reads Hood angle: the hood angle the shooter is fixed at, degrees above level. It is the shooter's own hood angle (the Shooter tab's), and every shot in the shot table leaves at it.

Turret angles everywhere -- the angle ShooterAim sends a shooter's TURRET @AssemblySetpoint method, the readout beside the drawn shooter, the turret's range -- are degrees from the turret's zero. A shooter with no turret, or no hood, is not an error: it points in its fixed direction, or launches at its fixed hood angle. A device chosen above that isn't available -- the code doesn't mark it as the turret, or the hood, or its subsystem is switched off or not in this design -- counts as none, and the export uses the fixed angle. The Shooter editor says so: no turret on its Turret tab, which offers Shooter points (the same setting as Facing, the other way round), and no hood on its Shooter tab, where Hood angle is the fixed hood angle. Best fixed hood angle, beside it, finds the fixed hood angle that lands the ball from the most of the floor for the robot's shooter, and saves it: the Shooter Sim's own search, on its Field (see the Shooter Sim tab's "Best fixed hood angle").

The robot views draw the shooter as it is set up: a tube from its launch point, pointing the way it shoots, on the Orthographic and 3D views here at rest, and on the Live Robot, Simulate Robot and Recordings fields turned as the run reports -- the solid tube at the angles read back from the Turret angle from and Hood angle from devices, the faint dashed one where the shooter aim wanted it, so a turret or hood that doesn't follow its commands shows, and the angles written beside it. A servo's angle needs its range in degrees on the robot design. A motor's position isn't in a run's samples, so a turret or hood a motor turns is drawn at rest, with only the aim's dashed tube turning.

Moving the shooter. Click the shooter's ring or tube in an Orthographic view to select it -- it is outlined in every view, and the right-hand column shows it, as above. Drag it to move its launch point: forward and left in the Top view, along the side and up in the Front and side views; the other views follow as it moves, and it is saved when you let go. Click a device, or anywhere off the shooter, or press Esc, to go back to the devices. Undo (Cmd/Ctrl+Z) doesn't take back a move of the shooter: drag it back, or type its launch point.

Two settings on the shooter's mount page are for the simulated robot:

  • Simulator: time between balls: in the Desktop Simulator and Simulate Robot, how long apart the shooter lets balls go while its feeder runs with the gate open.
  • Simulator: replace each element fired with a new one on the field: ticked, each element the robot fires is put back somewhere else on the field, outside the forbidden areas, so there is always more to pick up.

Everything is saved to the robot's own shooter_assembly.json. The Shooter Sim's Copy to robot copies a configuration to it, and + ▾ → robot's shooter loads it to compare.

Export shot table

The Turret tab: range of motion, how it turns, and what it does when the target is out of range.
The Turret tab: range of motion, how it turns, and what it does when the target is out of range.
The Mount tab.
The Mount tab.

Export shot table, at the top of the shooter, finds the Shooter Sim's Best shot from here from every spot on the field, for every place the project's targets stand (field_designs/shooter_targets.json), and writes it to the robot's shot_table.json. Sync copies it to the robot, which aims from it: the flywheel speed, hood angle and turret angle for wherever it stands (the library's shooter_aim.md).

  • It simulates the shooter, holding its flywheel at a speed, at the flywheel speeds the Field reads between, then flies every spot as the Field does, the shooter facing the target. Each spot's best window then has its whole burst simulated at speeds across it, for the one that lands the most balls. Each speed is simulated once, whichever spots try it.
  • It takes a while: the line under the button says what it is doing and how far it has got, and Cancel stops it, writing nothing. On one laptop, four target placements took about 35 s of flying -- about 50 s with the band for shots on the move at 1 m/s -- besides the twenty or so simulations, about a second each.
  • Shots on the move. A robot moving as it shoots throws the ball with its own speed added, so the ball leaves at another angle over the ground than the hood gives it: driving toward the target flattens it, driving away steepens it. So that the robot can still read its shot from the table, rather than work one out as it drives, each spot also has a landing curve: the shot that lands from there at each hood angle of a band round the hood's angles, as fast and in the direction the ball must go over the ground -- at the spot's own hood angle, the spot's own shot, so the robot goes on from it as it starts to move. The robot takes its own speed away from each and reads off the one that leaves at an angle its hood gives. The band is as wide either side as the fastest the robot moves while shooting (Mount tab) can tilt the slowest ball that lands: about ±9° at 1 m/s for a ball leaving at 7 m/s, in the Field's 3° steps. A hood that doesn't move gets the band round its one angle. Set it to 0 for a robot that only shoots standing still; a faster one makes the band, and the export, longer.
  • Aiming at any point. A script can aim the shooter at a point no target stands at: a field position, or one the robot's code works out. For those, the table also holds the shot to any point in the open air: at each hood angle of the band, the ball speed that comes down through a point at every 0.25 m along the floor and every 0.1 m up, round the targets' heights, and its flight time. A point within 0.5 m of a target's aim point uses that target's Best instead, which knows its rims. This adds a few seconds of flying at the end.
  • Put right anything the shooter's red line lists first: the export won't start until then.
  • Is the table up to date? With no export under way, the line under the button says whether the robot's shot_table.json was exported from the shooter as it is now: a green dot when it matches, with when it was written; amber when anything it was worked out from has changed since -- the shooter's settings, its devices, launch point, facing or ranges, the shooter parts it uses, the targets or where they stand, the forbidden areas, the robot's size or the project's measured motor variation -- and it needs exporting again; a hollow dot when none has been exported. Each export writes a fingerprint of what it worked from into the table (inputs_sha256, with the time as exported), and the line compares it with what an export would work from now. A table exported before this check shows amber until it is exported again. It doesn't see a library update that simulates the shooter differently.
  • Only from the region. The table has shots only from each target's region (the Region tab, below); everywhere else the robot finds no shot, so ShooterOnTarget stays false and it doesn't fire. Best is searched, and the band flown, only for the region's spots, so a smaller region exports faster. After Fly the floor, an export goes on from that floor rather than flying it again, while it is still the shooter's.
  • A feeder servo the robot drives itself goes to the robot design's named positions feed and hold, and a gate servo to open and closed (Design tab, the servo's named positions): give each both.

Region

The Region tab: the shot table's grid, shaded by each spot's best shot, with the region outlined.
The Region tab: the shot table's grid, shaded by each spot's best shot, with the region outlined.

The Region tab says where on the field the robot shoots at each target from. The field is on the left, and the controls are in a column beside it. While the tab shows, the shooter drawing above shrinks to give the field the height. Pick the Target -- each place a target stands has a region of its own -- and the field shows the shot table's grid, a cell every 15 cm, turned so that target's alliance's drive team is at the bottom.

  • Fly the floor simulates the shooter and flies every spot at every hood angle and flywheel speed, as the export's first part does, for each target's heat map: each spot shaded by its best shot's Overall (the share of its balls that go in with the flywheel's speed spread as the motor varies, and the shot's aim spread by its aim variabilities, as the Field's Overall reads it), or by Shade by's other choices, such as Error tolerance (how far off its hood angle and flywheel speed can be and still go in); grey where no shot is worth taking; nothing where the robot can't stand or can't reach the target. It takes a few minutes. The maps are kept in the robot's shot_floor.json (Robot Designer's only; the robot doesn't read it). Heat maps says whether they were flown for the shooter as it is now (Current, Out of date or Not flown), and Flown says when. Changing the region, the fastest the robot moves while shooting or how the simulated robot feeds doesn't need them flown again; an export flies the floor too, and updates them.
  • The region is drawn bright and outlined; the rest of the floor faded. Drag across the field to add those cells to the region, or drag from a cell of the region to take them out; click a cell to add or take out one. Hold Shift to always add, Alt to always take out. Spots counts the region's spots with a shot, of all the spots with one. Under Spot, the spot under the pointer: where it is, its shade and whether it is in the region.
  • Tolerance ≥ ±…σ, then Select, makes the region the spots whose best shot's flywheel can be off by at least that many standard deviations of its measured speed spread, either way, and still go in (the Shooter Sim tab's guide, Error tolerance): ±1σ is every spot with a shot. It ranks spots by how forgiving they are, counted from the middle of their range of speeds; the speed shot need not be the middle, so it is no share of balls in. All is no region: a shot from everywhere, as before regions. Clear leaves none: the robot doesn't shoot at that target.
  • Copy to other targets gives them this region: as it is for a target of the same alliance, and mirrored as the field mirrors (field.json's alliances symmetry) for one of the other alliance. Without a symmetry it isn't copied to the other alliance's targets.
  • The regions are kept in the robot's shooter_assembly.json, each target's as rows of the grid (# in the region, . outside), from the field's top edge down. A changed region makes the shot table out of date: export again.