stp.rc

This module contains data structures that are robocup specific, ie. Robot, Ball, WorldState

Module Contents

Classes

Robot

State of a robot. Pose: [x, y, theta]. Twist: [dx, dy, dtheta]. Properties are

Ball

State of the ball. Properties are used to enforce that instances of this class

GamePeriod

Game period.

GameState

State of the game.

GameRestart

What kind of restart.

Field

Information about the field.

GameInfo

State of the soccer game. Corresponds to a combination of the C++-side PlayState and MatchState

WorldState

Current state of the world.

Attributes

RobotId

stp.rc.RobotId
class stp.rc.Robot(robot_id: RobotId, is_ours: bool, pose: numpy.ndarray, twist: numpy.ndarray, visible: bool, has_ball_sense: bool, kicker_charged: bool, kicker_healthy: bool, lethal_fault: bool)

State of a robot. Pose: [x, y, theta]. Twist: [dx, dy, dtheta]. Properties are to enforce that instances of this class should not be mutated.

property id: RobotId
Returns:

Id of the robot.

property is_ours: bool
Returns:

True if the robot is our robot.

property pose: numpy.ndarray
Returns:

Pose of the robot. [x, y, theta].

property twist: numpy.ndarray
Returns:

Twist of the robot. [dx, dy, dtheta].

property visible: bool
Returns:

True if the robot is visible

property has_ball_sense: bool
Returns:

True if this robot has functioning ball sensors

property kicker_charged: bool
Returns:

True if the kicker capacitors are charged

property kicker_healthy: bool
Returns:

True if the kicker is healthy

property lethal_fault: bool
Returns:

True if the robot has encounted a fault that will prevent further play, such as an FPGA or motor fault.

