Programming

Concept

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

What are encoders?

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.

Difficulties

  • Since the Raspberry Pi's are primarily Linux computers, their read rate is not great. This negatively impacted the accuracy of the values received.

    A decoding chip such as the LS7366R (one of the more simpler ones) can count several hundred thousand more ticks than a Raspberry Pi, but due to it taking a long amount of time to ship (3 weeks on average), it is currently not feasable. I plan to incorporate this in the future.

    The chip mentioned above uses SPI communication protocol to communicate with the Raspberry Pi, enabling high receive rates, significantly higher than the digital I/O pins can provide.

In the above video, the cummulative angle is printed to the console using the encoder.

Programming

To program the encoder reading, the encoder class of gpiozero was used. This class handles the initialization and reading of the values.

OpenCV Object Detection

What is OpenCV?

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).

Purpose

    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).