Skip to content

Add function to determine if we can score#96

Merged
auscompgeek merged 1 commit intomainfrom
davo/push-rrytprrqtytr
Feb 8, 2026
Merged

Add function to determine if we can score#96
auscompgeek merged 1 commit intomainfrom
davo/push-rrytprrqtytr

Conversation

@auscompgeek
Copy link
Member

@auscompgeek auscompgeek commented Feb 8, 2026

https://frc-docs--3246.org.readthedocs.build/en/3246/docs/yearly-overview/2026-game-data.html

To test this, run the robot in practice mode, or in the simulator set the match time (to the correct length of the teleop period!)

@greptile-apps
Copy link

greptile-apps bot commented Feb 8, 2026

Greptile Overview

Greptile Summary

Implemented hub activation logic based on 2026 game rules. The is_hub_active() function determines scoring availability by checking match state (autonomous always active), alliance color, game-specific data (which alliance won autonomous), and teleop time ranges with alternating 25-second shifts between active/inactive periods. The shooter controller exposes this status via a @feedback method for use by other robot components.

  • Added is_hub_active() function in utilities/game.py with proper handling of autonomous, teleop phases, and alliance-specific shift patterns
  • Integrated hub status check into Shooter controller via @feedback decorator for magicbot state machine visibility
  • Time-based logic correctly implements 135-second teleop period with transition (5s), four alternating shifts (4×25s), and endgame (30s) periods
  • Proper fallback behavior when alliance or game data is unavailable

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • Implementation is clean, well-structured, and follows defensive programming practices with proper null checks and fallback behavior. Time-based logic correctly implements the 135-second teleop period. Integration with shooter controller uses appropriate magicbot @feedback decorator pattern.
  • No files require special attention

Important Files Changed

Filename Overview
utilities/game.py Adds is_hub_active() function to determine hub availability based on match state, alliance, game data, and time-based shifts
controllers/shooter.py Adds @feedback method is_hub_active() that exposes hub status from game utilities to the shooter state machine

Sequence Diagram

sequenceDiagram
    participant Shooter as Shooter Controller
    participant Game as utilities.game
    participant DS as DriverStation

    Shooter->>Game: is_hub_active()
    Game->>DS: getAlliance()
    DS-->>Game: alliance or None
    
    alt alliance is None
        Game-->>Shooter: False
    else autonomous enabled
        Game->>DS: isAutonomousEnabled()
        DS-->>Game: True
        Game-->>Shooter: True
    else not teleop
        Game->>DS: isTeleopEnabled()
        DS-->>Game: False
        Game-->>Shooter: False
    else teleop enabled
        Game->>DS: getMatchTime()
        DS-->>Game: match_time
        Game->>DS: getGameSpecificMessage()
        DS-->>Game: game_data ("R", "B", or invalid)
        
        Note over Game: Determine red_inactive_first<br/>from game_data
        Note over Game: Calculate shift1_active<br/>based on alliance and<br/>red_inactive_first
        Note over Game: Evaluate time ranges:<br/>- >130s: active (transition)<br/>- 105-130s: shift1<br/>- 80-105s: !shift1<br/>- 55-80s: shift1<br/>- 30-55s: !shift1<br/>- ≤30s: active (endgame)
        
        Game-->>Shooter: True/False
    end
Loading

Copy link
Contributor

@DannyPomeranian DannyPomeranian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, clanker man is not good, but monke sees working code and monke approves working code

@auscompgeek
Copy link
Member Author

135-second teleop period

silly LLM doesn't know about this year's game, teleop this year is 2 minutes and 20 seconds

@auscompgeek auscompgeek force-pushed the davo/push-rrytprrqtytr branch from f5e6907 to 2212936 Compare February 8, 2026 05:25
@auscompgeek auscompgeek merged commit 1c16549 into main Feb 8, 2026
13 checks passed
@auscompgeek auscompgeek deleted the davo/push-rrytprrqtytr branch February 8, 2026 05:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants