SAMPLE_TEAM.Soccer.strategy

The module is designed by team Robokit of Phystech Lyceum and team Starkit of MIPT under mentorship of Azer Babaev. The module is designed for strategy of soccer game for forward and goalkeeper.

Module Contents

Classes

GoalKeeper

class GoalKeeper is designed to define goalkeeper's play according to style developed by

Forward

The class Forward is designed for definition of strategy of play for 'forward' role of player

Forward_Vector_Matrix

The class Forward_Vector_Matrix is designed for definition of strategy of play for 'forward' role of player

Player

class Player is designed for implementation of main cycle of player.

class SAMPLE_TEAM.Soccer.strategy.GoalKeeper(logger, motion, local, glob)[исходный код]

class GoalKeeper is designed to define goalkeeper’s play according to style developed by Matvei Ivaschenko - a student of Phystech Lyceum in 2020. Idea of style was in dividing of home half of shoccer field to 8 sectors according to distance from home goals. When ball is in 4 sectors closest to goals A1, A2, A3, A4 goalkeeper attacks ball with purpose transfer it to side of opponent. When ball is in 4 sectors B1, B2, B3, B4 which are in longer distance from goals goalkeeper just slide to better position from current without attempt to attack ball. In case if ball didn’t go longer than 1m after kick of goalkeeper, he will undertake another attempt up to 10 times in total. In case if ball goes to distance longer than 1m or ball can’t be seen by goalkeeper then goalkeeper returns to center of goals.

turn_Face_To_Guest(self)[исходный код]

The method is designed to define kick direction and load it into self.direction_To_Guest direction is measured in radians of yaw. After definition of kick direction robot turns to this direction. In case if robots“ own coordinate self.glob.pf_coord shows lication on own half of field i.e. self.glob.pf_coord[0] < 0 then direction of shooting is 0 if robots“ x coordinate > 0.8 and abs(y coordinate) > 0.6 then direction of kick is to center of opponents“ goals. if robots“ x < 1.5 and abs(y) < 0.25 kick direction will be to corner of opponents“ goals, with left or right corner is defined randomly. in all other positions of robot kick direction is defined as ditection to target point with coordinates x = 0, y = 2.8

goto_Center(self)[исходный код]

Goalkeeper returns to duty position 0.4m in front of own goals. before returning robot checks trustability of localization. If localization is poor then robot undertake special motions by head and by turning to goals with purpose to improve localization. In case if distance to duty position is more than 0.5m then far_distance_plan_approach will be used, else near_distance_omni_motion will be used. after returning to duty position robot turns to kick direction, for which yaw=0 in front of own goals.

find_Ball(self)[исходный код]

Before using motion method seek_Ball_In_Pose goalkeeper define usage of method in quick mode or in accurate mode. In case if localization is trustable quick mode is used means fast_Reaction_On=True. seek_Ball_In_Pose method moves head of robot to 15 positions covering all visible areas in front and in sides of robot. this way seeking of ball is not single task. Robot improves localization through observing localization markers on obtained pictures. In case if fast_Reaction_On=True then observation of surroundings will be interrupted as soon as ball appear in visible sector. Speed of ball is also detected.

scenario_A1(self, dist, napravl)[исходный код]

This method is activated if goalkeeper finds ball at distance less than 0.7m and relative direction from 0 to math.pi/4. Supposed that goalkeeper stands on duty position faced to opponents“ goals before seeking ball. usage:

None: self.scenario_A1(float:dist, float: napravl)

dist - distance to ball from goalkeeper in meters napravl - relative direction to ball from goalkeeper in radians

method undertake 10 attempts to kick off ball to opponents side. In case of successful attempt - ball goes 1m away from goalkeeper - goalkeeper returns to duty position in front of own goals. Otherwise attempts are continued up to 10 times.

scenario_A2(self, dist, napravl)[исходный код]

This method is activated if goalkeeper finds ball at distance less than 0.7m and relative direction from math.pi/4 to math.pi/2. Supposed that goalkeeper stands on duty position faced to opponents“ goals before seeking ball. usage:

None: self.scenario_A1(float:dist, float: napravl)

dist - distance to ball from goalkeeper in meters napravl - relative direction to ball from goalkeeper in radians

method undertake 10 attempts to kick off ball to opponents side. In case of successful attempt - ball goes 1m away from goalkeeper - goalkeeper returns to duty position in front of own goals. Otherwise attempts are continued up to 10 times.

scenario_A3(self, dist, napravl)[исходный код]

