Skip to content

team_com disallowed robots to send messages if not intended, and reduces the rate if we get close to the budget end#870

Open
MegaIng wants to merge 13 commits into
mainfrom
team_com-message_budget-emergency-stop
Open

team_com disallowed robots to send messages if not intended, and reduces the rate if we get close to the budget end#870
MegaIng wants to merge 13 commits into
mainfrom
team_com-message_budget-emergency-stop

Conversation

@MegaIng
Copy link
Copy Markdown
Contributor

@MegaIng MegaIng commented May 24, 2026

See #805

@cleWu03 @jaagut


View with Codesmith Autofix with Codesmith
Need help on this PR? Tag @codesmith with what you need. Autofix is disabled.

@MegaIng MegaIng requested a review from jaagut May 24, 2026 14:37
@github-project-automation github-project-automation Bot moved this to 🆕 New in Software May 24, 2026
@jaagut jaagut moved this from 🆕 New to 👀 In review in Software May 24, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR aims to make team communication (team_com) more budget-aware by reducing the publish rate when the message budget gets tight and stopping message sending when the budget is critically low, with corresponding behavior-layer fallbacks when team comm data is no longer available.

Changes:

  • Add a configurable reduced_rate and switch the team_com timer to a lower publish rate under budget pressure.
  • Block outgoing team_com messages when near the message-budget end and when messages exceed the 512-byte size limit.
  • Introduce behavior/blackboard support to keep decisions working after team_com is stopped (new decision + caching of last known team-data-derived values).

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 13 comments.

Show a summary per file
File Description
src/bitbots_team_communication/bitbots_team_communication/config/team_communication_config.yaml Adds reduced_rate configuration parameter.
src/bitbots_team_communication/bitbots_team_communication/bitbots_team_communication/bitbots_team_communication.py Implements rate reduction + budget/size-based suppression of outgoing messages.
src/bitbots_behavior/bitbots_body_behavior/bitbots_body_behavior/behavior_dsd/main.dsd Adds TeamComLimitReached branching and a new (currently unused) behavior block.
src/bitbots_behavior/bitbots_body_behavior/bitbots_body_behavior/behavior_dsd/decisions/team_com_limit_reached.py New decision element for whether the team_com limit has been reached.
src/bitbots_behavior/bitbots_body_behavior/bitbots_body_behavior/behavior_dsd/decisions/number_penalized_players.py Adds decisions for penalized teammate/rival counts.
src/bitbots_behavior/bitbots_body_behavior/bitbots_body_behavior/behavior_dsd/decisions/is_penalized.py Adds a new return state for “unpenalized after team_com stop”.
src/bitbots_behavior/bitbots_body_behavior/bitbots_body_behavior/behavior_dsd/decisions/goalie_handling_ball.py Uses cached team-data state when team_com is stopped.
src/bitbots_behavior/bitbots_body_behavior/bitbots_body_behavior/behavior_dsd/decisions/goalie_active.py Uses cached team-data state when team_com is stopped.
src/bitbots_behavior/bitbots_body_behavior/bitbots_body_behavior/behavior_dsd/decisions/count_active_players_without_goalie.py Uses cached team-data state when team_com is stopped.
src/bitbots_behavior/bitbots_body_behavior/bitbots_body_behavior/behavior_dsd/decisions/closest_to_ball.py Uses cached ranking when team_com is stopped.
src/bitbots_behavior/bitbots_blackboard/bitbots_blackboard/capsules/team_data_capsule.py Adds caching of last-known team-data-derived values for use without team_com.
src/bitbots_behavior/bitbots_blackboard/bitbots_blackboard/capsules/game_status_capsule.py Tracks “team_com limit reached” and an “unpenalized after stop” flag.
Comments suppressed due to low confidence (3)

src/bitbots_behavior/bitbots_body_behavior/bitbots_body_behavior/behavior_dsd/decisions/closest_to_ball.py:55

  • Same blackboard.gamstate typo as above in RankToBallNoGoalie; it will raise AttributeError at runtime when the team comm limit is reached.
        if self.blackboard.gamstate.get_team_com_limit_has_reached():
            rank = self.blackboard.team_data.get_last_rank_with_team_com()
        else:

src/bitbots_behavior/bitbots_blackboard/bitbots_blackboard/capsules/team_data_capsule.py:240

  • get_is_goalie_active() has the same iterator-consumption issue: sum(map(...)) is called twice on the filtered iterator. After setting was_goalie_active, the second sum will likely return 0, so this function will incorrectly return False. Compute once and reuse the result.
        # Count valid team data infos (aka robots with valid team data)
        self.was_goalie_active = sum(map(self.is_valid, team_data_infos)) == 1
        return sum(map(self.is_valid, team_data_infos)) == 1

src/bitbots_behavior/bitbots_body_behavior/bitbots_body_behavior/behavior_dsd/decisions/count_active_players_without_goalie.py:18

  • When the team comm limit is reached, this path uses cached values from team_data (e.g., get_last_number_active_player()), which are initialized to -1. If the limit is reached before these caches are updated, this decision can fall into the exception path. Consider falling back to computing the current value (or treating -1 as 0) to avoid runtime failures.
        if self.blackboard.gamstate.get_team_com_limit_has_reached():
            number_of_active_teammates = self.blackboard.team_data.get_last_number_active_player()
        else:

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +285 to +286
if(len(proto_msg) > 512):
self.logger.warning(f"Team_com msg not sended, because size {len(proto_msg)} bytes is above the maximum of 512 bytes")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please don't hardcode 512, but put it into a configurable parameter. Use this variable in the warning f-string.

YES --> $ConfigRole
GOALIE --> #GoalieBehavior
ELSE --> $TeamComLimitReached //this decision is only for better visualization
NO -- > $CountActiveRobotsWithoutGoalie
@@ -0,0 +1,66 @@
from bitbots_blackboard.body_blackboard import BodyBlackboard
from dynamic_stack_decider.abstract_decision_element import AbstractDecisionElement
from game_controller_hsl_interfaces.msg import GameState
Comment on lines 223 to 226
# Count valid team data infos (aka robots with valid team data)
self.last_number_of_active_players = sum(map(self.is_valid, team_data_infos))
return sum(map(self.is_valid, team_data_infos))

Comment on lines +25 to +26
self.team_com_limit_has_reached: bool = False
self.upenalized_after_team_com_stop: bool = False
@jaagut
Copy link
Copy Markdown
Member

jaagut commented May 25, 2026

@copilot please resolve the found issues. Omit the comment that still needs discussion. At the end, run pixi run -e format format to make sure the code complies.

Copy link
Copy Markdown

Copilot AI commented May 25, 2026

@copilot please resolve the found issues. Omit the comment that still needs discussion. At the end, run pixi run -e format format to make sure the code complies.

Addressed the requested review findings (excluding the human-discussion thread) in commits 0b5294e, b90edc8, and 0eccd8d. I also executed the requested command pixi run -e format format, but this sandbox does not have pixi installed (pixi: command not found).

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • pixi.sh
    • Triggering command: /usr/bin/curl curl -fsSL REDACTED (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot finished work on behalf of jaagut May 25, 2026 10:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 👀 In review

Development

Successfully merging this pull request may close these issues.

5 participants