The program uses computer vision library of Python to detect people. Distance, angle, and identity are identified. Once this is done, the main motor starts running, and stops at the angle that will enable the candy to be launched at the person.
Version 1 video
Encoders are sensor that can be used to detect the direction, speed, and angle of a motor.
Initially, this project was designed with the idea to use stepper motors to drive the system, but this ended up being scrapped due to the low velocity typically reached by motors under NEMA 27, and under expensive, speciailized, motor drivers.
(Motor) encoders use a variety of methods to collect data. The encoders I used were quadrature encoders. The encoders output two square waves, A and B. By analyzing the square waves, data can be colllected about the motion of the motor.
In the above video, the cummulative angle is printed to the console using the encoder.
To program the encoder reading, the encoder class of gpiozero was used. This class handles the initialization and reading of the values.
OpenCV is a popular computer vision and machine learning library. It is primarily used in Python, but is also used in C++, MATLAB, and Java(the worst by far).
The purpose of using OpenCV is to recognize humans and return effectively a list of their coordinates. With this, the program can calculate the launch angle and whether or not the person is too far (using bounding boxes).