epfl-cs358 / 2024sp-robopong

1 stars 0 forks source link

Test the CV code on the real system #36

Closed Amene-Gafsi closed 5 months ago

Amene-Gafsi commented 6 months ago

I successfully tested the computer vision code on the actual system, and it worked flawlessly. Here's a summary of the process:

  1. Camera Calibration: Initially, I calibrated the camera to accurately track the ArUco markers. This step ensures that all subsequent operations use the calibrated frame for precise computations.

  2. Coordinate Transformation: After camera calibration, I transformed the coordinate system to align with the calibrated frame, which is crucial for accurate tracking and positioning.

  3. Motor Calibration: I then calibrated the motors connected to the Arduino. This involves sending commands to move Motor 0 or Motor 1 up or down until it reaches its edge limit. Upon reaching this limit, I send a 'stop' command to the Arduino, which then records this position as the maximum or minimum boundary. The motors are prevented from moving beyond these set limits.

  4. Boundary Definition: Once all four corners have their boundaries saved, the system is ready to track the ball's coordinates.

  5. Ball Tracking and Motor Control: Based on the ball's position, I send commands to each motor to adjust its position to hit the ball effectively.

  6. Goal Detection System: In parallel, I implemented a system to detect goals. If the ball is close enough to a paddle and then disappears from view for three consecutive frames, the system sends a 'goal 0' or 'goal 1' signal to the Arduino.

This entire setup performed perfectly during my tests.