Skip to content

Split goal scene conditions for left and right goals with team color detection - #92

Draft
tomoakiwakawaka with Copilot wants to merge 5 commits into
mainfrom
copilot/fix-86
Draft

Split goal scene conditions for left and right goals with team color detection#92
tomoakiwakawaka with Copilot wants to merge 5 commits into
mainfrom
copilot/fix-86

Conversation

Copilot AI commented Sep 20, 2025

Copy link
Copy Markdown

This PR addresses the need to separate goal detection logic that was previously combined for both left and right goals. The original implementation used a single condition that handled both goals simultaneously, making it difficult to distinguish between different goal scenarios and team contexts.

Key Changes

1. Split Goal Detection Logic

  • Before: Combined condition ((ball_x > poji_goal_x and ...) or (ball_x < nega_goal_x and ...))
  • After: Separate if/elif blocks for right goal (x > 6000) and left goal (x < -6000)

2. Team Color Detection

Added determine_attacking_team() function that:

  • Calculates average distance of each team's robots to the respective goal
  • Determines which team (yellow/blue) is attacking based on proximity
  • Provides context for understanding which team scored

3. Enhanced Data Storage

  • Before: Single file robot_position_goal.csv
  • After: Separate files robot_position_left_goal.csv and robot_position_right_goal.csv
  • Added new columns: attacking_team, goal_side, ball_angle, ball_speed, ball_x, ball_y

4. Ball Trajectory Analysis

Implemented calculate_ball_angle() function that:

  • Computes shooting angle from ball velocity data using math.atan2(vy, vx)
  • Includes both angle (degrees) and speed information
  • Helps analyze shot characteristics and trajectory patterns

5. Integration Fixes

  • Updated goal_scene() function signature to match existing architecture
  • Enabled goal scene thread in main.py with proper argument passing
  • Added robust error handling and debug logging

Example Usage

The system now generates separate CSV files for each goal with enhanced data:

# robot_position_right_goal.csv
yellow_0_x,yellow_0_y,blue_0_x,blue_0_y,...,attacking_team,goal_side,ball_angle,ball_speed,ball_x,ball_y
5000,100,-3000,200,...,yellow,right,26.6,111.8,6100,200

This makes it much easier to analyze:

  • Which team scored on which goal
  • Shot angles and velocities
  • Robot positions during goal events
  • Separate analysis of left vs right goal scenarios

Fixes #86.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI self-assigned this Sep 20, 2025

Copilot AI commented Sep 20, 2025

Copy link
Copy Markdown
Author

@tomoakiwakawaka 👋 This repository doesn't have Copilot instructions. With Copilot instructions, I can understand the repository better, work faster and produce higher quality PRs.

I can generate a .github/copilot-instructions.md file for you automatically. Click here to open a pre-filled issue and assign it to me. I'll write the instructions, and then tag you for review.

Copilot AI and others added 4 commits September 20, 2025 15:42
…ght goals

Co-authored-by: tomoakiwakawaka <131442068+tomoakiwakawaka@users.noreply.github.com>
Co-authored-by: tomoakiwakawaka <131442068+tomoakiwakawaka@users.noreply.github.com>
…gration

Co-authored-by: tomoakiwakawaka <131442068+tomoakiwakawaka@users.noreply.github.com>
Co-authored-by: tomoakiwakawaka <131442068+tomoakiwakawaka@users.noreply.github.com>
Copilot AI changed the title [WIP] goal.pyの条件の分割 Split goal scene conditions for left and right goals with team color detection Sep 20, 2025
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.

goal.pyの条件の分割

2 participants