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.
| 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") |
There was a problem hiding this comment.
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 | |||
| # 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)) | ||
|
|
| self.team_com_limit_has_reached: bool = False | ||
| self.upenalized_after_team_com_stop: bool = False |
|
@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:
|
See #805
@cleWu03 @jaagut
Need help on this PR? Tag
@codesmithwith what you need. Autofix is disabled.