Week 22. Jan 28.Feb 1 2019 - michelle-qin/Portfolio GitHub Wiki
I'm continuing to work on the combination board - the M4 Express Feather, Servo, and Stepper adafruit boards. Last week, I connected a servo motor to the servo board and attempted to get a twitch out of it. Unfortunately, nothing happened last week. This week, I worked with mentor Nikolai and what we found was if we inputted each line of my code into the serial console, the servo motor moved. However, the code itself in the main block of the text editor is not being read when it's run (I even added in print statements and got zip out of it). Nikolai and I were looking into the UF2 Bootloader and it's still a mystery to be solved -- seems much more complicated than expected.
Fixed the issue! Here's the experience:
- Yesterday (Monday, 1/28), I talked with Mr. Miller about the issue and he did some research to look into it. What he found was a ReadMe file on the Adafruit_CircuitPython_ServoKit repo that stated there were 3 dependencies the driver replied on. I looked into the files on the CircuitPy drive and realized that I had only 1 of the dependencies on there - I needed to bring in the other 2.
- I tried to download the other 2 on the drive but encountered an error because there was very room left on the drive. After lots of trials trying to delete random files on the library and encountering protest from the board, I worked with Ken who found a large file named "examples" on the drive that we could completely erase. After deleting that file, there was enough room to download the other 2 dependencies.
- Note: Something that I learned. When downloading files from Adafruit's GitHub page to bring onto the drive, I would clone the files into my Downloads and drag them onto the drive from there. While functional, this wasn't the most efficient path. I learned that to direct the git bash to the drive you use this line: cd /D in this case, the file was named CIRCUITPY (D:) From there, you can directly clone files into the drive.
- After getting the necessary dependencies, we were still encountering issues - the servo motor would not move. We went though some trial and error, resetting the board (which fixed a serial monitor issue) and looking through some Adafruit documentation/tutorials.
- Finally, on one of the Adafruit documentation, we found this line "To edit code, open the code.py file on your CIRCUITPY drive into your editor." Currently, we were running our code on a file named "main.py" We loaded the code from our "main.py" file into a file named "code.py" and it worked!
While a tedious process, I learned a lot and gained very supportive mentorship from Ken, Mr. Miller, Nikolai, and Mr. Harlow!
My code for moving the servo:
from adafruit_servokit import ServoKit
from time import sleep
kit = ServoKit(channels=8)
while True:
kit.servo[0].angle = 0
sleep(2)
kit.servo[0].angle = 0
sleep(2)
Now that the servo motor is working, my next goal is to operate the servo motor with a proximity sensor. I was told that another student will solder a proximity sensor to the board sometime so hopefully I can do that soon!
Useful Note: Here's what the colors and blinking mean:
- steady GREEN: code.py (or code.txt, main.py, or main.txt) is running
- pulsing GREEN: code.py (etc.) has finished or does not exist
- steady YELLOW at start up: (4.0.0-alpha.5 and newer) CircuitPython is waiting for a reset to indicate that it should start in safe mode
- pulsing YELLOW: Circuit Python is in safe mode: it crashed and restarted
- steady WHITE: REPL is running
- steady BLUE: boot.py is running
The proximity sensor was added on but it experienced some shorting which fried the board, making it unusable. We just ordered a new board so I'll get back to this next week!
Starting on a new project... Kinetic Maze. The Kinetic Maze is a large circular maze that moves according to the user's body movement. We want to program a camera that is compatible to raspberry pi to replace a Kinetic that can detect human body movement. Thus far, I've been doing research for this - check the links I found below!
KINETIC MAZE LINKS (Detecting human body/movement skeleton with raspberry pi)
- Deep Learning based Human Pose Estimation using OpenCV ( C++ / Python ): https://www.learnopencv.com/deep-learning-based-human-pose-estimation-using-opencv-cpp-python/
- Code from article above: https://github.com/spmallick/learnopencv/tree/master/OpenPose
- Camera Module V2: https://www.raspberrypi.org/products/camera-module-v2/
- Flex Cable for Camera Module V2: https://www.adafruit.com/product/2144?gclid=EAIaIQobChMI0_DX58yW4AIVg7lkCh2E2wyuEAYYAiABEgKs9_D_BwE
- Raspbian Stretch: Install OpenCV 3 + Python on your Raspberry Pi: https://www.pyimagesearch.com/2017/09/04/raspbian-stretch-install-opencv-3-python-on-your-raspberry-pi/
- Detect a person's motion and identify his body parts moving forward towards camera on Android: https://stackoverflow.com/questions/38519366/detect-a-persons-motion-and-identify-his-body-parts-moving-forward-towards-came
- Code for android motion detection: https://github.com/phishman3579/android-motion-detection
- Video (Human body skeleton detection and tracking using OpenCV): https://www.youtube.com/watch?v=OfDdNv-bMBo
- Presentation (HUMAN BODY SKELETON DETECTION & TRACKING): https://prezi.com/gc3be0nmd9zi/human-body-skeleton-detection-tracking/#_=_
- Video (It's Triggy! | Body Tracking with Python (OpenCV2 Library)): https://www.youtube.com/watch?v=gPeeFCvJOWA
BALL TRACKING
- Code: https://pastebin.com/nrh2xNNT
- Raspberry Pi Ball Tracking: https://www.instructables.com/id/Raspberry-Pi-Ball-tracking/
EXTRA STUFF:
- Face tracking: https://www.instructables.com/id/RasPi-OpenCV-Face-Tracking/