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.
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].
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 ofcom.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)))
pcmd
(pcmd options)
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].
switch-camera
(switch-camera direction)
Switches the video stream between the forward-facing and downward-facing cameras.
direction
must be :forward
or :down
.
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.