Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rubberazer/darkpaw_motion_opencv
A little project in C/C++ for the Adeept Darkpaw robot
https://github.com/rubberazer/darkpaw_motion_opencv
adeept csrt mongoose mpu-6050 opencv opencv4 pca9685 pid-controller pigpio raspberry-pi-camera robotics-programming tracking ultrasonic-sensor-distance video-streaming web-server
Last synced: about 1 month ago
JSON representation
A little project in C/C++ for the Adeept Darkpaw robot
- Host: GitHub
- URL: https://github.com/rubberazer/darkpaw_motion_opencv
- Owner: Rubberazer
- Created: 2021-03-02T19:51:34.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2024-05-25T12:49:45.000Z (7 months ago)
- Last Synced: 2024-11-13T20:08:48.386Z (about 1 month ago)
- Topics: adeept, csrt, mongoose, mpu-6050, opencv, opencv4, pca9685, pid-controller, pigpio, raspberry-pi-camera, robotics-programming, tracking, ultrasonic-sensor-distance, video-streaming, web-server
- Language: C++
- Homepage:
- Size: 235 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Darkpaw_motion_opencv
A little project in C/C++ for the Adeept Darkpaw robot.[Playing](https://github.com/Rubberazer/Darkpaw_motion_opencv/assets/47650457/d74e66f9-015d-43ed-9e28-c8865e67b35d)
Basically replaced the original maker's python code by my own C code -with a pinch of C++ for the OpenCV thread, I am using OpenCV to first detect and then follow objects. I added an ultrasound sensor (the usual HC-SR04) as there were empty slots in the robot HAT, so it doesn't hit the walls. At the moment the robot can move: forward, backward, turn right and left totally fine, is able to detect, track and follow objects. It also incorporates a MPU6050 gyroscope & accelerometer that comes with the kit, at the moment those values are stored along with the distance measured by the ultrasound sensor in a csv file with a time stamp. Version 3 also incorporates a web server.
08/03/2021: Added PID regulator to compensate drifting and to steer the robot, working with the gyroscope data as feedback to the PID.
11/03/2021: Added an OpenCV MOG2 background substractor and a tracker, currently using a CSRT but it could be easily replaced, the background substractor detects movement and focuses on the biggest area to pass that rectangle to the tracker so it gets initialized, it works. FPS are rubbish but still is able to follow slow motion objects e.g passing hand.
14/03/2021: The robot is finally able to follow the detected object, the magic is broken when the CSRT threshold is crossed and from that point the robot falls back to motion detection until it finds a new target to track, in the mean time the robot stops.
28/03/2021: Added an embedded web server based on Mongoose, now the robot streams video straight from its camera marking (blue rectangle) the tracked object. Unfortunately the workload finally broke the camels back and it starts to show that the Rasperry 4 is just too short, future potential optimization is required, probably switch from a CSRT to a MOOSE tracker.
10/04/2021: Probably last version, some cleaning, closing threads properly and tidying up in general. Kept the CSRT tracker and solved some recurrent exceptions thrown by OpenCV, mostly to do with capturing out of frame.
The robot itself can be found here: https://www.adeept.com/adeept-darkpaw-bionic-quadruped-spider-robot-kit-for-raspberry-pi-4-3-model-b-b-2b-stem-crawling-robot-opencv-tracking-self-stabilizing_p0125_s0035.html
It is a cool toy and the provided HAT supports connecting some additional stuff if you wanted too, I equipped it with a Raspberry Pi 4 with 8 Gigas so it is (almost) enough for the OpenCV stuff, as a basis to control the GPIO I am using the famous PIGPIO library wich always works first time, really good stuff that can be found here: http://abyz.me.uk/rpi/pigpio/
Embedded web server is built using the famous Mongoose, version 7.2 that can be obtained here: https://github.com/cesanta/mongoose/releases
OpenCV 4.5.0 (or any other version) can be obtained here: https://github.com/opencv/opencv
[
First Version
](https://github.com/Rubberazer/Darkpaw_motion_opencv/tree/main/First_version)Detects moving objects and once detected it tracks (and follows) them
Files: 2_darkpaw.cpp, makefile
Compile: type 'make', pigpio and opencv libraries should be installed previously
Execute: sudo ./darkpaw[
Second Version
](https://github.com/Rubberazer/Darkpaw_motion_opencv/tree/main/Second_version)
Detects moving objects and once detected it tracks (and follows) them, this version also incorporates a web server for video streaming.
Files: 3_darkpaw.cpp, makefile, web_root folder
Compile: type 'make', pigpio and opencv libraries should be installed previously, also mongoose.c and mongoose.h are required
Execute: sudo ./darkpaw
[Latest @ main
](https://github.com/Rubberazer/Darkpaw_motion_opencv)
Same functionality as 2 but terminating threads properly, cleaning up comments and tidying up a bit, all files hanging from 'main' in the repository
Files: 4_darkpaw.cpp, makefile, web_root folder
Compile: type 'make', pigpio and opencv libraries should be installed previously, also mongoose.c and mongoose.h are required
Execute: sudo ./darkpaw