Skip to content

Testing and Debugging Role Switching

Alex Baucom edited this page Mar 20, 2017 · 1 revision

In Role Switching, the main files involved are TeamSPL.lua and utilMsg.lua. The file utilMsg.lua has several message utilities for creating and decoding player messages while the file TeamSPL.lua handles all of the role switching and team ball computations.

The update() function of TeamSPL.lua is where all of the main computation is handled and it is fairly well commented for easy debugging. There are four main steps to the update function:

  • Send the current state message and collect all of the incoming state messages
  • Call the team ball calculation (see below) function and build lists of player eta to team ball and distance to defending goal
  • Sort eta and defender lists and figure out which role the current player should take one
  • Update shared memory and team data

The calc_team_ball() function is organized as follows:

  • Collect all teammate data and compute the probability that they see the correct ball
  • If nobody saw the ball or only one person saw the ball, we are basically done
  • If multiple people saw the ball, figure out if any of them are seeing the same ball
  • If they are, then trust that ball
  • If everyone is seeing different balls, then pick the one with the highest probability

Tips and Tricks

  • This function shouldn't need lots of special testing or debugging unless you see weird role switching choices happening in a game. Running multiple robots at the same time and watching the team monitor for unexpected switches is one of the best ways to see what is going on. This function is also setup with Logging so you can check the log files too.
  • If there are issues, try to narrow the issue down to a problem with the team ball or a problem with the role switching. If everyone agrees on the team ball properly, then the robots were likely just in a strange edge case that the role switching algorithm didn't handle right and it just needs to be tweaked slightly. If there is an issue with the team ball agreement, then some parameters in the team ball calculation might need to be changed.
  • If roles are jumping around too much, you could try tweaking the nonAttackerPenalty, the nonDefnederPenlaty, or the fallDownPenalty. These give penalties to the eta and defender distance of different players to try to prevent rapid switching. You could also consider implementing some sort of time delay between switches as well (i.e. once a switch happens, you can re-switch for a few seconds).
Clone this wiki locally