This module contains data structures for the Plays level of STP.
Helper class that provides a standard way to create an ABC using
Coordinate full-team behaviors via Tactics. Assumes number of Roles matches number of robots on the field.
- class stp.play.DiamondFormation(world_state: stp.rc.WorldState)
- property get_regions: List
- Hard Coded Region Bounds
starting with the top left region being the first element, top right, center, bottom left, and then bottom right in order
bounds are x min, x max, y min, y max
- property get_centroids: List
Convenience function for getting center of each region in get_regions() :return: list of region centroids for DiamondFormation
- class stp.play.IPlay
Helper class that provides a standard way to create an ABC using inheritance.
- exception stp.play.RoleAssignFailure
Common base class for all non-exit exceptions.
- class stp.play.Play
Coordinate full-team behaviors via Tactics. Assumes number of Roles matches number of robots on the field. Ends when SituationAnalysis switches the Play, so no is_done() necessary. See tick() for more details on behavior.
- abstract tick(world_state: stp.rc.WorldState) List[rj_msgs.msg.RobotIntent]
Performs one “tick” of the specified play.
- This should:
Determine if role assignment is necessary.
If so, perform role assignment with self.assign_roles().
Tick Tactics to aggregate robot_intents with self.get_robot_intents().
world_state – Current state of the world.
list of robot intents where index = robot_id
- assign_roles(world_state: stp.rc.WorldState) None
Given that all Roles are in sorted order of priority, greedily assign the highest-priority Role to the lowest-cost robot for that Role. Instantiate Tactics with the correct robots post-assignment. (Note that this behavior is largely handled by the init_roles() of each Tactic.) Satisfy constraint that all Roles of a Tactic must all be assigned at once. If a Tactic’s Roles cannot all be filled, none will be filled and a debug message signifying error is displayed along with the tactic’s tick not running.”
- get_robot_intents(world_state: stp.rc.WorldState) List[rj_msgs.msg.RobotIntent]
Has to be called after assigned_roles has been called. Tick each tactic to get a list of RobotIntents for GameplayNode. Each RobotIntent in this list is at index robot_id, or in Python terms: return_list[robot_id] = robot_intent
returns the string with the current play and the current state of the play.