Table of Contents
Table football, commonly known as foosball or table soccer, is a fast-paced game inspired by association football. Players aim to score goals by maneuvering rods with miniature figures representing football players from two opposing teams. While typically enjoyed by 2-4 players, traditional foosball is not designed for solo play.
This project seeks to develop a foosball table playable by a single player using an Arduino Uno microcontroller. The system will allow one side of the game to be automated and controlled via a computer program, while a human player operates the other side. The automated system will manage two axes of movement for each rod: rotation and linear displacement.
However, to simplify development and reduce costs, the prototype will use a smaller-scale foosball table with two rods per side instead of the standard four. This scaled-down design reduces system complexity and enhances motor responsiveness, making it more suitable for our project goals.
Admin
: Contains images used in the READMECAD
: Contains all the CAD stl files as well as the dxf files for lasercuttingHardware
: Contains the electronic circuit diagram and a document with hardware component specificationsSoftware
: Contains all the codeSoftware/Algorithms/followBall
: Contains the Arduino code for controlling the motors and handling the game logicSoftware/Camera/cv/python-webcam
: Contains the python code for the computer vision as well as the QR Markers to printout
video.mp4
You will need to buy:
- 4 17HS4401 Stepper Motors
- 4 A4988 Motor Drivers
- 4 End stop Sensors
- 1 Arduino Uno
- 1 USB cable to connect to the Arduino
- 1 CNC Shield
- 1 USB Isolator
- 1 Logitech Webcam C270
- 2 Aluminium Profile 20 x 20mm of length 410mm
- 1 12V Power Supply
- 1 Power Supply Plug
- 2 ~1 meter GT2 6mm belt
- 1 1 meter WS2813 LED Strips
- 1 Bread board
- 2 Metal Bars with diameter 15 mm length 1200__mm
- 2 Metal Bars with diameter 8 mm length 1200__mm
- 4 Ball Bearings that allow for both rotational and linear motion
- 8 Wheels (Something like this)
- 2 Pully
- Jumper cables
- 1 ball
To assemble you also need the following
Pole Components:
- 48 M3 screws with nuts, length 8mm
- 12 M2.5 screws with nuts, length 12mm
- 2 M4 screws with nuts, length 16mm
Mechanical Components:
- 14 M3 screws with nuts, length 8mm
- 2 M3 screws with nuts, length _25_mm
- 16 x M2.5 screws with nuts, length 8mm
- 2 x steel bars, diameter 4mm, length 3.2mm
- 2 x steel bars, diameter 4mm, length 2.2mm
have access to:
- 3D printer with TPU filament
- 3D printer with PET filament
- Laser cutting machine
- PlexiGlass 10mm
- MDF board 3mm
- MDF board 4mm
- MDF board 5mm
- MDF board 10mm
- Driller
- Bunch of different screwdrivers
- Soldering kit
- Lasercut
- 3D Print
- Assemble the Table
- Wire up the motors to the Arduino
- Set up the Camera Vision
Lasercut with the right MDF thickness (is in the file names): DXF files
3D Print the following pieces from the CAD:
For 3D printing of Pole Components: STL files
- 4 x Players with 15mm radius (Computer Controlled) -> Perimeter 6
- 4 x Players with 8mm radius (Human Controlled) -> Perimeter 6
- 2 x GardianStop 15mm radius -> Perimeter 2
- 2 x GardianStop 8mm radius -> Perimeter 2
- 4 x Bumpers with 15mm radius -> Perimeter 2
- 4 x Bumpers with 8mm radius -> Perimeter 2
- 8 x Bushing with 15mm radius -> Perimeter 3
- 8 x Bushing with 8mm radius -> Perimeter 3
- 2 x Handles -> Perimeter 5
- 2 x End Caps 8mm radius -> Perimeter 3
- 2 x End Caps 15mm radius -> Perimeter 3
For 3D printing of Mechanical Components: STL files
- 2 x Standing Motor holder -> Perimeter 2
- 2 x Rotation Motor holder -> Perimeter 2
- 2 x Motor to Pole Connector -> Perimeter 5
- 2 x Railing holder without pulley -> Perimeter 2
- 2 x Railing holder with pulley -> Perimeter 2
- 2 x pulley -> Perimeter 2
- 2 x wheels (to put at the end of the belts) -> Perimeter 2
- 4 x Belt to motor Platform Connector -> Perimeter 5
Our 3D printing steps: Use Fusion 360 to create and edit the pieces
Open Prusaslicer to prepare pieces for impression:
- Select Filament PETG
- Select Printer MK4 with 0.4 nozzle or i3 MK3S & MK3S+
- Select Print Setting 0.20mm QUALITY
- Place and add necessary supports to print out pieces correctly
- Edit the perimeter of the pieces for more resistance if needed
- Slice and Print
For the Bumpers: Open Prusaslicer to prepare pieces for impression:
- Select Filament NinjaTek NinjaFlex TPU
- Select Printer i3 MK3S & MK3S+
- Select Print Setting 0.20mm QUALITY
- ! don't use supports
- Place pieces and Slice
- Add glue to printing bed
When slicing be careful of the surface on which you print your pieces, to ideally minimize supports needed or place them in a smart way.
- Glue all the mdf pieces together with wood glue
- Add ball bearings and screw bushings
- Insert poles in one bushing and add the bumpers, add players with a spacing of 184mm between player/gardianStop, add gardianStop
- Insert poles into second bushing and add endcaps and handles
- Follow picture in Final Result to finish assembly
For ball reception place the following way
CNC shield mounted on top of the Arduino Uno , reset buttons should be aligned
CNC shield-Arduino Uno pin correspondance
When installing the A4988 Motor Drivers set the voltage in alternate current to 1.2V by turning the screws and using a multimeter.
On the CNC Shield there are 3 slots for motor drivers labelled X, Y, Z, A. In the picture below you see to which motor they should be connected to.
The End stop sensors have three cables that need to be connected, one to the ground, one to the 5V Power and one to the correct pins on the CNC Shield. The mapping of the position of the end stop sensors to the pins on the CNC Shield are shown in green in the picture below.
Always connect the Arduino via a USB-Isolator to your laptop and ideally don't charge your laptop while it is connected to the Arduino. It is also important that you unplug the power and the Arduino before changing anything on the wiring or manually moving the motors. Generally it is also advised to disconnect the power and the arduino whenever you're not using them. Also note that the motor drivers on the CNC shield might head up a bit if used for a long period of time.
You need to have Arduino IDE installed, as well as the libraries
- Open the code for the Arduino in
/Software/Algorithms/followBall/followBall.ino
- Connect the Arduino via the USB Isolator to your laptop
- Press the upload button in the top left of the Arduino IDE
- If you get a compilation error, check whether you have all libraries installed.
- If you get an error while uploading, check whether you have selected the right board and port and try again.
- If the motors don't move check your wiring. If that doesn't help check the voltage of the motor drivers using a multimeter. Also the documentation of the CNC shield might help.
You need to print out the 4 QR Code Markers stored in the file
/Software/Camera/cv/python-webcam/ArUco markers.pdf
and cut them out.
You then have to tape the QR Codes into the Right corners. Note that the top left corner, marked red in images below, should always point towards the corner. The QR Codes are numbered (see below) and they need to be in the right corners, according to the image below.
It is important that the Codes are at in the right corners and oriented the right way! Otherwise the camera vision will not detect the playing field correctly and do a weird transformation or cut of some part.
The code for the Camera Vision is located in the folder
/Software/Camera/cv/python-webcam/main.py
You need to have python installed on your computer (See here an article how to install python). You als need the following libraries:
If you are on linux or macOS and have pip installed you can simply run
pip install pyserial
pip install opencv
If you're having trouble, check with your package manager whether it accepts pip installs.
Note that you have to close all Serial monitors in the ArduinoIDE since it prevents the computer vision from opening the port. You can open it again when the computer vision is running. 2. Plug in the Logitech webcam,
- Plug in the Arduino UNO,
- Navigate to folder
Software/Camera/cv/python-webcam
, - Run
./main.py
.
If you want to know how to use different flags, type ./main.py --help
.
By default the camera should open a window called Output which displays the area in which the ball can be detected. If the ball is detected, there should be a blue circle around it.
- If the camera is not activating properly, try changing the parameter of the call to the
cv2.VideoCapture
function to another number (usually 0 or 2). You can also use the-i
flag for that. - If the camera vision does a weird transformation then the QR Codes are not placed in the right corners.
- If the output doesn't show the entire field, then the QR Codes might not be oriented correctly (Top left corner ins't pointing towards the corner).
- If the ball isn't detected then you might need to change the allowed range for the radius (line 37 in
main.py
). By default it is set to accept radius between 25 and 31. This works well for us on Macbooks but we observed that on Linux a range of 10 to 15 is appropriate. - If the code has a problem uploading to the arduino try doing the following (sometimes the port has a problem):
- Stop the computer vision
- Make sure you have no serial monitor open on the arduino ide and close all other sketches
- Plug in the arduino uno again and upload the code
- Start the computer vision again
Remember that you can use different flags to debug the computer vision. For example you can display views of different stages of computer vision (Marker detection, image transformation, etc.) using the --w or --windows flag or you can disable the Serial output if no Arduino is connected by using the -n or --no-ser-out flag.