team_com disallowed robots to send messages if not intended, and reduces the rate if we get close to the budget end#805
Hidden character warning
Conversation
…ces the rate if we get close to the budget end
| if self.gamestate is not None and not self.gamestate.penalized: | ||
| return False | ||
| #if we are close to our message budget, we dont want to continue publishing | ||
| if self.gamestate is not None and (self.gamestate.message_budget > 40): |
There was a problem hiding this comment.
Please add reasoning about 40 and swapp > for <
| def reduce_rate(self): | ||
| self.rate = 1 | ||
| self.timer.cancel() | ||
| self.timer = self.node.create_timer(1 / self.rate, self.send_message, callback_group=MutuallyExclusiveCallbackGroup()) |
There was a problem hiding this comment.
Please move this timer creation to a separate function, as this is duplicated from above.
| return transforms3d.euler.quat2euler([quaternion.w, quaternion.x, quaternion.y, quaternion.z]) | ||
|
|
||
| def reduce_rate(self): | ||
| self.rate = 1 |
There was a problem hiding this comment.
Please add a self.logger.warning message about reducing the rate.
| @@ -52,6 +52,7 @@ def __init__(self): | |||
| self.rate: int = self.node.get_parameter("rate").value | |||
There was a problem hiding this comment.
Please add a parameter reduced_rate and use that instead of hardcoded 1
| def send_message(self): | ||
|
|
||
| if not self.rate_is_reduced: | ||
| if self.gamestate is not None and self.gamestate.secs_remaining > 180 and (self.gamestate.message_budget / self.gamestate.secs_remaining) < 11.2: |
There was a problem hiding this comment.
Please move this logic to a method should_reduce_rate(self, ...) -> bool
Please add some reasoning for the magic values.
|
Also please address the failing code style checks |
| if game_state_penalized_team_mates == 4: | ||
| return "FOUR" | ||
| elif game_state_penalized_team_mates == 3: | ||
| return "THREE" | ||
| elif game_state_penalized_team_mates == 2: | ||
| return "TWO" | ||
| elif game_state_penalized_team_mates == 1: | ||
| return "ONE" | ||
| else: | ||
| return "ZERO" | ||
|
|
||
| def get_reevaluate(self): | ||
| """ | ||
| Game state can change during the game | ||
| """ | ||
| return True | ||
|
|
||
| class NumberPenalizedRivals(AbstractDecisionElement): | ||
| blackboard: BodyBlackboard | ||
|
|
||
| def __init__(self, blackboard, dsd, parameters): | ||
| super().__init__(blackboard, dsd, parameters) | ||
|
|
||
| def perform(self, reevaluate=False): | ||
| """ | ||
| Return number of penalized rivals | ||
| :param reevaluate: | ||
| :return: | ||
| """ | ||
| game_state_penalized_rivals = self.blackboard.gamestate.get_penalized_rivals() | ||
|
|
||
| if game_state_penalized_rivals == 4: | ||
| return "FOUR" | ||
| elif game_state_penalized_rivals == 3: | ||
| return "THREE" | ||
| elif game_state_penalized_rivals == 2: | ||
| return "TWO" | ||
| elif game_state_penalized_rivals == 1: | ||
| return "ONE" | ||
| else: | ||
| return "ZERO" |
There was a problem hiding this comment.
There would be the possibility of having more than four in an advanced game with substitutes, I think.
Summary
Related issues
Checklist
pixi run build