This method is activated if goalkeeper finds ball at distance less than 0.7m and relative direction from 0 to -math.pi/4. Supposed that goalkeeper stands on duty position faced to opponents“ goals before seeking ball. usage:

None: self.scenario_A1(float:dist, float: napravl)

dist - distance to ball from goalkeeper in meters napravl - relative direction to ball from goalkeeper in radians

method undertake 10 attempts to kick off ball to opponents side. In case of successful attempt - ball goes 1m away from goalkeeper - goalkeeper returns to duty position in front of own goals. Otherwise attempts are continued up to 10 times.

scenario_A4(self, dist, napravl)[исходный код]

This method is activated if goalkeeper finds ball at distance less than 0.7m and relative direction from -math.pi/4 to -math.pi/2. Supposed that goalkeeper stands on duty position faced to opponents“ goals before seeking ball. usage:

None: self.scenario_A1(float:dist, float: napravl)

dist - distance to ball from goalkeeper in meters napravl - relative direction to ball from goalkeeper in radians

method undertake 10 attempts to kick off ball to opponents side. In case of successful attempt - ball goes 1m away from goalkeeper - goalkeeper returns to duty position in front of own goals. Otherwise attempts are continued up to 10 times.

scenario_B1(self)[исходный код]

This method is activated if goalkeeper finds ball at distance more than 0.7m and less than half of length of field and relative direction from 0 to math.pi/4. Supposed that goalkeeper stands on duty position faced to opponents“ goals before seeking ball. method undertake to slide robot sideways to same Y coordinate as balls“ Y coordinate. In case if balls“ Y coordinate abs value is more than 0.4m robots maximum Y coordinate abs value will be 0.4m After sliding sideways robot undertake turning to 0 direction

scenario_B2(self)[исходный код]

This method is activated if goalkeeper finds ball at distance more than 0.7m and less than half of length of field and relative direction from 0 to math.pi/4. Supposed that goalkeeper stands on duty position faced to opponents“ goals before seeking ball. method undertake to slide robot sideways to same Y coordinate as balls“ Y coordinate. In case if balls“ Y coordinate abs value is more than 0.4m robots maximum Y coordinate abs value will be 0.4m After sliding sideways robot undertake turning to 0 direction

scenario_B3(self)[исходный код]

This method is activated if goalkeeper finds ball at distance more than 0.7m and less than half of length of field and relative direction from 0 to math.pi/4. Supposed that goalkeeper stands on duty position faced to opponents“ goals before seeking ball. method undertake to slide robot sideways to same Y coordinate as balls“ Y coordinate. In case if balls“ Y coordinate abs value is more than 0.4m robots maximum Y coordinate abs value will be 0.4m After sliding sideways robot undertake turning to 0 direction

scenario_B4(self)[исходный код]

This method is activated if goalkeeper finds ball at distance more than 0.7m and less than half of length of field and relative direction from 0 to math.pi/4. Supposed that goalkeeper stands on duty position faced to opponents“ goals before seeking ball. method undertake to slide robot sideways to same Y coordinate as balls“ Y coordinate. In case if balls“ Y coordinate abs value is more than 0.4m robots maximum Y coordinate abs value will be 0.4m After sliding sideways robot undertake turning to 0 direction

class SAMPLE_TEAM.Soccer.strategy.Forward(logger, motion, local, glob)[исходный код]

The class Forward is designed for definition of strategy of play for „forward“ role of player in year 2020. usage:

Forward(object: motion, object: lical, object: glob)

dir_To_Guest(self)[исходный код]

The method is designed to define kick direction and load it into self.direction_To_Guest, direction is measured in radians of yaw. In case if robots“ own coordinate self.glob.pf_coord shows lication on own half of field i.e. self.glob.pf_coord[0] < 0 then direction of shooting is 0 if robots“ x coordinate > 0.8 and abs(y coordinate) > 0.6 then direction of kick is to center of opponents“ goals. if robots“ x < 1.5 and abs(y) < 0.25 kick direction will be to corner of opponents“ goals, with left or right corner is defined randomly. in all other positions of robot kick direction is defined as ditection to target point with coordinates x = 0, y = 2.8 returns float: self.direction_To_Guest

turn_Face_To_Guest(self)[исходный код]
class SAMPLE_TEAM.Soccer.strategy.Forward_Vector_Matrix(logger, motion, local, glob)[исходный код]

