This library supports various similar cheap chinese copters that are controlled via WiFi and have a camera on board. Currently, the SG500 and the JJRC blue crab drones are supported.
It is written in C++, and Python 3 bindings are available. Also, a ROS node is available for utilizing these drones with the Robot Operating System.
The goal of this library is to support controlling the drone as well as retrieving telemetry information and the video stream for further use in the OpenCV library.
For a C++ example, see here.
Below is an untested python example:
#!/usr/bin/python3
import libcopter
import cv2 # opencv
copter = libcopter.SG500()
copter.initialize()
# If your drone is new, you need to calibrate it first.
# copter.recalibrate()
copter.takeoff()
while True:
copter.command(0.5,0,0,0) # go right
imgs, _ = copter.poll_data()
if len(imgs) > 0:
cv2.imshow("img", imgs[-1].frame)
copter.land()
Currently, I'm still reverse engineering the drone. Most I've already figured out, but there is still some way to go. Find my reverse engineering attempts here.
There's a python script that can generate steering packets and can successfully take-off and land the copter.
Also, there's a video stream parser written in C++ that splits the stream into telemetry data and a video stream and parses both.
My (new) drone keeps flying upwards until it hits the ceiling
and is uncontrollable. This is not a libcopter problem. You
have to recalibrate()
your drone first. The calibration
data seems to persist over drone reboots.