01 · Foundation
Project structure
A standard Goodecode workspace keeps editable Python under src/, project metadata beside it, and generated runtime output outside the source file.
Import goode for one-line hardware declarations. Import Any from typing for lifecycle callback signatures.
import goode
from typing import Any02 · Hardware
Robot configuration
Declare only the hardware the robot actually uses. Goodebot reads the declaration name, connection, and role without guessing.
left = goode.Motor_Group_Dec(ports=[-1, -2], name="Left Drive", role="leftDrive")
imu = goode.Sensor_Dec(port=11, name="IMU", sensor="imu")Motors and motor groups
Use Motor_Dec for one motor and Motor_Group_Dec for mechanisms or drivetrain sides. Negative ports reverse direction.
Pneumatics
Pneumatics use lettered ADI banks A–H. Do not represent a piston as a numbered smart-port device.
clamp = goode.Pneumatic_Dec(bank="A", name="Clamp", default=False)Sensors
Repository support covers IMU, rotation, distance, optical, GPS, and vision declarations. The selected kind must match the connected device.
03 · Programs
Program profiles and competition structure
Goodecode uses explicit callbacks for initialization, autonomous, and driver control. Competition setup belongs in competition_initialize.
def initialize(ctx: Any) -> None:
ctx.project_title("My Robot")
ctx.status("Ready")
def competition_initialize(ctx: Any) -> None:
ctx.status("Competition ready")Autonomous routines
Prefer measured distance and heading commands when chassis configuration is available. Timed drive remains a less repeatable fallback.
def autonomous(ctx: Any) -> None:
ctx.drive_for(24, units="in", speed=80)
ctx.turn_to_heading(90, speed=70)Driver control
Keep driver loops responsive and yield each pass. Controller profiles and bindings describe intent while the loop handles live drive input.
Controller input
def opcontrol(ctx: Any) -> None:
ctx.bind_hold("R1", "Intake", power=100)
while ctx.enabled():
ctx.drive_tank(ctx.axis3(), ctx.axis2())
ctx.sleep_ms(20)04 · Output
Brain output
Brain screen layouts use a fixed 480 × 240 canvas. Keep labels clear and touch targets large enough for real use.
def build_info_screen(ctx: Any) -> None:
ctx.screen_page("Main")
ctx.title("Goodebot")
ctx.screen_text(x=16, y=48, text="Ready")Timing
Use ctx.sleep_ms(20) inside continuous loops. Keep initialize fast and deterministic; avoid blocking work that prevents mode transitions.
Reference
Confirmed function reference
Every function below is present in the current extension syntax or source-backed guide. Support remains Beta unless marked otherwise.
goode.Motor_DecBeta+
PurposeDeclare one smart-port motor.
Parametersport, name, role; optional brake
ReturnsMotor declaration metadata
ConstraintsSmart ports are 1–21; a negative port reverses the motor.
arm = goode.Motor_Dec(port=5, name="Arm", role="arm", brake="hold")goode.Motor_Group_DecBeta+
PurposeDeclare a named group of motors.
Parametersports, name, role; optional brake
ReturnsMotor-group declaration metadata
ConstraintsUse a non-empty list of smart ports.
left = goode.Motor_Group_Dec(ports=[-1, -2], name="Left Drive", role="leftDrive")goode.Pneumatic_DecBeta+
PurposeDeclare an ADI pneumatic output.
Parametersbank, name; optional default
ReturnsPneumatic declaration metadata
ConstraintsUse ADI banks A–H, not smart-port numbers.
clamp = goode.Pneumatic_Dec(bank="A", name="Clamp", default=False)goode.Sensor_DecBeta+
PurposeDeclare a supported sensor.
Parametersport, name, sensor
ReturnsSensor declaration metadata
ConstraintsThe sensor kind must match the connected V5 device.
imu = goode.Sensor_Dec(port=11, name="IMU", sensor="imu")ctx.project_titleBeta+
PurposeSet the project name shown in previews and reports.
Parameterstitle: str
ReturnsNone
ConstraintsCall during initialization for deterministic metadata.
ctx.project_title("Goodebot")ctx.statusBeta+
PurposePublish the current readable program status.
Parametersmessage: str
ReturnsNone
ConstraintsKeep messages concise for Brain-sized output.
ctx.status("Ready")ctx.enabledBeta+
PurposeReport whether the current program mode remains enabled.
Parametersnone
Returnsbool
ConstraintsUse it as the condition for driver loops.
while ctx.enabled():
ctx.sleep_ms(20)ctx.sleep_msBeta+
PurposeYield for a duration in milliseconds.
Parametersmilliseconds: int
ReturnsNone
ConstraintsDriver loops should normally yield about 20 ms.
ctx.sleep_ms(20)ctx.drive_tankBeta+
PurposeSet left and right drivetrain power.
Parametersleft, right
ReturnsNone
ConstraintsValues follow the generated runtime’s power range.
ctx.drive_tank(ctx.axis3(), ctx.axis2())ctx.drive_forBeta+
PurposeDrive a measured distance using the configured chassis.
Parametersdistance; units, speed
ReturnsNone
ConstraintsRequires a configured drivetrain; measured motion is preferred over timed drive.
ctx.drive_for(24, units="in", speed=80)ctx.turn_to_headingBeta+
PurposeTurn to an absolute heading.
Parametersheading; speed
ReturnsNone
ConstraintsRequires a configured heading sensor.
ctx.turn_to_heading(90, speed=70)ctx.bind_holdBeta+
PurposeBind a controller button to a held mechanism action.
Parametersbutton, device; power
ReturnsNone
ConstraintsThe named device must already be declared.
ctx.bind_hold("R1", "Intake", power=100)ctx.auton_selectorBeta+
PurposeDefine selectable autonomous entries.
Parameterstitle, entries; save_to_sd
ReturnsNone
ConstraintsEach entry needs a unique slot and name.
ctx.auton_selector(title="Autons", entries=[{"slot": 1, "name": "Skills"}], save_to_sd=True)ctx.selected_autonBeta+
PurposeRead the selected autonomous routine.
Parametersdefault: str
Returnsstr
ConstraintsThe default should match a configured entry name.
selected = ctx.selected_auton(default="Skills")ctx.screen_pageBeta+
PurposeSelect or create the active Brain preview page.
Parametersname: str
ReturnsNone
ConstraintsDesign within the 480 × 240 Brain canvas.
ctx.screen_page("Main")ctx.screen_buttonBeta+
PurposeDraw an actionable button on a Brain page.
Parametersid, text, x, y, width, height, action
ReturnsNone
ConstraintsUse large touch targets and supported action names.
ctx.screen_button(id="save", text="Save", x=24, y=184, width=132, height=38, action="save_auton_selection")05 · Put it together
Complete project example
This one-file example declares only named hardware, sets project metadata, provides competition callbacks, selects an auton, and runs a responsive driver loop.
import goode
from typing import Any
left_drive = goode.Motor_Group_Dec(
ports=[-1, -2, -3], name="Left Drive", role="leftDrive"
)
right_drive = goode.Motor_Group_Dec(
ports=[8, 9, 10], name="Right Drive", role="rightDrive"
)
imu = goode.Sensor_Dec(port=11, name="IMU", sensor="imu")
intake = goode.Motor_Dec(port=5, name="Intake", role="intake")
clamp = goode.Pneumatic_Dec(bank="A", name="Clamp", default=False)
def initialize(ctx: Any) -> None:
ctx.project_title("Goodebot")
ctx.status("Ready")
ctx.use_brain_icon("goodebot")
def competition_initialize(ctx: Any) -> None:
ctx.auton_selector(
title="Autons",
entries=[
{"slot": 1, "name": "Skills", "folder": "skills"},
{"slot": 2, "name": "Match", "folder": "match"},
],
save_to_sd=True,
)
def autonomous(ctx: Any) -> None:
if ctx.selected_auton(default="Skills") == "Skills":
ctx.drive_for(24, units="in", speed=80)
ctx.turn_to_heading(90, speed=70)
def opcontrol(ctx: Any) -> None:
ctx.bind_hold("R1", "Intake", power=100)
ctx.bind_toggle("L1", "Clamp")
while ctx.enabled():
ctx.drive_tank(ctx.axis3(), ctx.axis2())
ctx.sleep_ms(20)06 · Troubleshooting
When code does not build
A declaration is ignored. Keep each goode.*_Dec call on one readable line and use valid ports or ADI banks.
Driver control freezes. Confirm the loop uses ctx.enabled() and yields with ctx.sleep_ms(20).
Movement calls fail validation. Configure the drivetrain and required sensors before using measured chassis actions.
The selected auton is missing. Match the default string to an entry defined in ctx.auton_selector.