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 14 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 14 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.

@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
…fterTeamCom and correct logic for is_allowed_to_send_message
# We are allowed to send 2.5 messages per second on average with each robot (12000 with 4 robots in a 1200 seconds game).
# the msg_left_linear_rate is the amount of messages we would send if we send exactly with this 2.5 msg per sec per robot rate
# once our actual msg budget is below this linear rate we tend to send more msg then allowed and should reduce our sending rate
if self.game_started_recently():
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.

@cleWu03 why is this necessary?

JUST_UNPENALIZED --> $GameStateDecider
INITIAL --> #Init
ELSE --> #GetWalkreadyAndLocalize
UNPENALIZED_AFTER_TEAM_COM_LIMIT --> #DoNothing
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.

What's the thinking here? Why are we passive after being unpenalized? Is there a possibility this hits every team robot at the same time frame and thus disables the whole team while still being allowed to play?

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