Software · Controls
Watch a behavior tree drive a pretend robot, one tick at a time.
This lab loads Arborist as a JavaScript module, which browsers block for files opened straight from disk. Open it through the docs site, or serve the folder with python3 -m http.server.
Tunable values (ports of the main tree, used from the next Reset)
The download is an Arbor project: bt_project.json, nodes.xml and trees/. Unzip it and open the folder in Arbor.
RetryUntilSuccessful asks forever. That is why Pickup and score wraps it in a Timeout.max_paused_sec (3 s) and the Sequence fails. Wrap it in <ForceSuccess> and the auto carries on.DriveP1: when the path ends, IntakeOnEvent is halted if it is still waiting. Then try a middle_wait_msec of 0 (under More readouts).Sequence to ReactiveSequence. Every tick starts from the first child, and finished children are reset, so Drive path starts over and over. Reactive is for conditions, not steps.AIM to AIMM, or add a node that doesn't exist. The lab marks the node and won't run it.The tree is drawn by Arborist, the viewer inside Arbor, so it looks exactly like Arbor's live view of the real robot.
Trees only ask for a state with SetWantedState (instant). The robot's state machine decides when it is really there, which IsSystemState checks. It is written the way our RobotContainer is: every condition in handleStateTransition(), and updateLogic() only asks subsystems for states.
handleStateTransition():
switch (wanted):
AIM -> system = aimed ? AIM : AIMING
SHOOT -> system = ready ? SHOOT_FEED
: SHOOT_WAIT
else -> system = wanted
updateLogic():
switch (system):
AIMING, AIM -> shooter AIMING
SHOOT_WAIT -> shooter SHOOT
SHOOT_FEED -> shooter SHOOT, intake SQUEEZE
INTAKE -> intake INTAKE
AUTO -> nothing (the auto
sets subsystems)
Aiming takes 0.8 s and needs the camera, except right in front of the hub. The flywheel takes 0.6 s to spin up. The robot is never in SHOOT itself, so IsSystemState SHOOT never succeeds; that is why ShootFor uses a Sleep. The AIMING step state is made up for this lab. The robot runs each 20 ms loop before the tree, and the auto period ends at 20 s.