Turboshrimp is a clojure library for communicating with and controlling the Parrot AR.Drone.
It supports the following:
- Flight control.
- Telemetry (including video and GPS).
- Runs on Android, using clojure-android.
This simple example connects to a drone, tells it to take off, and prints the battery level:
(require '[com.lemondronor.turboshrimp :as ardrone])
(def drone (ardrone/make-drone))
;; Connect to the drone.
(ardrone/connect! drone)
;; Tell the drone to being sending us detailed telemetry.
(ardrone/navdata-demo drone true)
;; Tell the drone to take off.
(ardrone/takeoff drone)
;; Check the battery level.
(println (get-in @(:navdata drone) '[:demo :battery-percentage]))
This example shows how to process telemetry updates from the drone as they arrive:
(require '[com.lemondronor.turboshrimp :as ardrone])
(defn process-event [event-type data]
(when (= event-type :navdata)
(println "Position:" (get-in data [:demo :drone :camera :translation]))))
(def drone (ardrone/make-drone :event-handler process-event))
(ardrone/connect! drone)
(ardrone/navdata-demo drone true)
There is an example of using the library to create a simple ground control station with keyboard control and live video with an overlaid HUD: examples/controller.clj
You can run the example like this:
# lein with-profile example run -m controller > debug.log
(Hey look, it's Ralph & Dottie!)
Here's a video of the HUD in action: https://www.youtube.com/watch?v=2mOtoYUoiWI
Once the controller has started, you can use the following controls:
Key | Command |
---|---|
t | Take off |
l | Land |
w/a/s/d | Forward / turn left / backward/ turn right |
shift-a/d | "Strafe" left / right |
q / z | Climb / descend |
c | Switch to forward-facing camera |
v | Switch to downward-facing camera |
Shrimpdroid is an Android app that uses turboshrimp to let you fly a drone with your phone.
See Turboshrimp API documentation.
$ lein test
-
Flight control works.
-
Telemetry works--even GPS!
-
Video works. I've tried two different H.264 decoders:
-
turboshrimp-h264j uses the pure Java h264j decoder. h264j is a little slow and has some color glitches and occasional errors.
-
turboshrimp-xuggler uses the xuggler decoder, which uses native code. It's almost twice as fast as h264j and its output appears to be perfect.
-
-
It runs on Android. I don't check every commit, but I do periodically test on Android. This code has flown a drone on an Android phone.
This code was originally forked from the awesome work gigasquid/Carin Meier did with clj-drone.
My changes are mostly about turning the code into a full-featured library for writing drone applications (similar to node-ar-drone), with the following specific goals:
-
Keeping the focus on straightforward drone control: I removed the OpenCV dependency and the goal/belief-driven programming API. Those are good things, but I think they should be in separate libraries.
-
Enhancing the ability to control multiple drones and receive telemetry from multiple drones: Replacing single, global vars with per-drone data structures.
-
Adding a clean way for applications to process drone telemetry, and parsing the full set of navdata options from the drone: GPS, magneto, vision, etc.
-
Android compatibility. I want to be able to use this code on Android using Clojure on Android.
-
Handle blocking config commands and multiconfig (see felixge/node-ar-drone#76).
-
Make sure errors and other events are handled correctly and consistently.
-
Make it easier to tell if the drone is connected or disconnected.
Copyright 2014, 2015, 2016 John Wiseman jjwiseman@gmail.com
Distributed under the MIT License.