Download presentation
Presentation is loading. Please wait.
1
Introduction What is this ? What is this ? This project is a part of a scientific research in machine learning, whose objective is to develop a system, based on the existent machine learning algorithms, which will learn to play foosball (table soccer game). This project is a part of a scientific research in machine learning, whose objective is to develop a system, based on the existent machine learning algorithms, which will learn to play foosball (table soccer game). We present now the first part of the project, which does not deal with machine learning at all. This software is a simulator, modeling the foosball environment. It consists of: We present now the first part of the project, which does not deal with machine learning at all. This software is a simulator, modeling the foosball environment. It consists of: The physical model of the game components (field, ball, players, etc.. ) The physical model of the game components (field, ball, players, etc.. ) The graphical user interface (GUI) for a visual representation. The graphical user interface (GUI) for a visual representation. The framework for an agent. The framework for an agent. The first two components are combined into a standalone application that can be used as an engine for development of different foosball agents.
2
The Robotic Foosball m Dynamics – The physics of the application. Graphics – The visualization of the dynamics. Agent – The brains of the application. Data Bank – The data storage of the application. In the real physical system the “Dynamics” and the “Graphics” are unified as the “Plant”.
3
The Project Objective The objective of this project is to build the software simulation of the Plant and provide an interface for the agent. The software simulation is the environment, which serves as the lab for the development of the agent. It is an idealized model of the real foosball table. The simulation consists of 2 independent modules, which communicate using a well- defined protocol. 1.Dynamics - Simulates the physical behavior of the foosball: i.The motion of the ball and the players. ii.The collisions between the ball and the players or the table borders. 2.Graphics – The graphic representation of all Foosball elements: the table, the ball and the players.
4
Agent – Plant Interface Time Stamp The Environment State : Locations and velocities of all the axes, location and velocity of the ball at given time. The Instruction issued by the agent to the foosball model: The desired location and the velocity of a certain axis at a given time.
5
The Fulfillment of an Instruction The simulation works with accelerations as inputs. Need to calculate:Given: X 0, V 0, X F, V F, T Every requirement may be satisfied in this way: The maximum velocity and acceleration are limited: V m <= V max a i <= a max Generally, there is no need to reach V max, while executing the instruction.
6
The Fulfillment of an Instruction Thus, the implementation may be simplified in the following way: If T is an odd number of clock cycles: a1 and a2 are slightly different.
7
The Graphics module Description The coordinates convention is: X-axis – Vertical direction Y-axis – Horizontal direction Z-axis – Out of page plane direction
8
The Graphics module Description The players are drawn using the following method: The players are drawn using the following method: A player is drawn using several rectangles for body parts, and a circle as a head. A player is drawn using several rectangles for body parts, and a circle as a head. The angle of rotation determines which parts of the player are visible. The angle of rotation determines which parts of the player are visible. The visible parts are drawn after the invisible ones. The visible parts are drawn after the invisible ones. Since all the players in a set are rotated simultaneously, the calculations are made only once. The rest of the players are simply shifted along the X-axis. Since all the players in a set are rotated simultaneously, the calculations are made only once. The rest of the players are simply shifted along the X-axis. See the calculations below See the calculations below
9
The Graphics module Description The original vector to be rotated by f about X-axis (orthogonal to the page plane). The result of the rotation.
10
The Graphics module Description In our graphic representation we are interested only in the 2D projection of the player on the XY plane, therefore we don’t need to calculate the coordinate. Obviously, the rotation matrix operator about X-axis is:
11
The Graphics module Description The player model in the application is simplified, as follows: The names on the figure are representing the constants, defined in “config.h” file. * H ead diameter is equal to feet width.
12
The Physics module Description The physical module is responsible for the game dynamics: For each “time slice” the next state is calculated, according to the current state and the applied accelerations. A state is defined by: the positions of the players, their velocities (linear and rotational), the position and the velocity of the ball. Collision detection between the ball and different table elements ( borders, players). Collision affects the current state.
13
1.The The ball does not roll. 2.The ball does not take off the table 3.Players have infinite mass relatively to the ball. 4.The maximum velocity and acceleration are limited. 5.A high constant friction is applied to players’ motion when there are no acceleration instructions. This reflects the behavior of a real system, where the motion stops very fast, after no power is applied. 6.The ball has adjustable elasticity parameter. 7.There is adjustable friction between the floor and the ball. The simulation assumptions
14
The Physics module Description A player kicks the ball:Analysis of player’s tangent velocity: The tangent velocity of a player is derived from his angular velocity. Only the projection of the tangent velocity on the XY plane makes sense, because the ball moves in XY plane only.
15
The Physics module Description - Ball Collision Mechanism 1. Calculate the ball velocity relatively to a table element. 2. Calculate the Normal between the Ball and the table element. Where:
16
The Physics module Description - Ball Collision Mechanism Notes: 1. The table borders are treated as players with fixed locations and zero velocity. 2. The friction and the elasticity factor can be defined within the application window. 3. Find the projection of the relative velocity on the normal. 4. Find the velocity of the ball after the collision. r - Elasticity Coefficient
17
The Physics module Description - Collision Detection Every time cycle the effective shape of each player is calculated. Effective shape is the shape “seen” by the ball, which is derived from the rotational angle and the body parameters of the player. The ball collides with the effective shape of a player. The shape is always a rectangle, because the players’ feet are cubical. Example: if a player is upside down, there is no effective shape at all – the ball doesn’t collide the player. The Effective Shape object calculations: The closest point of the effective shape to the ball. The horizontal (XY plane) velocity of the player. The ball object calculations: Whether the ball will reach any effective shape – the collision detection. If a collision detected, the collision mechanism is activated (as described above).
18
The Agent Framework is a standalone application, which controls the players in the simulation. The agent and the simulation maintain asynchronous communication. The communication is implemented as inter-process Windows messages (on the same machine). Data received from the simulation: current game state. Data sent to the simulation: the desired state of the players Any real agent may be installed within the framework. Currently, the agent simply issues random instructions to the server. The Agent Framework description
19
Known Problems The collision model fails at extremely high velocities, which are beyond the limit. The collision model fails at extremely high velocities, which are beyond the limit. The game state is not updated correctly for extremely short time cycles. The game state is not updated correctly for extremely short time cycles. The agents instructions are applied only to one simulation, even though several simulations run on the same machine. The agents instructions are applied only to one simulation, even though several simulations run on the same machine.
20
Future Enhancements Better collision model Better collision model Three dimensional game – the ability of the ball to take off the table. Three dimensional game – the ability of the ball to take off the table. Take in.to account the ball spin Take in.to account the ball spin Provide more flexibility of the simulation parameters. Provide more flexibility of the simulation parameters. Optimize the performance. Optimize the performance. Port the simulation to another platforms. Port the simulation to another platforms.
21
Tools used The software is developed on Microsoft Visual C++ platform for MS Windows. Fully object-oriented. MFC tools and libraries are used (mainly - for GUI) Tested operating systems: Windows 2000/NT/XP
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.