Thanks to visit codestin.com
Credit goes to Github.com

Skip to content

A new FRC structure for python using TimedRobot. More explicit, readable, and dynamic than ever.

License

Notifications You must be signed in to change notification settings

igowuu/FRC-5113-Perry

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

61 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Perry (FRC 5113)

Team 5113's code for Perry, our retired competition bot. Perry's code is written in Python and is based on Robotpy's TimedRobot control system with an order-independent robot architecture for readability.

Python RobotPy License: MIT

Why TimedRobot?

  • Full control over execution - no architecture-based restrictions, so the user has complete flexilibity
  • Simplicity - programming with TimedRobot is dead simple, making it easy to reason about and debug
  • Predictability - nothing happens unless you make it happen
  • Framework minimalism - avoids hidden schedulers and implicit behavior

Core Philosophy

Principle Description
Order independence Loop execution order does not affect behavior. Each file handles its logic independently.
Definite state The bot is fully controlled by states to prevent unintended actions.
Clear ownership Every file or package has one job. For example, 'Arm' controls the arm, and nothing else.
Public APIs only Components interact only via defined interfaces. No components peek at motors or sensors directly.
Explicit over implicit Units are clearly specified (meters, radians, percent output) to avoid error.
Comments Public methods include docstrings explaining each function / reasoning.

File Structure


robot.py

  • Initializes all components of the program and controls overall program flow.
  • Contains only highest-level robot control logic.
  • Robot loops are order-independent, so sequence doesn’t matter.

physics.py

  • Coordinates simulation updates across all simulated components.
  • Changes to real robot behavior are mirrored here for accurate testing.

controls

  • Holds all controller input logic and executes behavior based on it.
  • Defines high-level robot behaviors as finite state machines (FSMs).
  • Each control manages exactly one active behavior per loop via an enum.
  • Controls interact with components exclusively through public APIs.

components

  • Manages low-level ("dumb") hardware interfaces: motors, sensors, encoders, etc.
  • Provides clean methods for reading state and issuing commands.

config

  • Stores hardware constants, PID/FF values, robot info, deadbands, and more.
  • Centralizes configuration to avoid magic numbers.

utils

  • Contains general-purpose helper functions and shared utilities.
  • Provides reusable logic that does not belong to a specific robot subsystem.

sim

  • Contains all simulated components and virtual hardware.
  • Updates the real component objects for ease of testing.
  • Simulated values should typically be accessed via the real objects themselves.

autonomous

  • Contains all autonomous routines for the robot.
  • Each section follows an abstract base class pattern.
  • manager.py – Orchestrates autonomous routines as commanded by robot.py.
  • routines/ – Contains all autonomous routines, each composed of a sequence of steps.
  • steps/ – Contains individual, low-level tasks for specific robot components.

tests

  • Includes unit tests and built-in checks for validating robot code behavior.

Requirements

Python 3.11.x

All Python dependencies are listed in:

requirements.txt

Common Commands

Run Tests

robotpy test

Run Simulation

robotpy sim

Deploy to Robot

robotpy deploy

Intended audience

This style is for teams who:

  • Prefer full control over execution order
  • Prefer explicit state machines over command schedulers
  • Value clarity and debuggability over abstraction
  • Are willing to enforce structural discipline
  • Want code that is understandable for new members

Isn't this just Command-Based?

Command-based TimedRobot
Scheduler No scheduler. robot.py must update all components.
Implicit behavior Explicit behavior. You can see everything happening in your program - no behind the scenes. This alone significantly improves debuggibility and readability.
Structure requirements Fully dynamic. You can structure your programs however you want. It's up to you to maintain good structure.

Final Notes

  • This repository is both comp-ready code and a teaching reference.
  • The best way to understand the flow is to look at the actual program - it's an example in itself.

Usage of this repository allows teams to:

  • Reduce confusing bugs caused by implicit schedulers.
  • Onboard new members faster from transparent code flow.
  • Maintain long-term code quality across multiple seasons.

Thank you for reading through this repository. This takes a lot of time, so I'd love if you could share this with others or give feedback on it.

# Perry - FRC 5113 Robot Code
# Copyright (c) 2026 Jacob Taylor (igowu) <https://github.com/igowuu>
#
# Licensed under the MIT License.
# See https://opensource.org/licenses/MIT for details.