The class Forward_Vector_Matrix is designed for definition of strategy of play for „forward“ role of player in year 2021. Matrix is coded in file strategy_data.json This file is readable and editable as well as normal text file. There is a dictionary with one key “strategy_data”. Value of key “strategy_data” is a list with default number of elements 234. Each element of list represents rectangular sector of soccer field with size 20cmX20cm. For each sector there assigned a vector representing yaw direction of shooting when ball is positioned in this sector. Power of shot is coded by attenuation value: 1 – standard power, 2 – power reduced 2 times, 3- power reduced 3 times. Each element of list is coded as follows: [column, row, power, yaw]. Soccer field is split to sectors in 13 rows and 18 columns. Column 0 is near own goals, column 17 is near opposed goals. Row 0 is in positive Y coordinate, row 12 is in negative Y coordinate. Strategy data is imported from strategy_data.json file into self.glob.strategy_data list. usage:

Forward_Vector_Matrix(object: motion, object: local, object: glob)

dir_To_Guest(self)[исходный код]

The method is designed to define kick direction and load it into self.direction_To_Guest. Direction is measured in radians of yaw. usage:

int: row, int: col = self.dir_To_Guest() row, col - row and column of matrix attributing rectangular sector of field where ball coorinate self.glob.ball_coord fits.

turn_Face_To_Guest(self)[исходный код]
class SAMPLE_TEAM.Soccer.strategy.Player(logger, role, second_pressed_button, glob, motion, local)[исходный код]

class Player is designed for implementation of main cycle of player. Real robot have 3 programmable buttons. Combination of button pressing can transmit to programm pressed button code from 1 to 9. At initial button pressing role of player is selected. With second pressed button optional playing mode is selected depending on role. For „forward“ and „forward_old_style“ role second_pressed_button can take value 1 or value 4. With value 1 player starts game as kick-off player, with value 4 player stars as non-kick-off player, which means player starts moving 10 seconds later. For „run_test“ role second_pressed_button can take values from 1 or value 9 with following optional modes: 1 - 10 cycle steps walk forward 2 - 20 cycle side step walk to right 3 - 20 cycle side step walk to left 4 - 20 cycle steps walk forward 5 - 20 cycle steps with rotation to right side 6 - 20 cycle steps with rotation to left side 9 - 20 cycle steps of spot walk All modes of run test are used with purpose to calibrate walking. After calibration is completed results of calibration must be input to file Sim_params.json. Motion module is used calibration data for planning motions and odometry correction into localization. usage:

Player(str: role, int: second_pressed_button, object: glob, object: motion, object: local)

play_game(self)[исходный код]
rotation_test_main_cycle(self, pressed_button)[исходный код]
run_test_main_cycle(self, pressed_button)[исходный код]

For „run_test“ role second_pressed_button can take values from 1 or value 9 with following optional modes: 1 - 10 cycle steps walk forward 2 - 20 cycle side step walk to right 3 - 20 cycle side step walk to left 4 - 20 cycle steps walk forward 5 - 20 cycle steps with rotation to right side 6 - 20 cycle steps with rotation to left side 9 - 20 cycle steps of spot walk All modes of run test are used with purpose to calibrate walking. After calibration is completed results of calibration must be input to file Sim_params.json. Motion module is used calibration data for planning motions and odometry correction into localization. usage:

self.run_test_main_cycle(int: pressed_button)

sidestep_test_main_cycle(self, pressed_button)[исходный код]
norm_yaw(self, yaw)[исходный код]

This module normalizes yaw according to internal rule: -pi <= yaw <= pi usage:

float: yaw = self.norm_yaw(float: yaw) yaw - orientation on horizontal surface in radians,

zero value orientation is directed along X axis

forward_main_cycle(self, pressed_button)[исходный код]

Main cycle method for „forward“ role of player. usage:

self.forward_main_cycle(int: pressed_button)

forward_old_style_main_cycle(self, pressed_button)[исходный код]

Main cycle method for „forward_old_style“ role of player. usage:

self.forward_main_cycle(int: pressed_button)

goalkeeper_main_cycle(self)[исходный код]

goalkeeper main cycle method is based on vector matrix strategy. Goalkeeper doesn’t leave goals too far. Supposed that goalkeeper starts game at point on middle of goal line. After 10 seconds from game start goalkeeper moves to duty position which depends on detected ball position. In case if ball appears in dangetous position goalkeeper attcks ball.

goalkeeper_old_style_main_cycle(self)[исходный код]

main cycle for old style goalkeeper strategy

penalty_Shooter_main_cycle(self)[исходный код]

main cycle for penalty striker

penalty_Goalkeeper_main_cycle(self)[исходный код]
dance_main_cycle(self)[исходный код]