Full text
Universidade do Minho Escola de Engenharia António Fernando Alcântara Ribeiro Probability-Based Strategy for Football Cooperative Multi-Agent Autonomous Robots Dissertação de Mestrado Mestrado Integrado em Engenharia Eletrónica Industrial e Computadores Trabalho efetuado sob a orientação de Professor Doutor Luís Miguel Valente Gonçalves Professor Doutor Agostinho Gil Teixeira Lopes janeiro de 2024
Universidade do Minho Escola de Engenharia António Fernando Alcântara Ribeiro Probability-Based Strategy for Football Cooperative Multi-Agent Autonomous Robots Dissertação de Mestrado Mestrado Integrado em Engenharia Eletrónica Industrial e Computadores Trabalho efetuado sob a orientação de Professor Doutor Luís Miguel Valente Gonçalves Professor Doutor Agostinho Gil Teixeira Lopes janeiro de 2024
Copyright and Terms of Use for Third Party Work This dissertation reports on academic work that can be used by third parties as long as the internationally accepted standards and good practices are respected concerning copyright and related rights. This work can thereafter be used under the terms established in the license below. Readers needing authorisation conditions not provided for in the indicated licensing should contact the author through the RepositóriUM of the University of Minho. License granted to users of this work: CC BY-SA https://creativecommons.org/licenses/by-sa/4.0/ i
Acknowledgements The amount of knowledge acquired in this journey was only possible through hard work, motivation, perseverance and the support and incentive of people to whom I would like to thank especially. Firstly, a special thanks to my parents, Marisa Alcântara and Fernando Ribeiro, from whom I will be eternally grateful, for the support, belief, education and opportunities they gave me. I would not have reached this point without them, so for that, thank you. To my Grandparents, António, São, Dina and Fernando, for the help and for being an example that any dream is achievable through effort and hard work. To my little brother Francisco, thank you for being a constant supply of happiness and making me proud daily. To my dear sister Inês, for the support and inspiration. To Tiago, a particular thanks to whom I had the pleasure of working alongside throughout this dissertation, for being a mentor and a role model and for pushing me to improve every day. Also, thank you to Inês Garcia for her bits of advice and constant encouragement. To my godmother Paula Gama and her family, who have always been supportive. To my supervisors and mentors, Professor Gil Lopes and Professor Luís Gonçalves, a huge thanks for the chance to work with him and for all the help, support and guidance. To all Laboratory of Automation and Robotics members for all the fun moments not only in the laboratory but in competitions as well. Including people from the CHARMIE project, Tiago, Inês, Renata, Bruno and many more from other LAR projects such as Rui, Marco and others. To the people who showed perseverance and stayed beside me throughout this LAR@MSL project, thank you for all the nights and the fun moments and for believing in me, Joel, José, Rui, Rúben and Carolina. You are truly the best teammates one could have wished for. A huge thanks to the RoboCup community, especially in MSL, to the Tech United team. They were one of the main reasons that this project started. Thank you for helping our team, coming to Portugal to play with us, helping us during competitions, and for all the encouragement and rooting for us. Without your help and support, this team would not have been able to play, learn and evolve as it did. A big thanks to all Bot’n Roll members, José C., Nino, João, Pedro, Ivo, Bruno, Gonçalo, Luís, José F. and Delfim for being a great example and for supplying me with great opportunities. In particular, thanks to José Cruz for being a constant mentor for many years and for teaching me about electronics and also about life. Thank you to Nino Pereira for being a role model and helping me with the published paper. To my close classmates, whom I thank for all the experiences we had together. To my very good friend Francisco Marques thank you for all the support. Thank you to Margarida Correia, Isaura Lopes, Rita Cunha, Renata Martins, Gabriella Sá, Ana Lages, Rubén Silva, João Pinto, Joel Costa and Bruno Silva. To my extraordinary friend Tiago Oliveira for the encouragement and support. To Abelâmio Silva, Carolina Freitas, Eduarda Cardoso, Gaspar Lopes, José Nuno, Maria Cecília, Marta Ribeiro, and Pedro Berbereia, thank you for the special moments for always being there for me no matter the situation. Also, my scoutmasters, as they were, are and always will be an example to follow and become a better person. Words cannot express my gratitude to Carolina Lopes, who has been extremely helpful, supportive, and a true source of inspiration. Thank you for always being there, for your endless patience, for being a tremendous help, and for constantly pushing me forward for me to improve every day. Your faith in me gave me the courage to keep going no matter what. From the bottom of my heart, I thank you. ii
Statement of Integrity I hereby declare having conducted this academic work with integrity. I confirm that I have not used plagiarism or any form of undue use of information or falsification of results along the process leading to its elaboration. I further declare that I have fully acknowledged the Code of Ethical Conduct of the University of Minho. University of Minho, Braga, february 2024 António Fernando Alcântara Ribeiro iii
Abstract RoboCup is the Robotics World Championship and is one of the reasons for the constant growth, research and development in robotics. One of its leagues is the Middle Size League (MSL), which is a scientific football challenge with teams of five robots. The strategy of a multi-autonomous cooperative robotic system in a football game can be solved in multiple ways, commonly based on the Skills, Tactics and Plays (STP) architecture. With a different approach regarding its architecture, a centralised Probability- Based Strategy (PBS) method is presented in this dissertation and implemented in the LAR@MSL team from the University of Minho. It uses autonomous skills, generates tactics and plays in real-time, based on the probability values of every action possible. The action probabilities also position each robot to optimise the overall probability. This new method centralises all the decision-making processes in the base station, to which the robots communicate, transmit all the data acquired, and receive the ideal skill and respective arguments. The robots are still fully autonomous regarding the skills given to them, just like the strategy improvements and calibration are independent of the robots’ hardware and control systems. Also crucial for this solution was the development of the simulator environment, the communication system and the base station interface. The simulator greatly improved the development time for the strategy, allowing the strategy to be developed in parallel with the robot’s hardware. The communications system implemented was tested and proved reliable even in the most saturated environments. The base station interface developed is the primary debugging tool that allowed the team to interpret values in real-time and interact and calibrate both robots and the strategy. The strategy presented has been fully implemented within the team and tested in multiple scenarios, such as simulators, a controlled environment, against humans in a simulator, and at the RoboCup competition. The Probability-Based Strategy (PBS) proved modular, flexible, and easily adaptable to different game situations with minimal effort. It allows different behaviours against different opponents and can support any team size, either its own or the opponent’s team, without the need for a predefined set of plays. Keywords Football Strategy, Multi-Agent, Autonomous Robot, RoboCup, Probability-Based, Play Generator, Decision Trees, Heat Maps, Simulation, Real-Time Communication iv
Resumo O RoboCup é o Campeonato Mundial de Robótica, sendo este uma das razões de constante crescimento, pesquisa e desenvolvimento da area da robótica. Uma das ligas é o Middle Size League (MSL), que consiste num desafio cientifico de futebol entre equipas de cinco robôs. A estratégia para um sistema de robôs autónomos multi-agente pode ser resolvida de várias maneiras, sendo uma das arquitetura mais comuns a Skills, Tactics and Plays (STP). Com uma abordagem diferente em relação à arquitetura, uma estratégia centralizada baseada em probabilidades foi apresentada ao longo desta dissertação e implementada na equipa LAR@MSL da Universidade do Minho. A estratégia usa habilidades autónomas e gera jogadas e táticas em tempo-real baseando-se nos valores de probabilidade de todas as ações possíveis. As probabilidades de cada ação também são utilizadas para o posicionamento dos robôs, de forma a otimizar a probabilidade total. Este novo método centraliza todas as decisões no computador central, e é para este que os robôs comunicam, transmitem os dados adquiridos e recebem a habilidade ideal e respetivos argumentos. Os robôs continuam a ser completamente autónomos no que toca às habilidades e qualquer melhoria à estratégia e respetiva calibração são independentes do hardware e sistemas de controlo dos robôs. Igualmente importante e também apresentado nesta dissertação são o ambiente de simulação, o sistema de comunicações e a interface do computador principal. O simulador melhorou drasticamente o tempo de desenvolvimento da estratégia, permitindo que esta conseguisse ser desenvolvida em paralelo com o hardware dos próprios robôs. O sistema de comunicações foi testado e provou-se fiável mesmo em ambientes saturados. A interface do computador principal foi desenvolvida como uma ferramenta de debug e permitiu a equipa interpretar valores em tempo real, bem como interagir e calibrar os próprios robôs. A estratégia aqui apresentada foi também totalmente implementada na equipa e testada em vários cenários, como simuladores, num ambiente controlado, contra humanos num simulados e ainda na competição RoboCup. A Probability-Based Strategy (PBS) provou ser modular, flexível, e facilmente adaptável a diferentes situações de jogo com pouco trabalho. Permite à estratégia ter comportamentos diferentes contra diferentes oponentes e é independente do número de robôs, quer da própria equipa quer da equipa oponente, sem haver a necessidade de jogadas predefinidas. Palavras-chave Estratégia de Futebol, Multi-Agente, Robô Autónomo, RoboCup, Baseado em Probabilidade, Gerador de Jogadas, Árvores de Decisão, Mapas de Probabilidades, Simulação, Comunicações em Tempo Real v
Contents 1 Introduction 1 1.1 Problem Description ................................. 1 1.2 Motivation ...................................... 3 1.3 Objectives ...................................... 4 1.4 Document Structure .................................. 5 2 State of the Art 7 2.1 Strategies ....................................... 8 2.1.1 Skills, Tactics and Plays (STP) ........................ 8 2.1.2 Tech United’s Approach ........................... 9 2.1.3 Machine Learning Methods .......................... 10 2.1.4 Play Transition Methods for STP ....................... 10 2.1.5 Alternatives to STP .............................. 11 2.2 Team Simulators, Communications and Base Station .................. 11 2.2.1 Tech United Eindhoven ............................ 11 2.2.2 Water .................................... 14 2.2.3 CAMBADA .................................. 16 3 Theoretical Foundations 18 3.1 Robotics Simulators .................................. 18 3.2 Sockets ........................................ 20 3.3 Log Probability .................................... 21 3.3.1 Speed .................................... 22 3.3.2 Accuracy ................................... 22 3.4 Normal Distribution Curve and Bayesian Curve ..................... 22 3.5 Heat Maps ...................................... 23 vi
48 Futsal formations: (a) All or Nothing; (b) Square; (c) ’Y’ formation ............ 63 49 Diamond formation offensive and defensive situations ................. 64 50 Hungarian algorithm zone assignment example .................... 65 51 Representation of a base map based on the distance to the robot: (a) 2D base station representation; (b) 3D representation ......................... 66 52 Representation of base maps: (a) Forward field; (b) Centre field ............ 67 53 Ideal pass distance base map: (a) Field representation; (b) 3D pass probability representation ....................................... 67 54 Ideal goal distance base map: (a) Field representation; (b) 3D goal probability representation ......................................... 68 55 Opponents influence: (a) Field situation; (b) Individual matrix 3D graphical representation 69 56 Teammates influence: (a) Field situation; (b) Individual matrix 3D graphical representation 70 57 Representation of a base map based on the distance to the robot: (a) 2D representation; (b) 3D base station representation ........................... 71 58 3-meter radius rule map: (a) Field situation representation; (b) 3D matrix representation 71 59 Matrix size adjustment for non-entire field maps .................... 72 60 3D robot positioning map: (a) 2D representation; (b) 3D representation ......... 74 61 3D points of view: (a) Goal view; (b) Side line view; (c) Top view ............. 74 62 Position selection based on multiple possible areas .................. 75 63 Game + RefBox tab .................................. 79 64 Strategy calibration tab ................................ 80 65 Heat maps tab with calibration trackbars and player decision tree ........... 81 66 Skill tab with PID calibration trackbars, skill buttons and player decision tree . . . . . . 82 67 Vision tab ....................................... 83 68 Every robot ball representation and weighted average ................. 84 69 Robot information panel ................................ 85 70 Base station skill representation: (a) Stop; (b) Move; (c) Attack; (d) Kick; (e) Receive; (f) Cover; (g) Defend; (h) Control ............................. 86 71 Packet rate of received messages by the base station in RoboCup 2023 games ..... 89 72 Offensive probability map ............................... 90 73 Defensive probability map ............................... 91 xiii
74 First game situation in the simulator .......................... 92 75 Second game situation in the simulator: (a) Initial situation; (b) Situation after the first pass ......................................... 93 76 Third game situation in the simulator ......................... 94 77 Fourth game situation in the simulator ......................... 95 78 Game strategy against humans in the simulator .................... 96 79 Laptop computer protection cage: (a) Steel frame; (b) Protective sponge ........110 80 Robot sportswear: (a) Front view; (b) Side view; (c) Back view ..............110 81 Battery soldering process: (a) Spot welding; (b) Magnesium strips ...........111 82 Battery elements: (a) Battery Management Systems (BMS) connector; (b) Protective heat shrink tube ......................................112 83 Battery 3D printed parts: (a) Case with robot number; (b) Monitoring screen; (c) Sliding rails .........................................112 xiv
List of Tables 1 Table of robots and base station IP........................... 38 2 Game information sent by the robots ......................... 40 3 Diagnostics information ................................ 41 4 Table of skills and respective arguments ........................ 51 5 Description of variables ................................ 55 6 Table of variables in the game decision tree ...................... 61 7 Table of variables in the player decision tree ...................... 62 8 Base station keyboard shortcuts ............................ 87 xv
List of Equations 3.1 Log probability ....................................... 21 3.2 Probability space conversion into logarithmic space ..................... 21 3.3 Addition in logarithmic space ................................ 22 3.4 Floating point in logarithmic space ............................. 22 3.5 Normal distribution curve ................................. 23 3.6 Graph nodes and connection notation ........................... 25 3.7 Complete graph notation .................................. 25 3.8 A* total cost ........................................ 26 7.1 Distance between two robots ................................ 55 7.2 Action probability ..................................... 55 7.3 Action probability with opponents influence ......................... 56 7.4 Log probability conversion ................................. 57 7.5 Number of connections in probability graph ......................... 58 7.6 Distance between robot and a matrix point ......................... 66 7.7 αcalculation for matrix points ............................... 66 7.8 Goal probability based on robot position .......................... 68 7.9 Opponent circle influence points .............................. 69 7.10 Opponent cone influence .................................. 70 7.11 Influence heat maps probability fusion ........................... 73 7.12 Rule heat maps probability fusion ............................. 73 8.1 Position map conversion to colours ............................. 86 xvi
Acronyms API Application Programming Interface BMS Battery Management Systems CPU Central Processing Unit FIFA Federation Internationale de Football Association GPU Graphics Processing Unit gRPC Google Remote Procedure Calls GTK+ GIMP ToolKit GUI Graphical User Interface I2C Inter-Integrated Circuit IEEE Institute of Electrical and Electronics Engineers IP Internet Protocol JSON JavaScript Object Notation LAR Laboratory of Automation and Robotics LiDAR Light Detection and Ranging MSL Middle Size League ODE Open Dynamics Engine xvii
OSI Open Systems Interconnection PBS Probability-Based Strategy PCB Printed Circuit Board PIC Peripheral Interface Controller PID Proportional – Integral – Derivative PLA Polylactic Acid RAM Random-Access Memory RGB Red-Green-Blue RGBD Red-Green-Blue-Depth ROS Robot Operating System RTDB Real-Time DataBase SDL Simple DirectMedia Layer STP Skills, Tactics and Plays TCP Transmission Control Protocol TOF Time Of Flight UDP User Datagram Protocol xviii
Chapter 1 Introduction Robotics is one of the fastest growing areas, and it is the field of computer science and engineering that handles the design, assembly and management of robots. Robots have multiple designs that vary based on the task they are made to do. Robots can be classified in multiple ways based on their shape, size, function, environment, degree of automation and mobility. This dissertation focuses on fully autonomous mobile robots with the objective of playing football. These robots are not industrial, for service, medical use, or even military applications, but are the key to getting people interested in robotics and investing in its research and development. Various scientific contributions and even technology standards, like the EtherCat, were developed because of the need for that technology in football robots. 1.1 Problem Description RoboCup started in 1997, and leagues have become more competitive over the years based on the motivation of all teams to research and develop robots. The Middle Size League (MSL) is no exception [1]. MSL is one of the main leagues and has a large amount of areas present. Mechanics, Electronics, Programming, Control Systems, Multi-Agent cooperation, Communication, Artificial Intelligence, Computer Vision, Strategy, Decision-Making, Human Interaction and much more are the foundation of MSL. One of the RoboCup goals is to play against the world champion human football team with the best MSL team in 2050 [2]. Teams with five fully autonomous robots play against each other in every MSL game, and teams are free to design their hardware and software while complying with the league rules [3]. Figure 1 shows two MSL showcases, the final game from RoboCup 2013 in Eindhoven (a) and a demonstration from the team Tech United (b). 1
(a) (b) Figure 1: MSL showcases: (a) Final in RoboCup 2013 [1]; (b) Tech United’s demonstration The University of Minho and the Laboratory of Automation and Robotics (LAR) first participated in MSL in 1999 with the name ”MinhoTeam”. MinhoTeam participated in multiple leagues and already won multiple awards. There were already various MinhoTeam generations [4,5,6] in the last 25 years, and one of the objectives of this dissertation, together with other team members, is to restart MinhoTeam, now with the name LAR@MSL [7]. Many existing solutions for coordinating multi-robot football teams have some limitations. A common decentralised approach can lead to synchronisation issues between robots, which are not ideal in real-time problems. Solutions relying heavily on predefined playbooks restrict the flexibility and adaptability of the robot team. Playbooks require a lot of manual setup time and make it difficult to easily parameterise behaviours or add modularity. These solutions depend on having carefully crafted plays that cover every scenario the robots may encounter. However, it is difficult to account for all possible situations with predefined plays. Overall, the dependency on decentralisation, playbooks, and predefined plays and tactics limits the coordination ability of teams. These approaches lack the flexibility, synchrony, and adaptability required for robust multi-robot coordination in a complex and dynamic environment such as a robot football game. There is a need for a solution that provides centralised supervision, while still allowing decentralised execution, maintaining the robot’s autonomy. Modular and parameterised behaviours would increase adaptability. An approach combining these strengths and solving the common strategy problems would very much benefit a team. 2
1.2 Motivation The robotics trend is to work as teams of robots or multi-agent cooperative systems to complete more complex tasks, with full control in real-time and efficient interfaces. To achieve cooperation and collaboration amongst robots a good communication system is vital. A good task-planning platform is essential to prepare robots for those complex tasks, making simulators one of the best methods. To organise and manage/control such complex systems, it is necessary to have an integrated and centralised software platform. This platform must allow a very simple yet comprehensive interface, be a good debugging tool and have the capability to log and represent real-time data. The RoboCup MSL is a good test bed and benchmark to prepare for that challenge, as it incorporates all the issues above described. An MSL team has five robots that have to cooperate, maintain synchronism in a real-time application, require a good and efficient communication system, and depend on a central management control software with a comprehensive interface capable of representing real-time data. All the described challenges are the main reasons for this dissertation’s motivation. Motivation is also based on the will to be part of the research community [8], especially to contribute scientifically to this major league with new and creative solutions. This research community has already developed new products, created large robotics companies, and sponsored big events, among others. On top of that, the teams that participate every year in MSL and RoboCup are a big inspiration and have a lot of achievements and creations in the area of Robotics. Interacting with those teams allows the team to communicate and exchange ideas with people from world-renowned universities like the Eindhoven University of Technology and Carnegie Mellon, as well as some companies like Philips, VDL and even ASML, adding personal overall knowledge in robotics. 3
1.3 Objectives This dissertation goals reside on the following significant topics: • Creation of a centralised game strategy architecture capable of maintaining real-time synchronism between all robots; • Make the game strategy parameterisable, modular and flexible for easy adaptability between game and opponent teams; • Eliminate the need for a playbook, a predefined list of plays and tactics, in order to keep the play solutions dynamic and reduce the development time; • Development of a reliable and efficient communication system capable of performing under highly saturated environments; • Development of a simulation environment in order to accelerate the strategy development time and capable of maintaining an easy transition between the simulation and the real-world scenarios, in order to have a hardware-independent system; • Creation of a debugging tool capable of receiving referee instructions and representing game data in real-time; • Actively participate in robotic football competitions in order to test and acquire data for further analysis, such as ”Festival Nacional de Robótica” and RoboCup; • Results demonstration, description and analysis, and comparison to the current game strategy solutions. Strategy, Communication and Simulator are the focus of this dissertation. Because the team has five robots and the information gathered is restricted by each robot’s sensors, communication is critical for the robots to cooperate. Besides the three main parts of this dissertation, strategy, communications and simulation, the robot’s hardware and base station are presented as context and are necessary to the team and to the dissertation objectives. The creation of a game strategy method, centralised and synchronous, based entirely on probabilities that generate the plays in real-time, eliminating the need for a playbook can solve the current game strategy problems. Adjusting the probability formulae used can change completely a team’s intention and behaviour 4
2.1.5 Alternatives to STP The MuJoCo team implemented an approach that diverges from the STP architecture, opting instead for a solution entirely based on reinforcement learning [22,23], applied within a simulation environment. The downside of having a full reinforcement learning implementation is the lack of modularity and parameterization, which are important when playing against different teams in a short period. When a new opposing team employs different behaviours, Reinforcement Learning algorithms can lack flexibility and speed when adopted. Implementing changes often requires more time and computational resources compared to hand-coded strategies. Classic strategies can allow behaviour changes on the fly during a match (during the break) or in between matches. Some simulation league teams use genetic algorithms [24], which do not rely on the STP architecture. However, these have other limitations, such as modularity constraints and training requirements. 2.2 Team Simulators, Communications and Base Station There are many teams in MSL, but this section focuses only on three of them. The choice of these three teams is based on a few key points. The first one, Tech United Eindhoven, is the world champion and one of many teams that has everything open-source. They think and invest in new teams for the league. Water is another strong team with innovative ideas. Their approach to the problems very rarely uses a common solution, so their different ideas were one of the reasons this team was considered in this study. The third and final team is CAMBADA, a Portuguese team from Aveiro, and they were already World Champions in 2008. Other Portuguese teams participated over the years, for example, 5DPO [25], ISePorto and ISocRob. 2.2.1 Tech United Eindhoven Tech United Eindhoven is a team from the Netherlands representing the Eindhoven University of Technology from the city of Eindhoven. This team started in 2005 and first participated in a competition in 2006. They achieved the world champion title several times in 2012, 2014, 2016, 2018, 2019, 2022 and 2023 [26]. They call their Robots ”turtles”, but each has a specific name from famous football players or tech jokes. It is important to highlight their fair play as their achievements, research, software and hardware are open-sourced [27]. Figure 3shows the Tech United robots or, as they call them, ”turtles” [28]. 11
Figure 3: Tech United team robots [14] Simulator Nowadays, the Tech United team does not use a simulator very often. The free access to a field and fully functional robots allow them to test without the need to simulate. However, they still use it to replay virtually previous games from official competitions, as all the data is logged [15]. Their simulator was developed using MATLAB. Figure 4shows the Tech United simulator showing the computation of the desired position for each robot. Figure 4: Tech United simulator environment 12
Communications For communication, the team uses the same method as most other teams. It is called Real-Time DataBase (RTDB) and was first developed in 2004 by a Portuguese team called CAMBADA [29]. Its development solved the synchronization and data-sharing issues common on all teams of the league. Since then, because of the open-source spirit, other teams have used and helped improve it over the years. It was originally written in C++, but now, a Python 3 version is also available. Their communication system uses an UDP multicast communication between the robots and the base station Computer. Base Station The base station is the main computer that links the robots from each team to the Referee Box. Tech United’s base station is called ”Turtle Remote Control” and was also developed in MATLAB. They had a previous version developed in C with Glade and the GIMP ToolKit (GTK+) frameworks, but they rebuilt it in MATLAB. This software is used during games, demos and even to test different strategies and configurations. It handles the communication, the live representation of the game state and even the Referee Box (RefBox) commands. It represents all the information from the ”turtles”, in real-time, such as battery charge, Central Processing Unit (CPU) usage, role in the game, vision system and even communication loss rate. Tech United base station screen is shown in Figure 5. Figure 5: Tech United base station with 3D representation 13
2.2.2 Water Water is a Chinese team from the University of Technology in Beijing and has participated in national competitions since 2006 [30] and in RoboCup since 2010. They were World Champions five times in 2010, 2011, 2013, 2015 and 2017. The robots of the team Water are shown in Figure 6. Figure 6: Water team robots Simulator In contrast to most of the other MSL teams, team Water does not use any simulator. They use real robots to develop everything. The advantage is that there are no problems transitioning from the simulation to the real world. The disadvantage is that they cannot work offline and always need a field and functioning robots. MSL robots are manually developed, requiring considerable maintenance, making it difficult to have the full team working all the time. Communications Just like the simulator and the choice of the operating system, their communication system is also innovative. They are the only team using the Transmission Control Protocol (TCP) protocol [30]. They establish a client/server approach, being the Water Coach (base station) as the server and each robot as a client. Figure 7represents the communications scheme the team Water uses. 14
Figure 7: Team Water communication schematic [30] Base Station Their base station is called ”Water Coach” (Figure 8) and it was developed using Microsoft Visual Studio and written in C++. Water is one of the very few teams that use Windows on their robots. Most other teams use Linux with Ubuntu distributions. Just like Tech United, their base station serves the purpose of communicating with the robots and handling the Refbox events. Figure 8: ”Water Coach” - Water base station 15
2.2.3 CAMBADA CAMBADA is an acronym that stands for Cooperative Autonomous Mobile roBots with Advanced Distributed Architecture and it is a MSL Team from the University of Aveiro in Portugal. The team was created in 2003 and won the RoboCup in 2008. They are the Portuguese Champions since 2007 [31]. Unfortunately, due to the pandemic situation, the team has ended its activity. However, they were very active and helped to develop this league in many areas. CAMBADA team and their robots are shown in Figure 9. Just like Team Water, CAMBADA does not use a simulator, as it has free access to a full-size MSL field. Figure 9: CAMBADA team Communications For communications, team CAMBADA started to develop the solution most used in MSL called RTDB in 2004 [29]. They communicate using the same protocol as Tech United, the UDP multicast, and then use RTDB to manage, clean, fuse and synchronise all the data in real-time. With RTDB they have the same real-world model between all robots without surpassing the bandwidth limits imposed by the RoboCup rules [3]. RTDB’s major advantage is the synchronised data between robots with the shortest communication time for real-time applications [29]. Although other solutions have been used in RoboCup, this method enforces a correct timeline, meaning that refreshing information items and the temporal accuracy of the data stored in the RTDB has higher feasibility. Figure 10 shows the RTDB architecture and its shared memory. 16
Figure 10: Architecture of the RTDB being accessed by local processes [32] Base Station CAMBADA base station, Figure 11, is used to control and monitor their robots. It was developed in C++ language using the Qt framework. Even though Qt runs on multiple operating systems, this team uses it under Linux. They can set roles and game states and monitor most of the robot information, such as the battery charge, behaviour, and even RTDB debug flags. Figure 11: CAMBADA base station 17
Chapter 3 Theoretical Foundations As previously described, the core of this dissertation focuses on probabilities applied to robotics football strategy. As such, a theoretical foundation is presented to discuss the necessary topics from the following chapters. The topics presented are: • Robotics Simulators; • Sockets; • Log Probability; • Normal Distribution Curve and Bayesian Curve; • Heat Maps; • Decision Trees; • Graph; • A* Path Finding Algorithm; • Hungarian Algorithm. 3.1 Robotics Simulators Most teams in the MSL league choose to develop their simulator, but many generic robotics simulators can be used. A robotics simulator is a software capable of creating simulation environments to study, research, and develop platforms without using hardware [5]. On the other hand, there is a disadvantage to using simulators, as the transition from the simulated environment to the real-world is not easy and it 18
requires some adaptation of code to be able to behave similarly. Some simulator software was considered, but the software used in this dissertation was Webots. Webots is a 3D graphical robotics simulator developed by Cyberbotics, a Swiss enterprise that started in 1996. It was a paid license and relatively expensive for many years, requiring a physical USB key to run. In 2019, it became open-source. However, it still has paid licenses for professional use, giving access to 24/7 support and consultancy. It uses the same physics engine as Gazebo, Open Dynamics Engine (ODE) but runs on Linux, Mac and Windows. An example of a simulation environment developed in Webots with an Aibo robot is shown in Figure 12. Figure 12: Example of simulation in Webots Webots is ideal for digital twins, and besides an API, the communications between any code and the simulation can be based on TCP. Robot controllers can be written in C/C++, Python, Java and MATLAB, but they also support ROS. It allows external controllers to actuate and get information from the simulation in any language as long as the TCP/IP protocol is used to communicate between the internal and external controllers. It also offers a Web Interface that easily shares, runs and interacts with simulations from the cloud. The simulation runs on the computer or the cloud, shown in the web interface. Users can fully control the environment from this web interface and even program the robots directly. 19
The main fields of applications are: • Fast Prototyping; • Wheeled and Legged locomotion; • Suitable for Air, Water and Land Robots; • Multi-Robot Simulations; • AI and genetic algorithms; • Computer vision. When selecting a simulator various factors must be considered such as performance, community, documentation, and stability. Performance-wise, Webots was one of the best options due to the low usage of CPU,GPU, memory and disk when compared to the most common alternatives [33,34]. Since it became free and open source, Webots has grown and has been very active. Gazebo is widely used but most of the options available regarding communication were based on ROS, something that the team had no intent of using. CoppeliaSim has very poor performance compared to Gazebo and Webots, especially when the simulation environment is a multi-robot system, which is the case [33,34]. 3.2 Sockets Sockets are a method of communication either on the same device or over a network. They link two processes through a connection defined by an Internet Protocol (IP) address and the port numbers on each side. They can communicate both ways and be either Transmission Control Protocol (TCP) or User Datagram Protocol (UDP). They work on the transport layer of the Open Systems Interconnection (OSI) model [35]. Figure 13 shows an example of a socket between two machines. 20
3.9 Hungarian Algorithm The Hungarian algorithm is an efficient technique for solving assignment problems. An assignment problem has the same number of elements and tasks; each element must be assigned to one task. Each element task assignment has a cost associated with it, and this method solves the problem through matrix manipulation, yielding the overall lowest cost possible. The Hungarian algorithm uses a matrix where each row represents a task, each column an element, and each cell the cost of that element-task [43]. A series of steps for manipulating the matrix is carried out until there are enough zeros in the matrix. It is required to have lines passing through the zeros where the number of lines is the same or bigger than the number of tasks or elements. When this happens, a choice of zeros from different lines is a solution with the lowest cost overall. An example is shown in Figure 19. 40 60 15 25 30 45 55 30 25 (-15) (-25) (-25) Task 1 Task 2 Task 3 1 23 25 45 0 0 5 20 30 5 0 (-0) (-5) (-0) 25 40 0 0 0 20 30 0 0 40 60 15 25 30 45 55 30 25 Figure 19: Hungarian algorithm example The first step is to subtract the minimum value of each row from all values of the row. Next, the same must be done to the columns with the minimum value of each column. Lastly, if the number of zeros is equal to or greater than the number of rows, a combination of non-crossing zeros is the position of the solution. In this example, the solution was: • Element 1 -> Task 3; • Element 2 -> Task 1; • Element 3 -> Task 2. The overall cost of the solution presented is 70, which is the sum of the cost of each assignment, 15 from task three, 25 from task one and 30 from task 2. 27
Chapter 4 Robot’s Hardware The robot’s hardware and mechanical description are presented to help better understand the development environment for the strategy. The hardware development occurred parallel to the strategy development and was crucial to achieving some dissertation objectives. All real-world results were acquired with these robots. 4.1 Architecture Every robot is divided into different modules, each responsible for a specific task. The modules have the necessary sensors and actuators, but some sensors are also necessary in multiple parts of the robot. For example, the compass is present in the ESP32 module but influences both the control systems and the localisation system. Figure 20 shows a robot schematic with all its modules, how it interacts with the base station, and the protocols used between each model. Robot Referee Table Ethernet I2C_2 Serial Display CMPS14 ESP32 ESP32 SparkFun Thing Main Computer I2C_2 2x TOF I2C_2 Router Base Station Computer Wifi PWM H Bridge 2x DC Motors USB 3x DC Maxon Motors Board PWM Kinect OmniDirectional Vision System Ethernet Coil Dribbler Kicker Omnidirectional Locomotion Referee Box Computer Opponent's Base Station Ethernet Ethernet Movement PWM I2C_1 OMNI 3MD Max Sensors Actuators Microcontrollers Drivers Computers Legend: 3x Encoders Figure 20: Robot’s hardware diagram 28
4.1.1 Robot’s Diagram The LAR@MSL team has five robots: four strikers and a goalkeeper. All the strikers have the same hardware configuration and software, but the solution for the goalkeeper to optimise its objectives is slightly different. The differences between the strikers and the goalkeeper are the position of the Kinect Depth Camera [44], the upwards-extending arm, and the addition of a Light Detection and Ranging (LiDAR) sensor at the back of the goalkeeper. Figure 21 depicts a striker robot and its components. CMPS14 Compass LCD Display OmniDirectional Vision System Front-Facing Kinect Depth Camera Kick Mechanism Dribbler Motors Kick Board ESP32 Microcontroller Omnidirectional Locomotion Board Three Omni Wheels Power Distribution Unit Robot Computer Dribbler Time-Of-Flight Figure 21: Robot’s photo with the main elements highlighted (front and back views) 4.1.2 Chassis Sometimes collisions can happen during a game, requiring a very robust structure, so most parts are made of iron or aluminium. Figure 22 shows the robot chassis and the aluminium boards that make up the layers of the robot. According to the size limits defined in the RoboCup MSL rule book [3], the robots cope with the dimensions (52 cm x 52 cm x 80 cm). The robot weighs 36 Kg, 4 Kg below the MSL rule book defined limit [3]. Even though a higher weight requires more energy consumption, having a lighter robot is worse when it comes to collisions and respective inertia. Besides all the metals around the robot, there is a protective cushioned fender. This is important so no sensible hardware is exposed. Should they collide with something or some other robot, the impact is absorbed. When playing with or against humans, it is also mandatory that the robots wear thicker skirts to protect the humans in case of shock. 29
(a) (b) (c) Figure 22: Robot chassis photo: (a) and (b) Side view; (c) Aluminium plate 4.1.3 3D Printed Parts As some custom-manufactured parts needed to have higher precision and due to the team’s reduced budget, some parts were 3D printed either in Polylactic Acid (PLA) or Resin. Most of the 3D printed parts were boxes or fixtures, and Figure 23 shows some of them. Another example of 3D printed parts were some rollers for the omnidirectional wheels, but those were printed in resin due to the weight and impact. (a) (b) (c) Figure 23: 3D printed parts and respective CAD1drawing: (a) Omni-vision camera support; (b) Ball caster wheel support; (c) Power box 1CAD (computer-aided design) software is used by engineers and designers to create 2D and 3D models of physical objects and systems. 30
4.2 Energy and Power Distribution Regarding energy, the robot uses 24 V lithium-ion batteries with 6600 mAh. These were handmade by the team due to budget reasons. The construction is described in more detail in section Batteries in Appendix A - Extra Work. The batteries have a 3D-printed case and rail so that they are easy to connect, and the rail prevents them from being plugged backwards. Not all modules work at the same voltage, and hence the converters and switches are available in the Power Box. Figure 24 shows the batteries and Power Box. The robot has a remotely operated emergency stop mechanism, which consists of a twochannel wireless-operated relay on a low radio frequency of 433 MHz with a remote control. This relay does not cut power to the whole robot but turns off the Omni-3MD Max, the motor driver board Peripheral Interface Controller (PIC) so that the motors stop. (a) (b) (c) Figure 24: Energy management: (a) Lithium-ion 24 V battery; (b) Battery connection rail; (c) Power box 4.3 Low-Level Control and Sensors The robot has an ESP32 Sparkfun Thing as the main microcontroller to manage communications among all hardware. It communicates with the main computer through a serial port, and most of the sensors use the Inter-Integrated Circuit (I2C) protocol. The ESP32 has two I2C channels being used for the board responsible for the robot movement, and all the other I2C devices are on the other channel. For safety purposes, the robot must stop as quickly as possible. A saturated I2C channel could pose an issue in achieving this objective. The devices on the second I2C channel (the compass, the Time Of Flight (TOF) sensors, and the display) are not a priority and, therefore, can be in a second channel. Figure 25 shows the Printed Circuit Board (PCB), the ESP32, the compass and the screen. 31
(a) (b) (c) Figure 25: Low-level microcontroller components: (a) ESP32 and PCB; (b) ESP32 board box mounted on the robot and protection; (c) CMP14 compass and screen 4.4 Locomotion Speed and agility are extremely important in football robots, and for that reason, a fast and efficient method of locomotion is important. The robots have three omnidirectional wheels at 120º of each other, allowing the robots to move in any direction at any moment while simultaneously rotating. 4.4.1 Omni-3MD Max The motor driver board is the Omni-3MD Max, a board developed by Bot’nRoll, which is responsible for controlling the three motors based on the values given. The board receives a linear velocity, a direction and an angular velocity and calculates the kinematics necessary to reproduce that movement. It also handles the motor Proportional – Integral – Derivative (PID) control to have an accurate velocity, and even controls the acceleration curves to avoid drifting and wheel spin. Figure 26 shows the Omni-3MD Max board (a) as well as the motors attached to the chassis (b). (a) (b) (c) (d) Figure 26: Locomotion system: (a) Omni-3MD Max; (b) Motors and wheel; (c) Maxon motor; (d) Encoder 32
The motors are Maxon 148867 DC 24 V and have a maximum power output of 150 W each (Figure 26 (c)). Each motor has an encoder with the reference HEDS-5540, as shown in Figure 26 (d) and its output goes into the Omni-3MD Max for the control systems. 4.5 Ball Handling Mechanism One of the robot’s requirements was to be able to catch and control the ball. To solve that problem, each robot has a dribbling system able to receive and control the ball with two motors and two TOF sensors. The motors can move the ball in any direction, and they are controlled based on the two TOF distance sensors that are mounted facing the ball. The wheels were custom-made so that the ball’s grip was maximised to pull the ball to the centre of the robot. Figure 27 shows the dribbling system as well as the TOF sensors and how they are mounted. (a) (b) Figure 27: Ball handling mechanism: (a) Top view; (b) Front view with the ball caster wheels 4.6 Kicking Mechanism Another ability required by the robot is to kick the ball and for that, the robot has a kicking system. It is composed of two parts: the mechanical and the electronic parts. A coil and an iron flap are responsible for hitting the ball in the mechanical part. The electronics part is a board that charges capacitors to 450 V and controls the energy flow. When the kicking trigger is on, it sends the capacitor’s charge into the coil that magnetically moves the iron flap and hits the ball. Work is being carried out to make the robot able to kick upwards in a projectile trajectory, and the importance of that is based on how difficult it is to defend an arc ball instead of a rolling ball. The kicking mechanism and board are visible in Figure 28. 33
(a) (b) (c) Figure 28: Kicking mechanism: (a) Mounted on the robot; (b) Iron flap; (c) Kick board 4.7 High-Level Computation and Main Computer Each robot has a laptop responsible for managing, calculating and controlling all high-level systems. It gets information from all the cameras and sensors, handles communications with the base station, runs all logic and control algorithms, makes decisions and even logs data. This central computer has a Ryzen 5 CPU with 8 GB of Random-Access Memory (RAM) and an NVIDIA GTX 3060 Graphics Processing Unit (GPU). The significance of the graphics card lies in its ability to execute all the neural networks used in the detection algorithms. Regarding the operating system, it uses Linux, more specifically, the Ubuntu 22 distribution. Most of the code running on the robot computer was written in Go (a compiled language) [7]. 4.8 Vision System One of the most important robot input systems is the vision system, which consists of 2 cameras. The main camera, the catadioptric omni-vision camera, has a full 360-degree field of view. The second camera, a Kinect from the ”Xbox 360”, is a front-facing depth camera [7]. 4.8.1 Catadioptric Vision System The catadioptric vision system applied to the robots is an upright camera facing a conic/hyperbolic mirror, and its designation is the omni-vision camera [45]. The camera used is a Blackfly PGE 13S2C network camera that communicates through an ethernet cable using sockets. On top of the camera, there is a curved mirror centred with the camera lens, making it able to see all around the robot. The angle of a specific object detected by the camera is given by the angle of that 34
object to the centre of the mirror, and the distance is calculated based on the distance to the centre of the image. Figure 29 (a) shows the camera and the mirror, and Figure 29 (b) shows an image taken from the camera in a game situation. (a) (b) Figure 29: Omni vision camera system: (a) Camera mount and mirror; (b) Image from camera 4.8.2 Kinect Depth Camera The second camera on the robot is a front-facing depth camera, a Kinect from the ”Xbox 360”. It is an infrared camera that is able to capture Red-Green-Blue-Depth (RGBD) images at 30 frames per second. This front-facing camera is used for most of the ball actions such as kicking, receiving, and attacking the ball. The need for the second camera is due to having more accurate detection systems and, consequently, better control systems. The downside of the Kinect camera is its low field of view, so when the Kinect is not able to see the ball, the information used is only from the omni-vision camera. Figure 30 shows the Kinect camera and how it is mounted on the robot. (a) (b) Figure 30: Front-facing depth camera Kinect: (a) Camera mount; (b) Image from camera depth and colour 35
Chapter 5 Communication System The communication system is an indispensable part of a centralised strategy and robot synchronism. It enables the robots to communicate via a Wi-Fi network and all the communication limitations and restrictions were coped with, based on the MSL rule book [3]. 5.1 Communication’s System Description The robots use UDP sockets to communicate with the base station which is the team’s central computer. The communication system is the same in the simulator and the physical robots to help transition between the simulator and the real-world robots. Robots can communicate with each other if all packets go through the game’s access point, but the LAR@MSL team does not use that feature. Also, in the same network is the RefBox computer, which is responsible for translating the referee instructions to the team’s base stations and, consequently, the team’s robots [9]. The communications diagram is shown in Figure 31. Base Station Blue Base Station Red 2 3 2 3 RefBox Access Point A Access Point B Switch Figure 31: Communication system diagram 36
6.2 Components, Field and Organisation The simulated environment was created with the focus of accelerating the game strategy development, so the environment was kept as simple as possible (Figure 34). Since there was no need to have the omniwheel physics, the dribbling system and other moving parts were developed with simpler solutions so that the simulator would have better performance. Figure 34: Webots field, simulation elements and robots The simulated environment has ten robots, two goals, a ball, and other extra components to help better optimise and manage the simulation. Besides the robots and the ball, no other objects move, as they still need to be able to be interpreted by the physics engine collision system. The elements that still detect collisions and have no movement are called static objects. 6.2.1 Static Simulation Objects The goals, the field floor and the walls are solid-state static elements present in the simulation. The only physics calculations carried out with these elements are the collision system. These elements do not move but still behave accordingly when an object collides with it. The ball is neither a robot node nor a static object, but it has gravity applied to it and also has an associated weight and elasticity so that the ball’s behaviour is similar to the real world. The robot and ball use controllable magnets to simulate the dribbling system. The ball has a passive magnet, while the robots can activate or deactivate their magnet to catch and release the ball respectively as they would in the real world with the dribbler mechanism [46]. 43
6.2.2 Single Robot In the simulation, each robot is an extruded hexagonal shape and has a magnetic actuator in the front, as shown in Figure 35 (a). The robot does not have wheels because dedicating computational power with omni wheels, PID control systems or kinematics would be inefficient. Instead, the robot’s movement is controlled by applying a movement vector to the robot itself with the supervisor API, with the arguments: linear velocity, direction, and angular velocity, similar to the real world. The dribbling mechanism uses magnetic actuators to either grab or release the ball. When the ball is close to the robot’s front, the magnetic actuator is activated, and the ball remains attached to the robot until it kicks or releases the ball by deactivating the magnet. The kicking mechanism is implemented by code and not a simulated actuator. When the robot kicks, it applies force to the ball, pushing it away. The kick force also varies based on one of the kicking parameters. The robot’s nodes hierarchy is shown in Figure 35 (b). (a) Robot Controller or Supervisor Physics boundingObject Transform Children Translation Rotation Scale Magnetic Connector BodyScript Path -> Body -> Body Solid: Cylinder (b) Figure 35: Simulation robot element: (a) Body and texture; (b) Node hierarchy 6.2.3 Opponents The opponent robots in the simulator are shaped like extruded hexagons with a red colour and can be moved manually. They are identical to the team robots in every aspect and can be controlled by the control skill through the base station. They also have a magnetic actuator and can kick just like the team robots. This allows the testing of strategies in multiple ways such as static plays, both teams playing with the same strategy and the strategy against humans. In this last case, the game can be played with five human players controlling the opponents using game controllers. Each human player controls one opponent, playing against the developed strategy to ease the game strategy calibration. This situation is visible in the Tests and Results chapter, section 9.5 Against Humans. 44
6.3 Architecture, Controllers and Supervisors Webots can have multiple codes running simultaneously, and there are two types of scripts, the controllers and the supervisors. Controllers and supervisors are processes, explained in section 6.3.3 Controller vs Supervisor with the purpose of gathering information, actuating in the simulation environment, and can even do both. They are either asynchronous or synchronous with the simulation time step. Every interaction between a controller or a supervisor with the simulation environment is carried out through the Webots API. These functions can be time-consuming and so reducing the number of requests is a requirement to optimise it. 6.3.1 Architecture All supervisors and controllers in the simulation run in parallel, so communication between them is a requirement. In this case, even though Webots have communication tools developed to link two or more controllers, sockets were the solution opted for in order to use the same method of communication as in the real world. Another reason for this choice was the reusability of code should the simulation software ever change, or even in the event of over-the-internet simulations. Figure 36 shows the simulation architecture, where the yellow arrows are the sockets used to send information from the base station to a robot, either from the own team or a simulation opponent. The blue arrows are the sockets used by the robots to send information to the base station or the display controller. The purple arrows are the sockets from where the main supervisor sends world information to the robots. The dashed red arrows are API functions either to send commands or receive information. The exact port numbers used by the team robots with either the base station, main supervisor or display controller are available in Communication System in section 5.2.2 Port Organisation. 45
Base Station Main Supervisor Robot 4Robot 3 Robot 1 Robot 2 Robot 5 Display Controller Robot 2 Robot 3 Robot 4 Webots API World StatePhysics Engine Opponent 1 Opponent 5 Opponent 2 Opponent 3 Opponent 4 Webots Framework Webots Simulation Environemt Figure 36: Webots simulation architecture 6.3.2 Nodes and Webots API Nodes within Webots are the fundamental building blocks of the simulation environment. They represent entities such as robots, objects, sensors, actuators, lights, or any other element present. A simulated environment is organised in a hierarchical structure, where each node has specific attributes and functionalities. The organisation follows a parent-child relationship, where nodes can have parent nodes and children nodes. For instance, a robot node may have children nodes representing its sensors, actuators, or even subparts of the robot itself. These nodes are manipulated and interact with the available Webots API. The API enables precise control of the simulation and allows code to create, modify, and interact with every node in the simulation. To use the API which is available in multiple programming languages, the node robot can have code that is either a controller or a supervisor. All controllers and supervisors require a parent robot node to interact and run in the simulation [46]. 46
6.3.3 Controller vs Supervisor In Webots, a controller and a supervisor are both used and they serve different purposes within the same simulation environment. A controller is a program with the focus of controlling a specific robot or a group of robots within the simulation. The controller only has access to children nodes inside its own, and it interacts with movements, sensor readings, and decision-making processes of the robot(s). Supervisors, on the other hand, are higher-level controllers with a focus on managing the overall simulation environment rather than controlling individual robots or nodes. Supervisors can control the entire simulation, including the setup, initialisation, coordination of multiple robots, global environment settings, and interaction with external nodes. Supervisors are usually implemented using the Webots controller API, allowing them to access and manipulate the simulation environment. They are distinct from the controllers responsible for the robots’ actions. 6.3.4 Main Supervisor A main supervisor was created to reduce the number of API requests as well as synchronise the information between all robots. All the robots need to detect objects on the field. Instead of each robot requesting the location of ten robots and the ball, the main supervisor gets information about everything and gives that information to all robots. This method is less CPU intensive as well as faster and synchronous. The information is sent through a socket which is the same method for all the other inter-controller communications. This method reduces the number of API requests from 110 to 11 per simulation iteration, which is an improvement of ten times. 6.3.5 Display To simplify the debugging process, visual representations are used both on the base station and in the simulator. A display was used as a replacement for the field floor within the simulation environment. This floor serves as a display, synchronised with a controller, facilitating a visual representation of the robot’s active skills. The display has a resolution of 240×160 pixels where each pixel corresponds to a 10 cm distance in the real world. The purpose of this display primarily revolves around showcasing the active skills of the robots, including ball interactions, movements, and other skills. To effectively manage the field floor, a centralised controller has been developed. Each robot supervisor can make requests to the display controller to draw onto the field floor. Upon receiving these commands from multiple robots, the display interprets and executes the requested actions, resulting in the visualisation of the intended representations. 47
The display node on Webots has multiple API functions, with the ability to draw circles, ellipses, lines, and other graphical elements. All the display API functions are available to the robot’s supervisors and only a few are used to represent the skills. 6.3.6 Robot Supervisor In the simulated environment, each robot is equipped with its dedicated supervisor, ensuring individualised control and management for distinct robot nodes. Despite sharing the same base code, each robot operates through its supervisor instance, where the sockets, which are different in every robot, are used for inter-process communication among the nodes. These robot supervisors receive inputs from both the main supervisor and the base station. After gathering all the information available, the robot calculates the desired movement and action for the active skill given by the strategy. The robot movements and actions are then sent to the Webots API to move the robot accordingly, dribble and kick if necessary. Information is also sent to the base station to serve as feedback to the game strategy algorithms, just like it would happen in the real world. Apart from the necessary communications for movement and feedback, the desired requests are made to the display controller to represent the robot’s actions on the field floor. The data flow between all the controllers and supervisors is represented in Figure 37. Robot Robot Robot Robot Skill Base Station World State Movement and Actions Robot Webots API Display Elements Display Main Supervisor Robot Information Robot Elements Location Webots API Display Controller Draw Request x5 Figure 37: Webots simulation data flow diagram 48
Chapter 7 Game Strategy RoboCup middle-size league teams have traditionally used game strategies where robots make autonomous decisions [3]. This dissertation introduces a new game strategy approach that relies on centralisation, probability-based plays, and fast communication, redefining teamwork among robotic football players. Unlike traditional methods, this approach retains robot autonomy while taking advantage of a central computer, the base station, to provide skills, world information, and even ideal paths. This centralisation enhances probability-based decision-making and synchronises robot actions, creating an efficient and reliable game strategy without a playbook. 7.1 Architecture Figure 38 represents the colour-coded game strategy architecture schematic. It contains the Communications module, Data Fusion, Play Generator, Decision Trees [39,40] and Heat Maps [38] and the Skill Assigner. The modules are explained in the following sections. 532 41 Data Fusion out: Filtered Information Game Decision Tree out: Game State Play Generator out: Current Play Player Decision Tree out: Player State Heat Maps out: Player Positioning Map Positioning out: Player Target Position Skill Assignemet out: Player Skill Skill Arg Calculations out: Player Skill Arguments Communications out: Robots Information Figure 38: Probability-Based Strategy (PBS) architecture diagram 49
The communications module (in light blue) was already described in the Communication System chapter. The data fusion module (represented in dark blue) filters all the information gathered by the robots, creating a real-time world state map used throughout the strategy. The decision trees (in red) are responsible for part of the decision-making, both for the game and the player’s decision trees. The Play Generator (shown in green) computes the optimal play for the current state of the game. Positioning and movement calculations fall within the preview of the heat maps and positioning modules (indicated in yellow). The two modules in purple are tasked with assembling the information, calculating the necessary arguments for packets, and transmitting them to the communication modules [9], thereby ensuring synchrony among the robots. 7.2 Visual Representation All base station representations are explained in chapter 8, but as context for the game strategy, a few key elements are presented. Figure 39 shows a MSL field, and the predefined axes Xand Y used throughout the strategy. All the field locations and positions use this axes configuration. The team goalkeeper defends the negative Xaxis goal. X Y Figure 39: Field axes and size reference Figure 40 shows the base elements. Represented with a blue hexagon are the team robots with their robot number (Figure 40 (a)). The arrow in front of each robot shows its orientation. The red circle represents the opponent’s robots (Figure 40 (b)) and the small yellow circle represents the ball, visible in Figure 40 (c) next to robot number two. Between two teammates, one with ball possession, there is a yellow line that represents the line of pass, visible in Figure 40 (c). The perpendicular yellow line between an opponent and the line of pass shows the shortest path between the opponent and the line of pass, visible in Figure 40 (c), and its intersection is represented by a tiny yellow circle. 50
(a) (b) (c) Figure 40: Representation guide: (a) Team robot; (b) Opponent; (c) Line of pass and opponent’s influence 7.3 Skills As the basis for a game strategy, the robots can perform certain skills as they are fully autonomous in that regard. For example, the robots can be instructed to follow the ball, and that is enough for the robots to detect the ball, obtain its precise location, calculate its trajectory, and move to grab it. Arguments are passed as a way to specify certain skill elements or to help the robot in a situation where it does not have the required information for the skill. Therefore, skills are the most fundamental actions that can be directed under this game strategy. Specifically, in the LAR@MSL game strategy [7] and in this dissertation, each robot can be assigned one of eight possible skills, each with up to seven arguments (Table 4). The number of arguments is higher than necessary at the moment since it was planned to provide future expansion of the system. Table 4: Table of skills and respective arguments Skill ID A1 A2 A3 A4 A5 A6 A7 Stop 0 - - - - - - - Move 1X Y Ori OxOy- - Attack 2BxByP- - - - Kick 3TxTyP/K DxDy- - Receive 4BxBy- - - - - Cover 5X1Y1X2Y2A - - Defend 6BxBy- - - - - Control 7DxDyOri P /K- - - 51
Stop Stop is the most basic skill of them all and has the purpose of stopping all robot-moving elements. It brakes the three locomotion motors, completely stops the dribbling mechanism and blocks the robot from actuating its kicking mechanism. It has no arguments and it is used every time the game is stopped or in case of an emergency. This skill has no hardware override and is not connected to the emergency stop mechanism since it only uses software. For an emergency stop, the robot has a wireless operated relay described in section 4.2 Energy and Power Distribution. Move The Move skill, as the name suggests, is used to send a robot to a target location. It has five arguments, which are the location where the robot should go, a flag to define if the robot’s orientation is free or locked, and the Xand Ycoordinates the robot should orientate to. If its orientation parameter flag is free, by default the robot orientates itself to the ball location. It is one of the most used skills and requires information from the localisation and detection systems. The robot dynamically calculates its path so that it can avoid all obstacles while performing the desired movement. Attack The Attack skill is responsible for trying to grab the ball as fast as possible with the dribbling mechanism. It receives the ball coordinates as a parameter and only uses it if it does not see the ball with its own vision system. It gives priority to the front-facing Kinect camera, followed by the omni-vision system. Only if both are not able to see the ball, the robot will use the parameter sent with the command. Regarding the grabbing action and the ball control, it is entirely achieved by the dribbling mechanism. The Pparameter is a flag used for penalties, in which case the robot moves slower towards the ball so that it does not take the ball out of place. Kick When the robot intends to score a goal or pass the ball, the Kick skill is used. The robot already knows its location by the localisation system. The first two parameters indicate the absolute position where the ball is supposed to be kicked. The third argument separates a pass from a kick to the goal. The robot adjusts the force applied to the kick accordingly. In a pass, the parameter specifies the kick force based on the distance to the teammate. When flagged to kick to the goal, the robot calculates where to shoot and kicks to the goal with maximum power. 52
Figure 44: Complete graph in a game situation 7.7 Ideal Probability Path Finder Algorithm The calculation of the highest probability path (lowest log probability value) is based on the path finder algorithm A∗[49,42]. The input to the algorithm is the graph itself with the starting and ending nodes. These nodes are always the robot that has the ball (starting node) and the goal (ending node). The output is the order of nodes that make the highest probability path. The A∗algorithm applied to this strategy outputs the highest probability path of scoring a goal given the current game situation and ball handler. The algorithm runs at every planning iteration and outputs the set of actions that maximises the probability of scoring a goal. When the overall probability is low, the kicking skill is delayed in order to give the team more opportunities to find a better set of actions, which occurs thanks to the positioning of the robots. The highest probability path is represented in pink lines in the graph, and the probability of every action is also displayed near every line. To give robots more independence, besides the highest probability path, it is also calculated the highest probability alternative. This is achieved by changing the arbitrary value of the first action to the highest value possible and then recalculating the highest probability path. The alternative is represented in orange, and both are given to the robot who has the ball. This is used in situations when the game changes very 59
quickly and something prevents the robot with ball possession from making a pass. In those situations, the robot already knows the alternative to keep the strategy going. Since this is calculated at every loop, nothing needs to be performed if the robot decides to use the alternative path instead of the main one. 7.8 Decision Tree The Play Generator covers the desirable path for the ball in offensive situations, but something needs to decide what type of situation the game and each of the robots are in at every moment. This is where decision trees come into place [39,40], and for this strategy, there are two of them. 7.8.1 Game Decision Tree The game decision tree handles the game state and decides the skills desired for the current game situation, as shown in Figure 45. Each possible path in the game decision tree outputs a list of five skills. These skills are distributed between the players based on the other players’ decision trees (explained in section 7.8.2 Player Decision Tree). The tree can be readjusted and configured by a JavaScript Object Notation (JSON) config file. Most of the branches have two possible outcomes that are solvable with a boolean variable, for example, the first one is Ball. The negative of that is not Ball or !Ball. All the variable meanings are available in Table 6. PassGoal Pass !Pass Game Decision Tree Ball Shoot !Shoot !Goal !Pass Free OurBall KnownBall !Ball !KnownBall Opponent Transition Pass Goal Figure 45: Game-state decision tree 60
Table 6: Table of variables in the game decision tree Variable Meaning Ball Team ball possession Shoot Team can perform a kick Goal Team is allowed by the rules to kick to the goal Pass Team can perform a pass KnownBall Team knows where the ball is Free The ball is free in the field with no nearby robot OurBall No ball possession but one of the teammates is the closest Transition The ball is between actions, moving after a kick Opponent Opponent team has the ball or is closer Pass The transition is a pass from own team Goal The transition is a goal kick 7.8.2 Player Decision Tree The Player Decision Tree is calculated for every team member and decides which state that player is in, as shown in Figure 46. It is based on their current strategy, game and time states. Player Decision Tree Timeout !Timeout Defending !Defending Transition!InPath LPass !LPass FriendBall OurBall !OurBall InPath MyBall !Pass Goal Pass !Pass Pass NearBall !NearBall Figure 46: Player decision tree The same logic of variables in the game decision tree is applied here, for example, OurBall represents the ball possession and the !OurBall is the opposite. The Player Decision Tree is used to decide each robot’s skill and even some arguments for that player state. Also associated with that player state are the weights of each of the heat maps that decide the robot’s positioning. These weights are divided by player situation and not by robot, based on the fact that different situations are what determine different outcomes, and not the number of robots present on the field. Also, since the robots influence each other, even though they might be in the same player situation, their final heat maps are different, and so are their desired position. The Player Decision Tree variables are presented in Table 7. 61
Table 7: Table of variables in the player decision tree Variable Meaning OurBall Team ball possession InPath Robot is in the ideal ball path Transition The ball is between actions MyBall Robot has the ball FriendBall A teammate has the ball Pass A pass can be performed Goal The next action is a kick to the goal LPass There are lines of pass available NearBall Robot is the closest to the ball Timeout Timeout to attack the robot with the ball Defending Robot is defending an opponent 7.9 Robot Positioning and Heat Maps Equally important to the decision-making, is the robot’s positioning. Being in the right location at the right time has a huge impact on the game. Following the same logic as the decision-making, and with the need to have different outcomes for different situations, the use of weights and probabilities was the approach taken. 7.9.1 Zones A baseline positioning setup is important to always have safe and known options, and therefore the same solution applied in real football is used here. Formations serve as the blueprint for tactical organisation on the field, influencing a team’s performance and strategy. They organise the player’s positioning, movement, and overall team structure during the game. Formations in futsal optimise both defensive and attacking situations, team coordination, and fluid transitions between offence and defence. Effective formations require synchronisation among players, and based on that, the playing style can significantly impact match outcomes. Futsal Zones Futsal has multiple known formations and is a 5v5 game just like MSL. Multiple possible futsal formations were studied, and the most common are presented in Figure 47 and 48. All of them have advantages and disadvantages and all of them are used in different games against different opponents. 62
2 3 14 5 (a) 5 4 1 2 3 (b) 5 4 1 2 3 (c) Figure 47: Futsal formations: (a) Wall; (b) Side Line; (c) Line 5 4 12 3 (a) 2 3 1 4 5 (b) 5 4 12 3 (c) Figure 48: Futsal formations: (a) All or Nothing; (b) Square; (c) ’Y’ formation Zones in Robots When applying the formations to the robots, one of the most effective formations when balancing both offensive and defensive situations is the Diamond formation. This formation has two configurations possible for defensive and offensive situations, visible in Figure 49. This formation is based on a series of symmetric triangles that translates to multiple lines of pass simultaneously and provides effective cover when defending a certain player. The biggest disadvantage of this formation is the fact the players are required to move substantially. Which for a robot, contrary to a human, only stops when runs out of battery. 63
4 3 1 2 4 3 5 5 2 1 Figure 49: Diamond formation offensive and defensive situations An important difference between futsal and MSL is that robots know and can do all the same things. Robots are built equally, and all can move and control the ball the same way. That is a difference from the human game that can be taken advantage of. When using a Diamond formation, humans run a lot to keep every opponent under pressure and to keep their position at the same time. Since all the robots are equally built, it is possible to take advantage of that by not having fixed positions in the formation assigned to each robot. After a play, robots do not need to return to their assigned position or formation due, because another robot can replace them and swap positions. Zone Assignment and the Hungarian Algorithm The Zone assignment is solved by exploiting the indifference between robots. The simplest yet most effective solution is assigning zones based on distance. Every robot should be assigned to its nearest zone, but two robots cannot be assigned to the same zone and no zone can remain without a robot. Zone assignment is based on the shortest distance overall, so the sum of the distance between every robot and its assigned zone needs to be as low as possible. The Hungarian Algorithm solves that problem. The Hungarian algorithm is used to solve an assignment problem with the optimal combination of agents to tasks while minimising the overall cost, in this case, distance. A matrix is created with the distances between every robot and zone. It iteratively identifies the most efficient assignment by seeking a combination of assignments that collectively have the lowest distance. Figure 50 shows two cases that are very similar but have different solutions because the overall distance is different. Robot number one, the goalkeeper, is not taken into consideration in zone assignment because it is not desirable for it to leave the goal. 64
4 3 1 2 5 4 3 1 2 5 Figure 50: Hungarian algorithm zone assignment example 7.9.2 Base Maps The sum of multiple base maps that are dynamically adapted for every game iteration is each robot heat map. Robots positioning is based on each robot heat map. The positioning map is calculated for each robot, which is the fusion of multiple distinct base maps, each with pre-generated matrices of weights. These matrices represent specific game influences and are created using distinct formulae aligned with the desired outcome. The heat map colour scheme is a “Red-Blue” format, where the blues represent low-value areas and the red represents high-value areas. It can be associated with warm and cold zones, where the robot always prefers the warm zones (red) and avoids the cold zones (blue). The representation formulae and user interface is presented in 8.1.3 Heat Maps from the Chapter Base Station. Base maps can be either entire field or partial field maps. They can be team or single robot maps, and they can either be influence maps or a rule. Entire field maps have influences that, based on a static matrix, impact the whole field regarding the robot’s position. Partial field maps are mostly robot-focused and readjusted at every game iteration. Team maps are calculated for everyone on the team. For example, the influence of all opponents is the same regarding the robot’s position. Everyone on the team can use that map after being calculated since it does not have the robot’s position as an input. Single robot maps are calculated for every robot, as is the example of the Distance Map presented in Figure 51. This map is calculated based on the distance between the robot’s current position and its surrounding locations. This particular map serves the purpose of limiting the movement options available to players by excluding long-distance solutions. In fact, this distance base map ensures a more focused range of movement for the player, eliminating choices of longer movements or time-consuming. 65
(a) (b) Figure 51: Representation of a base map based on the distance to the robot: (a) 2D base station representation; (b) 3D representation This example is a linear equation based on the distance, visible in Equation 7.6 where Cxand Cy are the matrix centre coordinates, xand yare all the points from the matrix. βin Equation 7.7 is a multiplication factor used to normalise the values between matrices. The radius of the distance influenced is defined by r. The base map is achieved by calculating αfor every matrix position. d=√(x−Cx)2+ (y−Cy)2(7.6) αx,y = 1−(β∗d r),if d≤r 0,otherwise (7.7) Forward Field and Centre Field Figure 52 shows two base maps with similar purposes but different influences. These are entire field maps, and the first (a) influences to make the robots move forward in the field. It makes all the solutions have a forward and progressive approach to the field. The second map (b) is to make the robots avoid the sidelines. It has the purpose of making the robots play more in the middle of the field, to avoid losing the ball on the sideline. This map is important, especially for a new team with control systems that are not fine-tuned. 66
(a) (b) Figure 52: Representation of base maps: (a) Forward field; (b) Centre field Ideal Pass Distance One way to optimise the pass probability is to position the robots in ideal conditions of pass. This base map was created for that purpose and varies from robot to robot depending on where the ideal pass distance map is positioned. This map is visible in Figure 53, (a) is a field representation, and (b) is the Bayesian curve in a 3D representation [50]. For the robot in possession of the ball, the centre of this matrix aligns with the next robot on the path. Conversely, for the robots positioned on the path but not in possession of the ball, the matrix’s centre is aligned with the robot from which they are anticipated to receive the ball. The formula employed for these calculations is identical to the one used for the ideal pass probability in Equation 7.2. (a) (b) Figure 53: Ideal pass distance base map: (a) Field representation; (b) 3D pass probability representation 67
Ideal Goal Distance Just like in the ideal pass distance base map, the same principle is applied to the ideal goal distance, but with some changes because of the importance of the kick angle between the robot and the goal. When performing a pass, both robots are facing each other. When kicking to the goal, the angle from where one shoots influences the area visible on the goal. Equation 7.8 is the formula for the ideal goal distance, which is the pass probability Bayesian curve times the cosine of the angle αbetween the goal and the kicking robot. Besides the same variables as presented in the ideal pass distance formula, distRG represents the distance between a robot and the goal, and IGD is the Ideal Goal Distance. Contrary to other base maps, this matrix is stationary and is always applied to the centre of the opponent’s goal. Visible in Figure 54 is the matrix applied to the field (a) and the 3D representation of the matrix (b). GoalP rob =cos(α)∗p d√2πe −(distRG−IGD)2 2d2(7.8) (a) (b) Figure 54: Ideal goal distance base map: (a) Field representation; (b) 3D goal probability representation Opponents Circle In an offensive situation it is not ideal to be near the opponents, and that is the reason for this base map. It consists of a simple negative power function to make the robots avoid the opponents. The matrix is the same for every opponent. For optimisation reasons, and because the opponent’s influence is the same for every robot, one map is created with all the opponent’s matrices. The full map is the combination of nmatrices, being nthe number of opponents detected. Figure 55 (a) represents the field with all the opponent’s matrices, and (b), is a 3D representation of an individual matrix with its formula visible in 68
7.9.5 Position Calculation A heat map does not return a specific position but a general area of where the robot should go. Based on that, the position can be calculated. A new binary matrix is created where the maximum values of the heat map are equal to 1 (one) and the rest is 0 (zero). This binary map is then used to detect all the good positioning areas available. To calculate the position based on the heat map, it was used the OpenCV library [53]. With the functions cv2.findContours and cv2.moments the centre of mass is calculated for every area. When multiple ideal areas are available, the selection of which one to choose is based on the largest area. Figure 62 shows a situation of four maximum value areas, with their specific maximum value centre of mass with a green cross, and its binary map. After calculating the centre of mass of all four, the location chosen is the one with the highest area, in this case, location B. 2 B A CB D 2 Figure 62: Position selection based on multiple possible areas 7.10 Skill Assignment The outcome of the Player Decision Tree and Game Decision Tree gives a group of five skills to be assigned to the team robots. These assignments are based on a couple of factors that vary between distance to the goal, current position, distance to the ball and even pressure variables. 7.10.1 Offensive Situation In offensive situations, almost all assignments are solved based on the ideal probability path. The robot who has the ball should pass to the next robot in the path and so on, until one robot kicks to the goal. All the robots not present in the ideal path should move to do one of two things: stay in the defensive 75
area and find a position to be part of the probability path; giving alternative lines of pass. In every situation, the goalkeeper must remain in the defend skill to protect the goal. 7.10.2 Defensive Situation Regarding defensive situations, the same approach as futsal is used. There is always at least one robot responsible for putting pressure on the opponent who has the ball. The other three strikers have an assigned opponent to defend with the Cover skill. The robot that should have the Attack skill to put pressure on the opponent with the ball is the one nearest to the ball. The opponents are assigned to each robot using the Hungarian algorithm. This algorithm is applied with the robots that are not in the attack nor the defend skill. This is verified in every iteration. If opponents swap positions, the robots also swap their assigned opponent and remain in the Cover skill to block them from receiving the ball. 7.10.3 Skill Arguments Calculations For each skill, arguments are calculated differently depending on the situation. The arguments in the Defend, Receive and Attack skills are the ball location, and it is given to the robot the weighted average calculated by the data fusion. Robots will only use the sent ball location in case they do not detect it with their own vision system. In the kick skill the arguments of where to kick are always the location of the next node in the ideal probability path, that can be either a teammate or the goal. The P/Kargument is set depending if it is a Pass or a Kick to the goal. The additional displacement arguments Dxand Dy are calculated based on the ideal position of the skill calculated by the heat maps. In the Cover skill, the arguments are the two objects one should cover. This is only used in defensive situations, and the points are the assigned opponent to defend, given by the Hungarian algorithm used and the goal. Regarding the Move skill arguments, they are calculated by the heat maps. Its orientation is set to be in line with the ball to take advantage of the front-facing camera. 7.11 RefBox Situations RefBox is the referee’s computer, that is used to send the referee decisions onto each team’s base station. All robots must obey the RefBox commands, and in case some robot malfunctions and does not behave properly, it will be considered a damaged robot and must leave the field. All referee interactions start with the Stop button from the RefBox. Therefore, when that button is pressed, the skill Stop is sent to all robots. After the ball is placed in the desired position by the referee, one of the situation buttons is 76
pressed. The possible situations are kickoff, free kick, goal kick, throw-in, corner and penalty, which can be to either team. In a RefBox command for the opponent team, robots will behave as they normally would by the strategy, with one key difference. The player decision tree that selects the skill for each robot will not allow any player to use the Attack skill before the referee restarts the game. The robots will just position themselves trying to cut lines of pass and put pressure on the opponent team. Regarding a RefBox command for an offensive situation, where the team has the ball possession, robots will also behave as the strategy dictates in an offensive situation. The player next to the ball that will restart the game, will not receive the Attack skill before the referee restarts the game. Also, in the first Attack skill to restart the game, the striking robot will receive a flag in the arguments that dictates the robot to move slowly to the ball in order to not take it out of place. To summarise, in RefBox commands robots will still detect the ball and opponents. When the referee instructs the robots which offensive or defensive commands it is, the robots will move accordingly to effectively restart the game. 77
Chapter 8 Base Station The base station computer has the responsibility for numerous modules, each with distinct tasks relevant to debugging, gameplay, calibration and testing. The development speed was a crucial factor, and consequently, Python was selected as the programming language. Besides its fast development time, Python has excellent graphical and data representation tools. Pygame was the library used for Graphical User Interface (GUI) development due to its graphics/multimedia features, performance, active community and open-source nature. Because of its game-oriented focus, the use of the Simple DirectMedia Layer (SDL) allows the pygame to take advantage of hardware acceleration for fast graphics rendering. 8.1 Tabs and their Purpose Using the same GUI as a browser, the base station interface is divided into tabs that serve different purposes. With a total of five tabs, these are the easiest ways to organise the representation and show different GUI elements. The tab division also allows the computer to render only the information needed for that specific tab. 8.1.1 Game + RefBox The primary interface is the ”Game + RefBox” tab which plays a central role in this system. It is used during the game and displays both the ongoing match and vital robot information. It shows the field, the robots and the detected elements’ representation. Below the field, there are five boxes with each robot’s information updated in real-time (around 25 times a second). This is where all the non-game robot information is presented. The exact information received is presented in Table 3, section 5.3 Data Frames from Communication System chapter and more information about how the data is presented in section 8.2.2 Robot Information. 78
There are buttons next to the field that simulate the RefBox for testing purposes without the need for a separate Refbox computer. The current score is prominently displayed in the top-right corner. For a clear overview, this interface’s visual representation is shown in Figure 63. Figure 63: Game + RefBox tab 8.1.2 Strategy The ”Strategy” tab serves as a debugging tool for the decision trees within the game strategy, visible in Figure 64. Similar to other tabs, it displays the robot information on the bottom. This tab includes both the Game Decision Tree and the Player Decision Tree on the right. The active state within the decision trees is in pink. The representation of the decision trees is modular and based on the configuration files imported at the beginning of the base station code. Users have the flexibility to choose which player’s decision tree to display by using the keyboard numbers one to five to select the desired robot. The robot selected has its information box with a different colour in order to show to the user the selected robot. In Figure 64 the selected robot is number one, so the player decision tree shown is from robot number one. 79
Figure 64: Strategy calibration tab 8.1.3 Heat Maps The ”Heat Maps” tab, visible in Figure 65, is essential for debugging, calibration, and visualisation of positioning maps. Instead of the conventional green field, it represents the probability maps used for positioning with a colour-coded matrix. The representation shows the complete map of the selected player, number five in this case, decision tree state, with high-probability areas marked in red and low-probability areas in blue. To calibrate a map other than the current player’s state, users can enable the checkbox on the right and select the desired map from the dropdown menu. Each dropdown menu option is a possible outcome of the player decision tree discussed in 7.8 Decision Tree in Game Strategy chapter. Users can adjust the weight of each base map using the track bars on the right side to calibrate the influence based on the current player’s situation. 80
Figure 65: Heat maps tab with calibration trackbars and player decision tree 8.1.4 Skills The ”Skills” tab plays a crucial role in calibrating control systems as well as any team demonstration. In this tab, users can select a specific robot using the keyboard numbers one to five, place markers on the field, and assign a specific skill for the chosen robot to execute. With this interface, one can control and test certain skills without the need to reset or manually move the robots. The markers are used to determine the skill arguments. For example, the kick skill needs an argument specifying the target location, and in this tab, such arguments are calculated using the markers. On the field, the markers are represented as pink and brown circles, such as the first and second markers, respectively. The need for two markers is due to certain skills requiring more than one location argument to be executed. Figure 66 shows various skills that were manually sent to the robots using the markers and the skill buttons. Robot one is in the Stop skill whereas robots number two and four are in the Move skill. Robot number three, the selected one, is in the Cover skill. The markers for the selected robot, number three in this case, are also visible. On the right side, below the skills buttons, a set of track bars is used to tune the PID control systems on the robot. These track bars enable the adjustment of PID parameters, and the information is transmitted to the robot to remotely command the robot’s control systems. Users can select a specific skill from the dropdown menu to modify the associated parameters. The save button is used to instruct the robot to save the current PID parameters onto its configuration file. 81
Figure 66: Skill tab with PID calibration trackbars, skill buttons and player decision tree 8.1.5 Vision The ”Vision” tab is a tool for the robot camera verification. It can simultaneously show camera images from all robots and select the specific image to show. The choice of camera is based on five dropdown menus, each corresponding to a robot. The image shown can be from the omni-vision camera, with or without the object detection and the Kinect depth camera either the RGB or Depth images, among others. Figure 67 has the images from robots number two, three and four. Robot number two requests the Kinect image with object detection while robot number three requests the omni-vision image with only the detected white lines. Lastly robot number four requests the image from the omni-vision with object detection. The protocol used to send the images in real-time to the base station is the Google Remote Procedure Calls (gRPC)1. In the team scenario, it is mostly used to make sure that the neural network is working well and the robot’s vision systems are working as intended. 1gRPC is a high-performance open-source remote procedure call (RPC) framework that uses protocol buffers and HTTP/2 for communication. 82
Figure 67: Vision tab 8.2 Graphical Representation The base station graphical representations need to be as intuitive and interactive as possible. The reason is that the representation of values helps one to understand what the sent values mean. During a game, the values sent by the robots change multiple times a second, and its representation is the key to simplifying the interpretation of the values by humans. 8.2.1 Field and Robots The highest screen percentage used is for the field and robots’ representation. To draw the field, the size of every field line is required and it is available in the MSL rule book [3]. These guidelines still generate various possible field configurations, so the field drawn is always based on the same configuration structure. The field was designed to be scalable according to a scale factor as well as the screen resolution. The robot’s location and orientation are used to draw them onto the field. Based on the robot’s location and orientation, the coordinates of each detected game element are calculated and drawn onto the field. The coordinates of the detected elements are relative to the robot. These are converted onto absolute coordinates before being represented. After drawing every robot and detected element, that same data is fed into the data fusion and the filtered locations are also drawn onto the field. Both the original and filtered information are shown and the way to distinguish both is based on the opacity. Each robot’s ball 83
detection has a 50% opacity with the weighted average of the ball at 100% opacity. An example of this representation is visible in Figure 68. Figure 68: Every robot ball representation and weighted average 8.2.2 Robot Information The robot information is a real-time table of all the important robot data. It provides information about sensor readings, battery charges, communications, robot states, and other relevant data. To make the information more intuitive and easy to interpret its representation is colour-coded. Specifically, white indicates normal operation, orange indicates a warning, red indicates an important alert and pink means something is not connected. Instead of words, emojis and icons are used to compile the information making it both intuitive and efficient in terms of screen space utilisation and human interpretation. Figure 69 shows an example of this data on Robot 3 where the Git2commit is outdated and, therefore, is in red while the camera battery is at 14%, which is low, and the capacitors of the kick are also at a very low charge of 4%. The battery is not connected so it is represented in pink. It is also visible that the computer battery is at 60% charge and is charging as shown by the plug icon next to the battery percentage. 2Git is a version control system that tracks code changes and allows developers to collaborate by committing code revisions. 84
The second map, Figure 73, shows a defensive situation where the robots intend to move to positions to cover one or more opponents. The map shows robot number five intention, where the zone and distance are the elements with more influence. This occurs because, in this situation, robot number 2 which is a teammate is the closest to the ball. Although this is a defensive scenario, there is no immediate threat from the opposing team. Therefore, the best strategy is to maintain a defensive position, keeping a suitable distance from the opponent to be able to receive a pass but remaining close enough to react quickly if the opposing team gains possession of the ball. Figure 73: Defensive probability map The influences of all maps have a specific weight associated with them and these need to be adjusted according to the desired output of a particular game and player situation. For an output of the decision trees, the desired maps’ weight is calibrated so that the robots position themselves correctly. Each map can have an influence between 0 and 1, where 0 is no influence at all and 1 is the maximum influence. These maps were calibrated using the simulator and based on normal football player behaviours in those situations. With the sum of all heat maps visible on the screen, the simulator is used to emulate a play. In each game situation, the human coach stops the virtual game and adjusts each map contribution to values that feature the intended result. Then, the virtual play resumes, which is repeated until the robot’s behaviour is as intended. Using the simulator to calibrate the maps simplifies and accelerates the process because of the ability to create custom game situations to be studied. 91
9.4 Simulator As expected, the simulation behaviour was almost flawless regarding the control systems and information, which helped develop the game strategy itself. Besides controlling the robots from the team and simulating the communication system, opponents were also positioned to test different game situations. 9.4.1 Case 1 The first game situation, presented in Figure 74, is an offensive situation. After robot 2 recovers the ball, the highest probability path is from robot number 2 to robot number 4 and then to robot number 5 to shoot to the goal. While that happens, robot number 3 positions itself near the ideal goal distance, giving an alternative to robot numbers 4 and 5. If robot number 4, after receiving the ball, has no line of pass to 5, it already has number 3 as an alternative line of pass. This is an example of where the heat maps and probability path complement each other by trying to optimise each other. Figure 74: First game situation in the simulator 92
9.4.2 Case 2 Figure 75 has two images from the same game scenario. Figure (b) is the situation after the first pass. In Figure 75 (a), robot number 2 has the ball and the highest probability path states that the following action is to pass the ball to robot number 4. At the same time, robot number 5 will stay further back, trying to defend. Robot number 3 will go forward trying to position itself to give robot number 4 an alternative line of pass. After the first pass between robots 2 and 4 is made, robot number 5 positions itself more to the centre, and robots 3 and 2 change tasks. This happened because robot number 2 was closer to the desired spot. Since no other opponents are detected, robot number 4 also has a relatively high probability of scoring, that being the assigned task. (a) (b) Figure 75: Second game situation in the simulator: (a) Initial situation; (b) Situation after the first pass 9.4.3 Case 3 Another offensive play is visible in Figure 76, where the probability of pass and goal is high, but the position is the key difference. Robot number 3 stays near its assigned zone and becomes a more defensive player. In contrast, robot number 5 tries to position itself between robot number 2, the one with the ball possession, and robot number 4. This intention is based on always trying to create alternative passes to maintain a fast game. 93
Figure 76: Third game situation in the simulator 9.4.4 Case 4 Now, shown in Figure 77, it is a defensive situation where each robot has an opponent assigned based on the Hungarian Algorithm, visible with the dark red lines. The robot of the assigned opponent must defend and try to cut the line of pass or goal. To maintain high pressure, the robot closest to the ball still tries to attack it and in this case, it is robot number 2. Robot number 3, besides covering the opponent’s line of goal further back, is deliberately covering that position with the intent of also cutting the line of the pass to the opponent near the centre. 94
Figure 77: Fourth game situation in the simulator 9.5 Against Humans After completing the calibration, the tests needed to be more dynamic. As a result, developing a simulator that allows humans to play against robots became a need. Like in common football computer games such as the FIFA video game, a game controller was given to each human to control one of the opponent robots, visible in Figure 78. Using the control skill, each human handled the robot’s movement, orientation, and pass or kick actions. Playing against a team of humans was carried out specifically to help better understand what types of in-game situations needed some adjustments. A video of the strategy development is available on LAR’s Youtube channel [54], where the simulator, the base station, and the game strategy actions sent to the robots are shown. The strategy proved to be more synchronised than the human team and their movements were visibly more coordinated. 95
Figure 78: Game strategy against humans in the simulator It effectively cut the lines of pass and intercepted the ball in a pass. In the use of the Cover skills, it is also perceptible that the Hungarian algorithm begins to associate each robot with an opponent to defend, where the associated opponent is always the nearest to that robot. It is also perceptible that as soon as the robots get ball possession, the time required to play and kick to the goal is also very little. During offensive situations, the position of the robots ahead of the ball to create alternative lines of the pass is also visible and effective. Even though they were not necessary, alternative lines of pass constantly exist. 9.6 Competition Games The transition to the real-world was studied on different occasions but real games were only played in RoboCup 2023. A short video that shows the intentions and defensive plays of some games played in the competition is available on LAR’s Youtube channel [55]. It is visible in the real-world image (filmed by one of the competition teams) and in the base station information gathered by the robots and what were the decisions taken. All the games were recorded during the competition, and all the information sent to and from the robots was recorded into a log file. This video shows four different plays which are described next. 96
9.6.1 Play 1 The play shows an offensive situation starting from kick-off. Immediately after kick-off, the players tried to position themselves to receive a pass and try to score a goal. This happened because they were on a more defensive and quick counter-attack strategy, defined by the maps and probability curves. It is visible that after kick-off, robot 3 tries to position itself in a line of pass and goal. Due to the poor robot control system, it was not able to receive the ball from robot 2. It is also perceptible in the information update presented how inconsistent the communication-saturated environment was. The flicker of each robot position and opponent detected was due to the accuracy of the localisation and detection systems. 9.6.2 Play 2 This shows a defensive situation, where all the robots positioned themselves to go to either side of the field. This opponent’s kick was saved by the goalkeeper’s good positioning, who managed to save the goal based on the information given by the other teammates. The information gathered by the strikers about the ball location was extremely important to the goalkeeper, who, based on that, could act accordingly. 9.6.3 Play 3 In play 3, a defensive situation, a synchronisation problem caused by the saturated Wi-Fi environment in the competition is visible. However, the robots still behaved properly. Although robot number 4 did not move due to hardware problems, robot number 2 covered the lines of goal and pass. After the opponent’s pass, the detection system malfunctioned and the robot was not correctly positioned to defend the goal or cut the line of pass. This play proves the effectiveness of the Cover skill. 9.6.4 Play 4 This example shows a defensive corner situation where the team tries to defend the goal. Two of the robots were out of the game due to mechanical and hardware problems. With the three robots on the field, robot number 2 and number 3 try to cut lines of goal from multiple robots while robot number 1, the goalkeeper, tries to position itself to cover the ball. The goal lines are covered with the skill cover and the position on the goal line of robot 3 was further back so that the goal area covered would be higher. Since they were at a numerical disadvantage, there was no point in robot number 3 covering the nearest opponent. 97
9.6.5 Real-World Differences Due to the project’s recency, the control system experienced performance issues when transitioning from simulation to the real world, consequently affecting the game strategy. The information gathered by the robots was inconsistent leading to less effective real-world results compared with their performance in simulations. The overall strategy output remained accurate but the robots’ data inaccuracies and simpler control systems limited the effectiveness of the strategy. Most of the effective plays were defensive aimed at cutting lines of pass and goal. In this competition, precise robot control is crucial especially as opposing teams had faster robots than those of the LAR@MSL team. 9.7 STP vs. PBS Since the game strategy implemented was developed for the RoboCup championship, the comparison between STP and PBS is a good way to explain the advantages and disadvantages of the work developed. 9.7.1 Differences Both strategy algorithms are based on skills that the robots can perform, but how these are attributed to the robots is very different. While the STP architecture is decentralised and the synchronism is maintained, the PBS is centralised and depends on a reliable and efficient communication system. Another major difference is the scalability of the architecture. STP decides which play to use at each moment based on the plays developed in the playbook [13,12]. One of the problems is that the plays are thought to have a static number of players. If the number of players in a team changes, the playbook needs to be rebuilt. The PBS developed skips the need to implement tactics, making it simpler, easier, and less time-consuming to implement. 9.7.2 Limitations PBS also has some disadvantages, and the limitations are almost all based on information, actions, and the opponent’s behaviour. Firstly, since the decision-making is centralised, the latency of communications can be a problem. Therefore, the communication system must be as fast and reliable as possible. It also depends on the robots’ information, like their locations and the objects they detect in the field. If that information is not accurate and precise, it can easily change the output of the decisions taken. Regarding the control systems, should the robots not behave well given a certain skill, the game’s outcome can be 98
ruined even though the game strategy still tries to give the best output possible. The game strategy is as efficient as the robots, which can perform the skills fast and reliably. Secondly, the first calibration process of the heat maps can be time-consuming. Even though the calibration is initially set up in the simulator and can be primarily tested against humans, achieving a stable solution can take quite some time. After the first stable solution, adapting and changing the behaviour is quicker and more straightforward. PBS also depends on the opponent’s behaviour and the strategy results in the real world were as good as the opponent team’s performance. If the opponent team has a stable and organised game strategy, it is easily predictable and excelled by PBS. If the opponent team’s behaviour is entirely random, PBS makes decisions based on unexpected events and performs worse. 9.7.3 Modularity, Flexibility and Scalability The game strategy’s modularity, flexibility, and scalability were all factors considered while designing the PBS algorithm. Concerning modularity, the system is easy to change and adapt to different game situations and opponents’ behaviour. By adjusting the heat map weights and the opponent’s influence in the pass and goal probability formulae, the robot’s risk can be adapted to the opponent team. Regarding flexibility, both the game and Player Decision Trees are easily configurable to adapt to any opponent team strategy. PBS is also easily scalable since it does not rely on the number of players on either team. 99
9.8 Summary The game strategy demonstrated promising performance in tests across different environments, including the simulator, games against humans and real-world competition. In the simulator, the strategy could direct robots to make appropriate positioning and passing decisions in varied offensive and defensive scenarios. The calibration process allowed tuning of the influence maps to achieve the desired robot behaviours. Games against human opponents provided valuable insights into dynamic situations requiring strategy adjustments. The real-world competition enabled the evaluation of the complete system, including communication, perception, and control. The recorded log files and video footage documented good strategy execution given the constraints of real-world conditions. Challenges like communication delays, detection errors, and hardware failures impacted in performance but did not prevent the game strategy from making the right decisions for every game situation. The testing showed the viability of the probabilistic play selection, influence maps, and role assignment logic despite imperfect real-world execution. Further refinements to the algorithms and robot systems can be built on these initial results. 100
[36] Log Probabilities. Available online: https://chrispiech.github.io/ probabilityForComputerScientists/en/part1/log_probabilities/ (accessed on 8 September 2023). [37] O’Hagan, A. Bayesian Statistics: Principles and Benefits. Available online: https://edepot. wur.nl/134085 (accessed on 7 September 2023). [38] Wang, Y.; Shenhan, J.; Chen, Z.; Huang, Z.; Xiong, R. Multi-Agent Collaboration for Feasible Collaborative Behavior Construction and Evaluation. 2019. Available online: Available online: https:// www.researchgate.net/publication/336146890_Multi-agent_Collaboration_ for_Feasible_Collaborative_Behavior_Construction_and_Evaluation. [39] Quinlan, J.R. Induction of Decision Trees. Available online: https://hunch.net/~coms-4771/ quinlan.pdf (accessed on 13 October 2023). [40] Song, Y.Y.; Lu, Y. Decision tree methods: applications for classification and prediction. Shanghai Arch. Psychiatry 2015, 27 , 130–135. Available online: https://doi.org/10.11919/j.issn. 1002-0829.215044. [41] Gowda, D.V.; Shashidhara, K.S.; Ramesha, M.; Sridhara, S.B.; Kumar, S.B.M. Recent Advances in Graph Theory And Its Applications. Adv. Math. Sci. J. 2021, 10 , 1407–1412. Available online: https://doi.org/10.37418/amsj.10.3.29. [42] Pereira, N.; Ribeiro, A.F.; Lopes, G.; Whitney, D.; Lino, J. Path planning towards non-compulsory multiple targets using TWIN-RRT*. Ind. Robot. Int. J. 2016, 43 , 370–379. Available online: http: //dx.doi.org/10.1108/IR-02-2016-0069. [43] Kuhn, H.W. The Hungarian method for the assignment problem. Nav. Res. Logist. Q. 1995, 2 , 83–97. Available online: https://doi.org/10.1002/nav.3800020109. [44] Lima, P.; Bonarini, A.; Machado, C.; Marchese, F.M.; Marques, C.; Ribeiro, F.; Sorrenti, D.G. Omni- Directional Catadioptric Vision for Soccer Robots. Robot. Auton. Syst. J. 2021, 36 , 87–102. Available online: https://hdl.handle.net/1822/3173. [45] Lopes, Gil and Ribeiro, A. Fernando and Pereira, Nino, ”Catadioptric system optimisation for omnidirectional Robocup MSL robots”, 2012, Available online: https://hdl.handle.net/1822/ 21158. 107
[46] Webots Reference Manual R2023b: Supervisor. Available online: https://cyberbotics.com/ doc/reference/supervisor (accessed on 20 October 2023). [47] Olthuis, J.J.; Beumer, R.M.; Bogaert, R.v.; Hameeteman, D.M.J.; de Loo, H.C.T.v.; G, M.J.; Molengraft, V.d.; Teurlings, P.; Verhees, E.D.T. Available online: https: //msl.robocup.org/wp-content/uploads/2022/12/Risk_Evaluation_of_ Robot_Soccer_with_Humans_in_MSL.pdf (accessed on 8 October 2023). [48] Kass, R.E.; Vos, P.W. Geometrical Foundations of Asymptotic Inference ; John Wiley & Sons: New York, NY, USA, 1997; p. 14, ISBN 0-471-82668-5. Available online: https://www.wiley.com/ en-us/Geometrical+Foundations+of+Asymptotic+Inference-p-9780471826682. [49] Ribeiro, F.; Moutinho, I.; Pereira, N.; Oliveira, F.; Fernandes, J.; Peixoto, N.; Salgado, A. High accuracy navigation in unknown environment using adaptive control. Volume 5001, pp. 312–319, ISSN: 0302- 9743. Available online: http://dx.doi.org/10.1007/978-3-540-68847-1_30. [50] Barrett, P.; Hunter, J.; Miller, J.T.; Hsu, J.-C.; Greenfield, P. Matplotlib— A Portable Python Plotting Package. 2005. Available online: https://www.researchgate.net/publication/ 234238535_matplotlib_--_A_Portable_Python_Plotting_Package. [51] FIFA Futsal Coaching Manual. Available online: https://cdn1.sportngin.com/ attachments/document/000a-2348966/FIFA_futsal-coaching-manual.pdf (accessed on 6 October 2023). [52] “NumPy Documentation” NumPy documentation - NumPy v2.0.dev0 Manual. https://numpy. org/devdocs/ (accessed on 27 January 2024). [53] “Documentation” OpenCV https://docs.opencv.org/4.x/ (accessed on January 3 2024). [54] “LAR@MSL Strategy: Humans vs. Robots in the Simulator” - https://www.youtube.com/ watch?v=SVYgXKeGaf0. [55] “LAR@MSL Strategy: RoboCup Plays” - https://www.youtube.com/watch?v= 63nJXTCfQEk. [56] Ribeiro, A.F.A.; Lopes, A.C.C.; Ribeiro, T.A.; Pereira, N.S.S.M.; Lopes, G.T.; Ribeiro, A.F.M. ”Probability-Based Strategy for a Football Multi-Agent Autonomous Robot System”. Robotics 2024, 13, 5. Available online: https://doi.org/10.3390/robotics13010005. 108
Appendix A Extra Work While the core focus of the dissertation involves high-level strategy, extra work was equally crucial to allow the robots actually to play football. Ensuring the hardware, electronics and low-level software functioned properly, the game strategy algorithms was a requirement for obtaining usable real-world results. Tasks such as designing the robots’ chassis, building batteries, making the robot’s sportswear and solving other hardware and electronics problems do not directly connect to the dissertation’s main goals but were essential prerequisites. Without this critical ”extra work” to handle the underlying robot capabilities, it would not be possible to participate in the ”Festival Nacional de Robótica” and RoboCup 2023 to effectively evaluate the strategy in a real-world scenario. Computer Protection Chassis Each robot is equipped with a laptop computer enclosed in a protective casing. An aluminium and steel cage was installed on top of each robot to shield the computer from damage. This sturdy metal cage prevents any direct impacts from other robots or objects from reaching the laptop. The cage is mounted to the robot’s aluminium frame as well as the robot’s four main screws. Figure 79 shows the steel cage mounted onto the aluminium frame (a) and the protective computer sponge (b). Additionally, a sponge material surrounds the laptop inside the cage to absorb the collisions. The sponge has two holes to allow proper airflow and cooling of the computer. With this protective enclosure, the vital computers are safeguarded from harm if the robots encounter collisions, as they sometimes do. 109
(a) (b) Figure 79: Laptop computer protection cage: (a) Steel frame; (b) Protective sponge Robot Sportswear As predefined in the rules, every robot needs to have a team identification colour and respective robot number. Sportswear T-shirts were made for every robot in two colours blue and red. Every team needs to have two distinct colours. The only requirement is that the colours presented are saturated. Cooling was considered and so on the sides of every shirt, there are holes to facilitate the laptop airflow. The LAR@MSL robot sportswear is visible in Figure 80. (a) (b) (c) Figure 80: Robot sportswear: (a) Front view; (b) Side view; (c) Back view 110
Batteries The robots are powered by lithium-ion batteries with a voltage of 24 V that were built by the team due to budget constraints. Specifically, the batteries utilise 18650 lithium-ion cells, each containing twelve cells configured six in series and two in parallel. The individual 18650 cells have a rated capacity of 3200 mAh, so each full robot battery has a total capacity of 6400 mAh. The maximum continuous discharge rate for the 18650 cells is 0.5 C, which equates to 3.2 A continuous draw per battery. For a short duration, the cells can handle pulse discharges up to 3.25 C or 20.8 A per battery. With this battery configuration and the capabilities of the 18650 cells, each robot can operate for extended periods within the continuous current limit while still having the pulse power capacity required for peak demands. The parallel grouping of the cells allows them to deliver sufficient current. The 18650 lithium-ion cells in each robot battery are connected using magnesium strips that were soldered together via spot welding visible in Figure 81 (a) and (b). (a) (b) Figure 81: Battery soldering process: (a) Spot welding; (b) Magnesium strips The completed batteries do not contain internal Battery Management Systems (BMS). However, connectors were added to each individual cell to allow for cell balancing during charging, Figure 82 (a). The battery charging stations contain the necessary BMS circuitry to charge the batteries while monitoring and balancing each cell. Once assembled, the batteries are covered in heat-shrink tubing to protect the cells and connections. This heat shrink tubing insulates and isolates the battery while also providing a clean, streamlined exterior, Figure 82 (b). 111
(a) (b) Figure 82: Battery elements: (a) Battery Management Systems (BMS) connector; (b) Protective heat shrink tube To further protect and isolate the robot batteries, custom 3D printed cases were created for each one. These cases are numbered to correspond with their respective robots, visible in Figure 83 (a). Additionally, the cases each contain a small display screen that shows the current charge percentage and voltage of the battery, Figure 83 (b). This allows the battery status to be monitored. The cases also have a rail built into them, with the robots containing the inverse rail, Figure 83 (c). This rail system enables the batteries to seamlessly slide into place when inserted into the robots, preventing any backward connections. It also locks the batteries firmly in position during operation, preventing hazardous movement inside the robot body. (a) (b) (c) Figure 83: Battery 3D printed parts: (a) Case with robot number; (b) Monitoring screen; (c) Sliding rails 112