team_com disallowed robots to send messages if not intended, and reduces the rate if we get close to the budget end#870
Conversation
…ces the rate if we get close to the budget end
…aying without team com
There was a problem hiding this comment.
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_rateand 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.gamstatetypo as above inRankToBallNoGoalie; it will raiseAttributeErrorat 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 settingwas_goalie_active, the secondsumwill likely return 0, so this function will incorrectly returnFalse. 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.
|
@copilot please resolve the found issues. Omit the comment that still needs discussion. At the end, run |
Agent-Logs-Url: https://github.com/bit-bots/bitbots_main/sessions/2ea79016-c148-4fe2-ac42-4250253e549b Co-authored-by: jaagut <34797331+jaagut@users.noreply.github.com>
Agent-Logs-Url: https://github.com/bit-bots/bitbots_main/sessions/2ea79016-c148-4fe2-ac42-4250253e549b Co-authored-by: jaagut <34797331+jaagut@users.noreply.github.com>
Agent-Logs-Url: https://github.com/bit-bots/bitbots_main/sessions/2ea79016-c148-4fe2-ac42-4250253e549b Co-authored-by: jaagut <34797331+jaagut@users.noreply.github.com>
Addressed the requested review findings (excluding the human-discussion thread) in commits 0b5294e, b90edc8, and 0eccd8d. I also executed the requested command 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:
If you need me to access, download, or install something from one of these locations, you can either:
|
…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(): |
| JUST_UNPENALIZED --> $GameStateDecider | ||
| INITIAL --> #Init | ||
| ELSE --> #GetWalkreadyAndLocalize | ||
| UNPENALIZED_AFTER_TEAM_COM_LIMIT --> #DoNothing |
There was a problem hiding this comment.
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?
See #805
@cleWu03 @jaagut
Need help on this PR? Tag
@codesmithwith what you need. Autofix is disabled.