Skip to content
Tempo on GitHub (opens in a new tab)

3.17 Robot extensions

A RobotExtension adds the distance an intake or arm sticks out past the bumpers to the footprint Tempo plans around obstacles with. Measure the distance from the outside of the bumper.

Setting an extension on a route

Java
Composer.startAt(start)
    .to(openField)                                       // frame and bumpers only
    .to(pickup)
        .extension(RobotExtension.front(0.35))           // intake out from this leg on
    .to(staging)
        .extension(RobotExtension.none());               // stowed again from here
Python
(Composer.start_at(start)
    .to(open_field)                                      # frame and bumpers only
    .to(pickup)
        .extension(RobotExtension.front(0.35))           # intake out from this leg on
    .to(staging)
        .extension(RobotExtension.none()))               # stowed again from here
C++
tempo::Composer::start_at(start)
    .to(open_field)                                      // frame and bumpers only
    .to(pickup)
        .extension(tempo::RobotExtension::front(0.35))   // intake out from this leg on
    .to(staging)
        .extension(tempo::RobotExtension::none());       // stowed again from here

extension(...) applies to the leg it follows and every later leg until another extension(...) changes it. If you call it before the first to(...) it sets the route’s default. It only changes the planned footprint, and your own command still moves the mechanism.

CallGrowth (meters)
RobotExtension.none()none
front(d), back(d), left(d), right(d)d off one side
rect(front, back, left, right)each side separately
a.union(b)the larger of a and b on each side

A negative or non-finite distance throws.

isNone() checks for no growth.

The is_none property checks for no growth.

is_none() checks for no growth. C++ spells union as united_with(other).

Inferring it from commands

You can also name an extension once and bind it to the commands that deploy and stow the mechanism. Tempo then works out each leg’s extension from the hooks on the route.

Java
import com.tempo.CommandEffect;
import com.tempo.RobotExtension;
import com.tempo.Tempo;

Tempo.extensions()
    .define("IntakeOut", RobotExtension.front(0.35))
    .define("ArmBack",   RobotExtension.back(0.28));

Tempo.commands()
    .bind("deployIntake", deployIntake, CommandEffect.set("IntakeOut"))
    .bind("stowIntake",   stowIntake,   CommandEffect.clear())
    .bind("scoreArm",     scoreArm,     CommandEffect.whileRunning("ArmBack"));
Python
from tempo import RobotExtension, Tempo
from tempo.command_effect import CommandEffect

(Tempo.extensions()
    .define("IntakeOut", RobotExtension.front(0.35))
    .define("ArmBack",   RobotExtension.back(0.28)))

(Tempo.commands()
    .bind("deployIntake", deploy_intake, CommandEffect.set("IntakeOut"))
    .bind("stowIntake",   stow_intake,   CommandEffect.clear())
    .bind("scoreArm",     score_arm,     CommandEffect.while_running("ArmBack")))
C++
tempo::Tempo::extensions()
    .define("IntakeOut", tempo::RobotExtension::front(0.35))
    .define("ArmBack",   tempo::RobotExtension::back(0.28));

tempo::Tempo::commands()
    .bind("deployIntake", deployIntake, tempo::CommandEffect::set("IntakeOut"))
    .bind("stowIntake",   stowIntake,   tempo::CommandEffect::clear())
    .bind("scoreArm",     scoreArm,     tempo::CommandEffect::while_running("ArmBack"));

Commands are matched by object, so pass the same command object to bind and to the route. Calling a command factory a second time makes a new object that isn’t bound. The first argument of bind is a name for the command, and the route doesn’t use it.

In C++, bind takes a pointer to the command, which is what deployIntake is in the sample. If you keep a CommandPtr in a member, pass its .get() to both bind and the route. The address of the CommandPtr doesn’t compile in bind.

When a bound command is used as a hook with run, runWhile, runBefore or runAfter, its CommandEffect changes the planned footprint. A bound runOnFailure command doesn’t.

EffectFootprint
set(ext) or set("Name")every later leg of the route, until a clear() or another set, which replaces it. On a runBefore, run or runWhile hook, it also covers the whole leg the hook is written on
clear()no inferred extension from then on
whileRunning(ext) (while_running)the whole leg the run or runWhile hook is written on, and no later leg
CommandEffect.none()unchanged, and the default for an unbound command

whileRunning adds the extension for the whole leg even if the hook’s trigger never fires. It has no effect on runBefore or runAfter hooks. If the mechanism can still be out after its command ends, use set and clear instead.

A clear() on a runBefore hook removes the extension for the leg the hook is written on. On a run or runWhile hook that leg still plans with the extension for its whole length, and the legs after it plan without it. If the robot has to be retracted before a narrow spot, put the clear() on a runBefore.

When more than one extension applies to a leg, Tempo plans with the larger value on each side. define and bind can come in either order.

Warning A misspelled name plans without the clearance

A name that was never defined resolves to no extension. There’s no error for it, and the route plans with the frame and bumpers only.

Note extension(...) overrides bound commands

If a leg has an extension(…) other than none(), including one still applied from an earlier leg, Tempo plans with it and doesn’t use the bound commands. extension(RobotExtension.none()) doesn’t cancel an extension inferred from commands, so bind a clear() where the mechanism retracts.

esc

Loading search...