Andrew’s Status Report for March 09, 2024

This week consisted of: refining the cue stick system, creating the local application, and testing the projector output system. When I began building the cue stick system, I realized that the Arduino Nano was redundant since the ESP32 acts as a microcontroller just augmented with WiFi/Bluetooth. The first version of this module utilized only the Arduino Nano and was wired. Because this was a lot easier to set up, I built the V1 of our cue stick system with just the Arduino Nano to test functionality. Once I verified it was working, I replaced the Arduino Nano with the ESP32 module. It works by acting as a server accessible through WiFi on a specified localhost port. When endpoints “/accel”, “/gyro” are queried, I construct an HTTP request containing accelerometer and gyroscope data respectively.

This leads into the local application. I built a first version of the webapp using React/Flask. The Flask backend acts as a sort of lightweight storage for the webapp. It routinely polls the ESP32 module fetching recent gyroscope and accelerometer data. It stores it in a local SQLite database and returns paginated data to the React frontend when requested. I initially created this Flask backend because I didn’t think WiFi speeds were fast enough to accommodate how much data we were going to receive per few milliseconds/seconds. However, just by running back-of-the-envelope calculations on typical WiFi router speeds, it might be possible to do away with the entire backend and poll the ESP32 module directly actually. Though an argument to be made for keeping the backend is to eventually integrate it with the physics engine, in which we would need storage or more complex behavior. I also tested the projection system and had to modify the coloring scheme. It turns out the projector is too weak in well-lit environments, so you have to use only black and white in the projection to have enough contrast to be clear and visible.

My progress this week is on-schedule. For next week, I hope to flesh out the webapp more by building an intuitive, user-friendly display for the accelerometer, gyroscope data for the web application. I’m also integrating the camera feed to the web application.

Andrew’s Status Report for February 24, 2024

This week the parts we ordered this week arrived. Since I’m in charge of the cue stick system, I integrated the IMU, Arduino Nano, and ESP32 WiFi module together which will all be attached to the cue stick directly. We will be using the IMU to gather data on both acceleration and orientation (pitch, roll, heave). For our first version, we are simply using the accelerometer to let the player quantify how fast/hard they are hitting and give them recommendations from that. Additionally, the gyroscopic data is currently only being used for telling the player whether they are holding the cue stick in the right orientation to hit the ball’s center. I wrote a first version of the IMU module which takes both this data and the gyroscopic data and streams it via the ESP32 module to the webapp that’ll be hosted on our laptop. If we have more time towards the end, we will look into integrating the gyroscopic data with the physics engine in order to account for more complex shots involving ball spin. Tjun Jet and I also looked into computing ball collisions in the physics engine and have a good idea of how the physics work for any general collision involving two balls now. I’d have liked to have more accomplished by this week, but I fell ill/still am a bit sick (as of writing this) and wasn’t able to accomplish much more. I’m hoping to be able to do more in the following week when I’m hopefully recovered.

Andrew’s Status Report for February 17, 2024

This week I finished up the AprilTag module. I modified an existing AprilTag library, extended it, and provided an API that detects AprilTags within an image and creates a coordinate plane with it. This allows the computer vision The AprilTag module is written in C/C++ and Python. I also wrote some unit tests, documented the usage of this AprilTag API, and handed it off to the rest of my team.

After this, I looked into the hardware components we need to assemble this system together. For detecting pool stick motion and player behavior, I decided on an Arduino Nano + 9DOF IMU + ESP32 module. This encapsulates the motion processing system. The Nano gets data from the IMU, then streams it to our laptop via the ESP32 module over WiFi. I also wrote some of the motion detection software for Arduino, though I don’t have a chance to test it on hardware until the parts arrive.

I also started writing code for our projection system (projecting our predictions onto the actual pool table). Currently, the predictions are outputted as lines drawn onto an image/frame of the pool table. I wrote out v1 of the projection system which currently just displays each frame live as the projection system outputs them. I’m going to improve on this by just displaying the trajectories and being able to automatically calibrate the projector by scaling the image size up and down depending on the AprilTag coordinates.

Andrew’s Status Report for February 10, 2024

This week, I was primarily focusing on figuring out the AprilTags for our pool table. We planned to use AprilTags on the four corners of the pool table for camera normalization, and we also want to use these AprilTags to construct a 2D coordinate system. We don’t have the AprilTags yet, but much of the software can be written first without having physical AprilTags.

I looked around different Python libraries and repositories and found a few resources for detecting AprilTags. After testing out a few of them and tinkering with the code, I managed to get AprilTag detection working for my laptop’s live video/camera:


Screenshot of  my laptop’s camera feed

It runs primarily on OpenCV but makes use of an open-source AprilTag detection library written in C by researchers from the University of Michigan. Their library also returns a list of metrics and coordinates, which I then process into a 2D coordinate plane with one of the AprilTags being the origin (0, 0). When we eventually port this onto a pool table, we should be able to easily create the coordinate plane.

I also did some research on transmitting data from the pool table camera to our video processing server. We decided on having a camera attached to a microcontroller with an ESP32 card. After some testing, we determined that transmitting frames over Wi-Fi via HTTP was sufficient.