__slots__ = ['__id', '__is_ours', '__pose', '__twist', '__visible', '__has_ball_sense', '__kicker_charged',...
__id: RobotId
__is_ours: bool
__pose: numpy.ndarray
__twist: numpy.ndarray
__visible: bool
__has_ball_sense: bool
__kicker_charged: bool
__kicker_healthy: bool
__lethal_fault: bool
__repr__() str

Return repr(self).

__eq__(other) bool

Return self==value.

__hash__() int

Return hash(self).

class stp.rc.Ball(pos: numpy.ndarray, vel: numpy.ndarray, visible: bool)

State of the ball. Properties are used to enforce that instances of this class should not be mutated.

property pos: numpy.ndarray
Returns:

Position of the ball. [x, y].

property vel: numpy.ndarray
Returns:

Velocity of the ball. [dx, dy].

property visible: bool
Returns:

True if the ball can currently be seen by the global vision system.

Note that with filtering or additional sensors like whiskers we may still know where the ball is located

__slots__ = ['__pos', '__vel', '__visible']
__pos: numpy.ndarray
__vel: numpy.ndarray
__visible: bool
__repr__() str

Return repr(self).

class stp.rc.GamePeriod(*args, **kwds)

Bases: enum.Enum

Game period.

FIRST_HALF = 0
HALF_TIME = 1
SECOND_HALF = 2
OVERTIME1 = 3
OVERTIME2 = 4
PENALTY_SHOOTOUT = 5
class stp.rc.GameState(*args, **kwds)

Bases: enum.Enum

State of the game.

HALT = 0
STOP = 1
SETUP = 2
READY = 3
PLAYING = 4
PENALTY_PLAYING = 5
class stp.rc.GameRestart(*args, **kwds)

Bases: enum.Enum

What kind of restart.

NONE = 0
KICKOFF = 1
FREE = 2
PENALTY = 3
PLACEMENT = 4
class stp.rc.Field(length_m: float, width_m: float, border_m: float, line_width_m: float, goal_width_m: float, goal_depth_m: float, goal_height_m: float, def_area_short_dist_m: float, def_area_long_dist_m: float, center_radius_m: float, center_diameter_m: float, goal_flat_m: float, floor_length_m: float, floor_width_m: float)

Information about the field.

property our_goal_loc: numpy.ndarray

Convenience function for getting our goal location :return: the location of our goal - its always (0,0)

property center_field_loc: numpy.ndarray

Convenience function for getting the center field location :return: the location of the center of the field

property their_goal_loc: numpy.ndarray

Convenience function for getting the opponents field location :return: the location of the opponents goal

property our_defense_area_coordinates: List

Convenience function for getting our defense area locations :return: the list of points for our defense area locations

property opp_defense_area_coordinates: List

Convenience function for getting oppenent defense area locations Note: each coordinate starts from top left and continues normal order :return: the list of points for opponent defense area locations

property our_goal_post_coordinates: List

Convenience function for getting our goal post coordinates :return: the list of points for our goal post locations

property their_goal_post_coordinates: List

Convenience function for getting their goal post coordinates :return: the list of points for their goal post locations

property our_left_corner: numpy.ndarray
Returns:

the coords of the left corner of our side of the field

property our_right_corner: numpy.ndarray
Returns:

the coords of the right corner of our side of the field

property their_left_corner: numpy.ndarray
Returns:

the coords of the left corner of their side of the field

property their_right_corner: numpy.ndarray
Returns:

the coords of the right corner of their side of the field

property floor_width_m: float
Returns:

width of full field (including borders)

property def_area_x_left_coord: float
Returns:

left x coordinate of the defense area

property def_area_x_right_coord: float
Returns:

right x coordinate of the defense area

property floor_length_m: float
Returns:

length of full field (including borders)

property goal_flat_m: float
Returns:

check on this one

property center_diameter_m: float
Returns:

returns the diameter of the center of the field

property center_radius_m: float
Returns:

returns the radius of the center of the field

property def_area_long_dist_m: float
Returns:

double check on this one

property def_area_short_dist_m: float
Returns:

double check on this one

property border_m: float
Returns:

The size of the border of the field

property line_width_m: float
Returns:

The width of the lines of the field

property length_m: float
Returns:

The length of the field in meters

property width_m: float
Returns:

the width of the field in meters

property goal_width_m: float
Returns:

the width of the goals in meters

property goal_depth_m: float
Returns:

the depth of the goals in meters

property goal_height_m: float
Returns:

the height of the goals in meters

__slots__ = ['__length_m', '__width_m', '__border_m', '__line_width_m', '__goal_width_m', '__goal_depth_m',...
__length_m: float
__width_m: float
__border_m: float
__line_width_m: float
__goal_width_m: float
__goal_depth_m: float
__goal_height_m: float
__def_area_short_dist_m: float
__def_area_long_dist_m: float
__center_radius_m: float
__center_diameter_m: float
__goal_flat_m: float
__floor_length_m: float
__floor_width_m: float
__def_area_x_right_coord: float
__def_area_x_left_coord: float
__field_x_right_coord: float
__field_x_left_coord: float
class stp.rc.GameInfo(period: GamePeriod, state: GameState, restart: GameRestart, our_restart: bool, ball_placement: numpy.array)

State of the soccer game. Corresponds to a combination of the C++-side PlayState and MatchState

property period: GamePeriod
Returns:

The game period

property state: GameState
Returns:

The game state

property restart: GameRestart
Returns:

The game restart state

property our_restart: bool
Returns:

True if it is our restart

property their_restart: bool
Returns:

True if it is their restart

__slots__ = ['__period', '__state', '__restart', '__our_restart', '__ball_placement']
__period: GamePeriod
__state: GameState
__restart: GameRestart
__our_restart: bool
__ball_placement: numpy.array
is_stopped() bool
Returns:

True if play is stopped.

is_ready() bool
Returns:

True if the field is waiting on a team to kick the ball in a restart.

is_setup() bool
Returns:

True if the field is setting up for a penalty kick or kickoff.

is_restart() bool
Returns:

True if there is a restart.

is_kickoff() bool
Returns:

True if the restart is a kickoff.

is_penalty() bool
Returns:

True if the restart is a penalty.

is_free() bool
Returns:

True if the restart is a free kick.

is_free_placement() bool
Returns:

True if the restart is free placement.

ball_placement() numpy.ndarray | None
Returns:

True if the restart is free placement.

class stp.rc.WorldState(our_robots: List[Robot], their_robots: List[Robot], ball: Ball, game_info: GameInfo, field: Field, goalie_id: int)

Current state of the world.

property robots: List[Robot]
Returns:

A list of all robots (created by merging our_robots with their_robots)

property our_robots: List[Robot]
Returns:

A list of our robots

property their_robots: List[Robot]
Returns:

A list of their robots

property ball: Ball
Returns:

The ball

property game_info: GameInfo
Returns:

The GameInfo object

property field: Field
Returns:

The Field object

property goalie_id: int
Returns:

The goalie id (int)

property visible_robots: List[Robot]
Returns:

List of all visible robots

property our_visible_robots: List[Robot]
Returns:

List of all our visible robots

property their_visible_robots: List[Robot]
Returns:

List of all their visible robots

__slots__ = ['__our_robots', '__their_robots', '__ball', '__game_info', '__field', '__goalie_id']
__our_robots: List[Robot]
__their_robots: List[Robot]
__ball: Ball
__game_info: GameInfo
__field: Field
__goalie_id: int