In some cases, the game gets terminated in the middle of the game and it seems to be caused by the AutoReferee trying to make a call which is returned with an ILLEGAL response from the GameController. Looking at the logs, the AutoReferee seems to try to award a Direct Free Kick to team A while there is an ongoing Free Kick for team B, which is not possible according to our game rules (the current free kick situation needs to be resolved before a new free kick or penalty kick can be awarded).
Here are three game logs that all have the termination of the game after an ILLEGAL call by the AutoRef:
[EDIT Maike: taken out the logs as they are no public resource]
The interesting lines from the log files are:
```
[9788.661|0985.240] Info: GI placing ball to [3.5609966246876104, -0.7867616154045358, 0]
[9788.661|0985.240] Info: Reset of penalized robots
[9788.661|0985.240] Info: Penalizing fallen robots
[9788.661|0985.240] Info: Finding alternative locations
[9788.662|0985.240] Info: Testing alternative location: [ 3.06099662 -0.78676162 0. ]
[9788.662|0985.240] Info: Testing alternative location: [ 3.56099662 -0.28676162 0. ]
[9788.662|0985.240] Info: Set alternative location to: [ 3.56099662 -0.28676162 0. ]
[9788.662|0985.240] Info: Ball respawned at 3.5609966246876104 -0.2867616154045358 0.07.
[9788.662|0985.240] Info: Waiting for secondary state: DIRECT_FREEKICK:1
[9788.662|0985.240] Info: Sending 123441:DIRECT_FREEKICK:11:READY to GameController.
[9788.662|0985.240] Info: Waiting for GameController to answer to 123441:DIRECT_FREEKICK:11:READY.
[9788.862|0985.240] Info: Waiting for GameController to answer to 123441:DIRECT_FREEKICK:11:READY.
[9789.850|0985.240] Info: New secondary state received from GameController: STATE_DIRECT_FREEKICK, phase 1.
[9789.850|0985.240] Info: State has succesfully changed to STATE_DIRECT_FREEKICK:1
[9789.949|0985.248] Info: [3.5609966246876104, -0.7867616154045358, 0] [3.5609966246876104, -0.2867616154045358, 0.07]
[9789.949|0985.248] Info: Ball in play, can be touched by any player (moved by 50.00 cm).
[9794.119|0985.664] Info: STATUS: Avg speed factor: 0.092 (over last 20.02 seconds)
[9794.119|0985.664] Info: STATUS: state: STATE_PLAYING, remaining time: 477
[9814.171|0987.712] Info: STATUS: Avg speed factor: 0.102 (over last 20.05 seconds)
[9814.171|0987.712] Info: STATUS: state: STATE_PLAYING, remaining time: 477
[9828.015|0989.136] Info: Red team (['1', '2']) is holding the ball.
[9832.826|0989.632] Info: Red team has held the ball for too long.
[9832.826|0989.632] Info: Interruption countdown set to 625
[9832.826|0989.632] Info: Ball not in play, will be kicked by a player from the blue team.
[9832.826|0989.632] Info: Penalty kick awarded to blue team.
[9832.826|0989.632] Info: Waiting for secondary state: PENALTYKICK:0
[9832.826|0989.632] Info: Sending 123993:PENALTYKICK:4 to GameController.
[9832.826|0989.632] Info: Waiting for GameController to answer to 123993:PENALTYKICK:4.
[9833.026|0989.632] Info: Waiting for GameController to answer to 123993:PENALTYKICK:4.
[9833.227|0989.632] Error: Received illegal answer from GameController for message 123993:PENALTYKICK:4.
[9833.227|0989.632] Info: FINAL SCORE: 2-2
[9833.227|0989.632] Info: Terminating 'game_controller' process
[9833.227|0989.632] Info: Stopping animation recording
[9835.687|0989.632] Info: Exiting webots properly
```
The idea proposed in this fix is to consider that during a freekick game interruption, a ball holding should be considered like an illegal kick. Hence, if such a situation is detected, the same procedure as the illegal kick is called, except that there is no WARN message sent any the player as ball holding is a collective foul.
Thanks for your contribution @omichel. We slightly changed the logic for what happens if a team that has the freekick does ball holding. We also moved this logic into another method for code quality
In some cases, the game gets terminated in the middle of the game and it seems to be caused by the AutoReferee trying to make a call which is returned with an ILLEGAL response from the GameController. Looking at the logs, the AutoReferee seems to try to award a Direct Free Kick to team A while there is an ongoing Free Kick for team B, which is not possible according to our game rules (the current free kick situation needs to be resolved before a new free kick or penalty kick can be awarded).
Here are three game logs that all have the termination of the game after an ILLEGAL call by the AutoRef: [EDIT Maike: taken out the logs as they are no public resource]
The interesting lines from the log files are:
``` [9788.661|0985.240] Info: GI placing ball to [3.5609966246876104, -0.7867616154045358, 0] [9788.661|0985.240] Info: Reset of penalized robots [9788.661|0985.240] Info: Penalizing fallen robots [9788.661|0985.240] Info: Finding alternative locations [9788.662|0985.240] Info: Testing alternative location: [ 3.06099662 -0.78676162 0. ] [9788.662|0985.240] Info: Testing alternative location: [ 3.56099662 -0.28676162 0. ] [9788.662|0985.240] Info: Set alternative location to: [ 3.56099662 -0.28676162 0. ] [9788.662|0985.240] Info: Ball respawned at 3.5609966246876104 -0.2867616154045358 0.07. [9788.662|0985.240] Info: Waiting for secondary state: DIRECT_FREEKICK:1 [9788.662|0985.240] Info: Sending 123441:DIRECT_FREEKICK:11:READY to GameController. [9788.662|0985.240] Info: Waiting for GameController to answer to 123441:DIRECT_FREEKICK:11:READY. [9788.862|0985.240] Info: Waiting for GameController to answer to 123441:DIRECT_FREEKICK:11:READY. [9789.850|0985.240] Info: New secondary state received from GameController: STATE_DIRECT_FREEKICK, phase 1. [9789.850|0985.240] Info: State has succesfully changed to STATE_DIRECT_FREEKICK:1 [9789.949|0985.248] Info: [3.5609966246876104, -0.7867616154045358, 0] [3.5609966246876104, -0.2867616154045358, 0.07] [9789.949|0985.248] Info: Ball in play, can be touched by any player (moved by 50.00 cm). [9794.119|0985.664] Info: STATUS: Avg speed factor: 0.092 (over last 20.02 seconds) [9794.119|0985.664] Info: STATUS: state: STATE_PLAYING, remaining time: 477 [9814.171|0987.712] Info: STATUS: Avg speed factor: 0.102 (over last 20.05 seconds) [9814.171|0987.712] Info: STATUS: state: STATE_PLAYING, remaining time: 477 [9828.015|0989.136] Info: Red team (['1', '2']) is holding the ball. [9832.826|0989.632] Info: Red team has held the ball for too long. [9832.826|0989.632] Info: Interruption countdown set to 625 [9832.826|0989.632] Info: Ball not in play, will be kicked by a player from the blue team. [9832.826|0989.632] Info: Penalty kick awarded to blue team. [9832.826|0989.632] Info: Waiting for secondary state: PENALTYKICK:0 [9832.826|0989.632] Info: Sending 123993:PENALTYKICK:4 to GameController. [9832.826|0989.632] Info: Waiting for GameController to answer to 123993:PENALTYKICK:4. [9833.026|0989.632] Info: Waiting for GameController to answer to 123993:PENALTYKICK:4. [9833.227|0989.632] Error: Received illegal answer from GameController for message 123993:PENALTYKICK:4. [9833.227|0989.632] Info: FINAL SCORE: 2-2 [9833.227|0989.632] Info: Terminating 'game_controller' process [9833.227|0989.632] Info: Stopping animation recording [9835.687|0989.632] Info: Exiting webots properly ```The idea proposed in this fix is to consider that during a freekick game interruption, a ball holding should be considered like an illegal kick. Hence, if such a situation is detected, the same procedure as the illegal kick is called, except that there is no WARN message sent any the player as ball holding is a collective foul.