In this project, we build a robot system to play air hockey.

For the robot mechanics, we use an H-Bot gantry setup commonly used in DIY printers to move to robot pusher to any X-Y coordinate within the robot's play area. Two Nema 17 stepper motor control the XY motion of the gantry as follows:
- both motors clockwise: pusher moves right
- both motors counterclockwise: pusher moves left.
- right motor clockwise, left motor counterclockwise: pusher moves upwards
- right motor counterclockwise, right motor clockwise: pusher moves downwards
The logic for motor control is implemented on the Raspberry Pi Pico. Each motor is connected to a microstep driver which is connected to the Pi Pico.
For autonomous control, we use the iPhone camera to livestream the table to a python program running on PC. The program uses OpenCV with color thresholding to processes the frames from the camera. It determines the position of the yellow puck and the green pusher and calculates the appropriate move to vertically align the pusher with the puck. It sends the move to the Pi Pico motor control program through a USB connection, and the Pi Pico executes the motor control.
The demo code files can be found at https://github.com/abdulkarim-mugisha/puckman