-
Notifications
You must be signed in to change notification settings - Fork 1
Filter vision detections to roster defined by vision→cmd mapping #127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
2205038
d3afaef
5743e92
9f215d1
91888ec
f85d874
13867f0
a98141c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -60,6 +60,8 @@ def __init__( | |
| full_field_dims: FieldDimensions, | ||
| filtering: bool = True, | ||
| exp_ball: bool = True, | ||
| allowed_yellow_ids: Optional[frozenset[int]] = None, | ||
| allowed_blue_ids: Optional[frozenset[int]] = None, | ||
| ): | ||
| # alpha=0 means no change in angle (inf smoothing), alpha=1 means no smoothing | ||
| self.angle_smoother = AngleSmoother(alpha=1) | ||
|
|
@@ -80,6 +82,8 @@ def __init__( | |
| ) | ||
|
|
||
| self.exp_ball = exp_ball | ||
| self.allowed_yellow_ids = allowed_yellow_ids | ||
| self.allowed_blue_ids = allowed_blue_ids | ||
|
|
||
| if self.filtering: | ||
| # Instantiate a dedicated Kalman filter for each robot so filtering can be kept independent. | ||
|
|
@@ -238,13 +242,22 @@ def _include_vanished_robots( | |
| game_frame.enemy_robots.keys(), | ||
| ) | ||
|
|
||
| # Current vision IDs | ||
| yellow_present = {r.id for r in vision_data.yellow_robots} | ||
| blue_present = {r.id for r in vision_data.blue_robots} | ||
| # Current vision IDs (filtered to roster if provided) | ||
| yellow_robots = vision_data.yellow_robots | ||
| blue_robots = vision_data.blue_robots | ||
| if self.allowed_yellow_ids is not None: | ||
| yellow_robots = [r for r in yellow_robots if r.id in self.allowed_yellow_ids] | ||
| yellow_ids_last_frame = yellow_ids_last_frame & self.allowed_yellow_ids | ||
| if self.allowed_blue_ids is not None: | ||
| blue_robots = [r for r in blue_robots if r.id in self.allowed_blue_ids] | ||
| blue_ids_last_frame = blue_ids_last_frame & self.allowed_blue_ids | ||
|
|
||
| yellow_present = {r.id for r in yellow_robots} | ||
| blue_present = {r.id for r in blue_robots} | ||
|
|
||
| # Start with current measurements | ||
| yellow_vision_dict: dict[int, Optional[VisionRobotData]] = {r.id: r for r in vision_data.yellow_robots} | ||
| blue_vision_dict: dict[int, Optional[VisionRobotData]] = {r.id: r for r in vision_data.blue_robots} | ||
| yellow_vision_dict: dict[int, Optional[VisionRobotData]] = {r.id: r for r in yellow_robots} | ||
| blue_vision_dict: dict[int, Optional[VisionRobotData]] = {r.id: r for r in blue_robots} | ||
|
|
||
| # Add None for vanished robots | ||
| for robot_id in yellow_ids_last_frame - yellow_present: | ||
|
|
@@ -330,6 +343,13 @@ def _combine_both_teams_game_vision_positions( | |
| old_yellow_robots = game_frame.enemy_robots.copy() | ||
| old_blue_robots = game_frame.friendly_robots.copy() | ||
|
|
||
| if self.allowed_yellow_ids is not None: | ||
| yellow_vision_robots = [r for r in yellow_vision_robots if r.id in self.allowed_yellow_ids] | ||
| old_yellow_robots = {k: v for k, v in old_yellow_robots.items() if k in self.allowed_yellow_ids} | ||
| if self.allowed_blue_ids is not None: | ||
| blue_vision_robots = [r for r in blue_vision_robots if r.id in self.allowed_blue_ids] | ||
|
Comment on lines
+346
to
+350
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in commit f85d874: added
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in commit f85d874: added |
||
| old_blue_robots = {k: v for k, v in old_blue_robots.items() if k in self.allowed_blue_ids} | ||
|
|
||
| new_yellow_robots = self._combine_single_team_positions( | ||
| old_yellow_robots, | ||
| yellow_vision_robots, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.