com.lemondronor.turboshrimp

Control and telemetry library for the AR.Drone 2.0.

By John Wiseman / jjwiseman@gmail.com / lemonodor

animate

(animate name duration)

Commands the drone to perform a flight animation.

name is a symbol specifying a valid flight animation. duration is the duration of the animation in milliseconds.

Example:

(animate my-drone :yaw-shake (default-animation-duration :yaw-shake)

These are the valid flight animations: :phi-m-30-deg, :phi-30-deg, :theta-m-30-deg, :theta-30-deg, :theta-20-deg-yaw-200-deg, :theta-20-deg-yaw-m-200-deg, :turnaround, :turnaround-godown, :yaw-shake, :yaw-dance, :phi-dance, :theta-dance, :vz-dance, :wave, :phi-theta-mixed, :double-phi-theta-mixed, :flip-ahead, :flip-behind, :flip-left, :flip-right.

You can get the default duration for each flight animation from the map at/default-animation-duration.

The YouTube video “Drone Ace Flight Animation Controls for the AR.Drone” shows most of the animations.

animate-leds

(animate-leds & [name hz duration])

Animates the drone’s LED lights.

name, if supplied, must be a symbol specifying a valid LED animation. hz, if supplied, is the frequency in Hz at which the animation will run. duration, if supplied, is how long the animation should run for, in seconds.

These are the valid LED animations: :blink-green-red, :blink-green, :blink-red. :blink-orange, :snake-green-red, :fire, :standard, :red, :green, :red-snake, :blank, :right-missile, :left-missile, :double-missile, :front-left-green-others-red, :front-right-green-others-red, :rear-right-green-others-red, :rear-left-green-others-red, :left-green-right-red, :left-red-right-green, :blink-standard.

back

(back drone speed)

Commands the drone to begin moving (translating) backward. speed should be a number in the range [0.0, 1.0].

calibrate

(calibrate device-id)

Tells the drone to calibrate its magnetometer.

This command MUST be sent when the AR.Drone is flying.

On receipt of this command, the drone will automatically calibrate its magnetometer by rotating itself and then stopping.

device-id is the ID of the device to calibrate. The magnetometer is device ID 0.

clockwise

(clockwise drone speed)

Commands the drone to begin rotating counter-clockwise. speed should be a number in the range [0.0, 1.0].

config

(config key value & [callback])

Configures drone options.

You shouldn’t need to use this command because there are higher level functions already defined for most behaviors. See navdata-demo, navdata-options, animate, animate-leds, switch-camera, and set-camera-framerate.

connect!

(connect! drone)

Connects to a drone’s command channel and telemetry channel.

You must connect to a drone before you can send it any commands or receive telemetry.

counter-clockwise

(counter-clockwise drone speed)

Commands the drone to begin rotating counter-clockwise. speed should be a number in the range [0.0, 1.0].

ctrl

(ctrl control-mode other-mode)

This is a command that is not well documented in the AR.Drone SDK, and that you probably won’t ever need to use.

It can be used to clear the CONFIG ACK flag for “muticonfig” settings—see https://gist.github.com/bkw/4416785 for more information.

default-at-port

The default network port to use for sending AT control commands to a drone.

default-hostname

The default drone hostname.

default-video-port

The default network port for streaming video from a drone.

disable-emergency

(disable-emergency drone)

Resets the drone’s emergency stop state.

disconnect!

(disconnect! drone)

Disconnects from a drone.

down

(down drone speed)

Commands the drone to begin descending. speed should be a number in the range [0.0, 1.0].

flat-trim

(flat-trim)

Sets a reference of the horizontal plane for the drone internal control system.

It must be called after each drone start up, while making sure the drone actually sits on a horizontal ground. Not doing so before taking-off will result in the drone not being able to stabilize itself when flying, as it would not be able to know its actual tilt. This command MUST NOT be sent when the AR.Drone is flying.

front

(front drone speed)

Commands the drone to begin moving (translating) backward. speed should be a number in the range [0.0, 1.0].

land

(land drone)

Commands the drone to land.

left

(left drone speed)

Commands the drone to begin moving (translating) to its right. speed should be a number in the range [0.0, 1.0].

make-drone

(make-drone & options)

Creates a drone object.

This function can optionally take the following keyword arguments:

:hostname
The drone’s hostname/IP address.
:event-handler
A drone event handler function. See below for more information.
:name
A readable name for the drone.
:at-port
The network port to use for the AT command channel.
:navdata-port
The network port to use for navdata telemetry.

An event handler function must be a function of two arguments: event-type and event-data. There are currently three event types defined:

  • :navdata events occur whenever the drone sends navdata telemetry (typically many times per second) and the data sent with the event is the navdata object.

  • :state-change events occur when the drone’s state changes, according to the :state map of the :demo member of navdata. The data sent with the event is a map containing just the keys and values of the changed state, e.g. {:cutout :detected, :flying :landed, :emergency :detected}. For more information see the value of com.lemondronor.turboshrimp.navdata/state-masks.

  • :error events occur when an exception is thrown on the background thread that communicates with the drone. The data sent with the error event is the exception that occurred.

Examples:

(def my-drone (make-drone :event-handler #(println %1 %2)))

navdata-demo

(navdata-demo enabled?)

Enables or disables extended “demo” telemetry data.

navdata-options

(navdata-options flags)

When using navdata-demo to enable demo telemetry, this function selects which navdata packets to include.

flags is a sequence of option keywords. navdata-flags contains all valid options. The most common set of options is predefined as at/default-navdata-options.

Examples:

(navdata-options my-drone default-navdata-options)
(navdata-options my-drone [:demo :gps])

Here’s a list of allowed flags and their meanings:

Flag Description
:demo Demo navdata
:time Timestamp
:raw-measures Raw sensors measurements
:phys-measures Gyros?
:gyros-offsets Gyro offsets?
:euler-angles Drone attitude in euler angles
:references Attitude?
:trims Trim?
:rc-references Controller?
:pwm Motor control?
:altitude Altitude data
:vision-raw Vision?
:vision-of Vision offsets?
:vision Vision?
:vision-perf Vision performance/timing?
:trackers-send Vision tracking?
:vision-detect Vision-detected tag information
:watchdog Watchdog timer?
:adc-data-frame A/D converter?
:video-stream Video stream statistics
:games Game?
:pressure-raw Raw barometric sensor data?
:magneto Magnetometer data
:wind-speed Estimate wind data
:kalman-pressure ?
:hdvideo-stream Statistics on HD video stored on flash drive
:wifi Statistics on the wireless network link
:zimmu-3000 See :gps
:gps GPS data

pcmd

(pcmd options)

Makes the drone move (translate and rotate). You shouldn’e ever need to use this, because there are higher level functions already defined for those behaviors. See up, down, left, right, front, back, clockwise, counter-clockwise.

ref

(ref options)

Controls the basic behaviour of the drone (take-off/landing, emergency stop/reset). You shouldn’t ever need to use this, because there are higher level functions already defined for those behaviors. See takeoff, land, and disable-emergency.

right

(right drone speed)

Commands the drone to begin moving (translating) to its right. speed should be a number in the range [0.0, 1.0].

set-camera-framerate

(set-camera-framerate fps)

Sets the video stream frame rate.

stop

(stop drone)

Commands the drone to stop all motion.

switch-camera

(switch-camera direction)

Switches the video stream between the forward-facing and downward-facing cameras.

direction must be :forward or :down.

takeoff

(takeoff drone)

Commands the drone to take off.

up

(up drone speed)

Commands the drone to begin descending. speed should be a number in the range [0.0, 1.0].

video-input-stream

(video-input-stream drone)

Creates an InputStream connected to a drone’s video stream.

See com.lemondronor.turboshrimp.pave for more information about how to use a drone’s video stream.