Closed Amene-Gafsi closed 4 months ago
I planned to start implementing a task to make the paddles wait until the ball is close enough before moving to the correct position to hit it. However, I can't proceed with this until the final setup is complete and we determine the paddles' speed. Currently, we are all focused on increasing the gear radius to enhance the motors' speed. Once this is accomplished, I will proceed with the implementation.
Let's recall what I already did :
Camera calibration is working perfectly. I've made further improvements since initially, if a paddle obscured a marker at the start of the game, we had to move it manually. I added a feature to the code that checks which marker is hidden and then moves the corresponding paddle accordingly.
Paddle calibration is also performing excellently. I enhanced it by switching from detecting red rectangles to red triangles, which has resulted in better accuracy.
Ball and Paddle detection: Everything is working perfectly.
Goal detection: This is functioning flawlessly.
Ball Trajectory Prediction: Initially, we had an algorithm from the start of the semester that we couldn't test due to malfunctioning motors. Once the motors were operational, we tested the algorithm and found it had accuracy issues. I then experimented with a different approach using a machine learning model—Linear Regression—to identify the line that best fits through all the previous ball coordinates points. Although this was accurate enough, it introduced latency issues, which are problematic for a fast-moving ball. I finally settled on a simpler algorithm using numpy, which balances accuracy and low latency effectively. I also enhanced the system by drawing a line on the frame to show the prediction and by calculating the speed of the ball using the timestamps of each captured position. This calculation allows us to predict when the ball will reach the end of the board. Using this timing, we send a move command to the motors at precisely the right moment.
Task: Calculate and send the precise position and timing to the motors to ensure they strike the ball at the optimal moment