const classafParrotSdk2::Drone

sys::Obj
  afParrotSdk2::Drone

The main interface to the Parrot AR Drone 2.0.

Once the drone has been disconnected, this class instance can not be re-connected. Instead create a new Drone instance.

animateFlight

Source

Void animateFlight(FlightAnimation anim, Duration? duration := null, Bool block := true)

Performs one of the pre-configured flight sequences.

drone.animateFlight(FlightAnimation.phiDance)

If duration is null then the default duration of the enum is used.

Corresponds to the control:flight_anim config cmd.

animateLeds

Source

Void animateLeds(LedAnimation anim, Duration duration, Float? freqInHz := null)

Plays one of the pre-configured LED animation sequences. Example:

drone.animateLeds(LedAnimation.snakeRed, 3sec)

If freqInHz is null then the default frequency of the enum is used.

Corresponds to the leds:leds_anim config cmd.

This method does not block.

calibrate

Source

Void calibrate(Int deviceNum)

Tell the drone to calibrate its magnetometer.

The drone calibrates its magnetometer by spinning around itself a few times, hence can only be performed when flying.

This method does not block.

clearEmergencyLanding

Source

Void clearEmergencyLanding(Duration? timeout := null)

Blocks until the emergency landing flag has been cleared.

If timeout is null it defaults to DroneConfig.configCmdAckTimeout.

config

Source

DroneConfig config()

Returns config for the drone. Note all data is backed by the raw configMap.

configMap

Source

Str:Str configMap(Bool reRead := false)

Returns a read only map of the drone's raw configuration data, as read from the control (TCP 5559) port.

All config data is cached, pass a reRead value of true to obtain fresh data from the drone.

connect

Source

This connect()

Sets up the socket connections to the drone. Your device must already be connected to the drone's wifi hot spot.

Whilst there is no real concept of being connected to a drone, this method blocks until nav data is being received and all initiating commands have been acknowledged.

If timeout is null it defaults to DroneConfig.actionTimeout.

disconnect

Source

This disconnect(Duration timeout := 2sec)

Disconnects all comms to the drone. Performs the crashLandOnExit strategy should the drone still be flying.

This method blocks until it's finished.

droneVersion

Source

Version? droneVersion { private set }

The version of the drone, as reported by an FTP of version.txt.

exitStrategy

Source

ExitStrategy exitStrategy

Should this Drone class instance disconnect from the drone whilst it is flying (or the VM otherwise exits) then this strategy governs what last commands should be sent to the drone before it exits.

(It's a useful feature I wish I'd implemented before the time my program crashed and I watched my drone sail up, up, and away, over the tree line!)

Defaults to land.

Note this can not guard against a forced process kill or a kill -9 command.

flatTrim

Source

Void flatTrim()

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

Call before each flight, while making sure the drone is sitting horizontally on the ground. Not doing so will result in the drone not being unstable.

This method does not block.

flightState

Source

FlightState? flightState { private set }

Returns the current flight state of the Drone.

hover

Source

Void hover(Bool block := true, Duration? timeout := null)

Repeatedly sends a hover command to the drone until it reports its state as hovering.

If block is true then this method blocks until the drone hovers.

If timeout is null it defaults to DroneConfig.defaultTimeout.

isConnected

Source

Bool isConnected()

Returns true if connected to the drone.

land

Source

Void land(Bool block := true, Duration? timeout := null)

Repeatedly sends a land command to the drone until it reports its state as landed.

If block is true then this method blocks until the drone has landed.

If timeout is null it defaults to DroneConfig.defaultTimeout.

make

Source

new make(NetworkConfig networkConfig := NetworkConfig.<ctor>())

Creates a Drone instance, optionally passing in network configuration.

move

Source

|->Void? move(Float tiltRight, Float tiltBackward, Float verticalSpeed, Float clockwiseSpin, Duration? duration := null, Bool? block := (Bool?)true)

A combined move method encapsulating:

  • moveRight()
  • moveBackward()
  • moveUp()
  • spinClickwise()
moveBackward

Source

|->Void? moveBackward(Float tilt, Duration? duration := null, Bool? block := (Bool?)true)

Moves the drone backward.

The tilt (aka pitch or theta) is a percentage of the maximum inclination and should be a value between -1 and 1. A positive value makes the drone raise its nose, thus flying forward. A negative value makes the drone tilt forward.

duration is how long the drone should move for, during which the move command is resent every config.cmdInterval. Movement is cancelled if land() is called or an emergency flag is set.

Should block be false, this method returns immediately and movement commands are sent in the background. Call the returned function to cancel movement before the duration interval is reached. Calling the function after duration does nothing.

// move the drone
cancel := drone.moveBackward(0.5f, 5sec, false)

// wait a bit
Actor.sleep(2sec) 

// cancel the move
cancel()

If duration is null then the movement command is sent just the once.

See config command control:euler_angle_max.

moveDown

Source

|->Void? moveDown(Float verticalSpeed, Duration? duration := null, Bool? block := (Bool?)true)

Moves the drone vertically downwards.

verticalSpeed is a percentage of the maximum vertical speed and should be a value between -1 and 1. A positive value makes the drone descend in the air, a negative value makes it go up.

duration is how long the drone should move for, during which the move command is resent every config.cmdInterval. Movement is cancelled if land() is called or an emergency flag is set.

Should block be false, this method returns immediately and movement commands are sent in the background. Call the returned function to cancel movement before the duration interval is reached. Calling the function after duration does nothing.

// move the drone
cancel := drone.moveDown(0.5f, 5sec, false)

// wait a bit
Actor.sleep(2sec) 

// cancel the move
cancel()

If duration is null then the movement command is sent just the once.

See config commands control:altitude_min, control:control_vz_max.

moveForward

Source

|->Void? moveForward(Float tilt, Duration? duration := null, Bool? block := (Bool?)true)

Moves the drone forward.

The tilt (aka pitch or theta) is a percentage of the maximum inclination and should be a value between -1 and 1. A positive value makes the drone drop its nose, thus flying forward. A negative value makes the drone tilt back.

duration is how long the drone should move for, during which the move command is resent every config.cmdInterval. Movement is cancelled if land() is called or an emergency flag is set.

Should block be false, this method returns immediately and movement commands are sent in the background. Call the returned function to cancel movement before the duration interval is reached. Calling the function after duration does nothing.

// move the drone
cancel := drone.moveForward(0.5f, 5sec, false)

// wait a bit
Actor.sleep(2sec) 

// cancel the move
cancel()

If duration is null then the movement command is sent just the once.

See config command control:euler_angle_max.

moveLeft

Source

|->Void? moveLeft(Float tilt, Duration? duration := null, Bool? block := (Bool?)true)

Moves the drone to the left.

tilt (aka roll or phi) is a percentage of the maximum inclination and should be a value between -1 and 1. A positive value makes the drone tilt to its left, thus flying leftward. A negative value makes the drone tilt to its right.

duration is how long the drone should move for, during which the move command is resent every config.cmdInterval. Movement is cancelled if land() is called or an emergency flag is set.

Should block be false, this method returns immediately and movement commands are sent in the background. Call the returned function to cancel movement before the duration interval is reached. Calling the function after duration does nothing.

// move the drone
cancel := drone.moveLeft(0.5f, 5sec, false)

// wait a bit
Actor.sleep(2sec) 

// cancel the move
cancel()

If duration is null then the movement command is sent just the once.

See config command control:euler_angle_max.

moveRight

Source

|->Void? moveRight(Float tilt, Duration? duration := null, Bool? block := (Bool?)true)

Moves the drone to the right.

The tilt (aka roll or phi) is a percentage of the maximum inclination and should be a value between -1 and 1. A positive value makes the drone tilt to its right, thus flying right. A negative value makes the drone tilt to its left.

duration is how long the drone should move for, during which the move command is resent every config.cmdInterval. Movement is cancelled if land() is called or an emergency flag is set.

Should block be false, this method returns immediately and movement commands are sent in the background. Call the returned function to cancel movement before the duration interval is reached. Calling the function after duration does nothing.

// move the drone
cancel := drone.moveRight(0.5f, 5sec, false)

// wait a bit
Actor.sleep(2sec) 

// cancel the move
cancel()

If duration is null then the movement command is sent just the once.

See config command control:euler_angle_max.

moveUp

Source

|->Void? moveUp(Float verticalSpeed, Duration? duration := null, Bool? block := (Bool?)true)

Moves the drone vertically upwards.

verticalSpeed is a percentage of the maximum vertical speed and should be a value between -1 and 1. A positive value makes the drone rise in the air, a negative value makes it go down.

duration is how long the drone should move for, during which the move command is resent every config.cmdInterval. Movement is cancelled if land() is called or an emergency flag is set.

Should block be false, this method returns immediately and movement commands are sent in the background. Call the returned function to cancel movement before the duration interval is reached. Calling the function after duration does nothing.

// move the drone
cancel := drone.moveUp(0.5f, 5sec, false)

// wait a bit
Actor.sleep(2sec) 

// cancel the move
cancel()

If duration is null then the movement command is sent just the once.

See config commands control:altitude_max, control:control_vz_max.

Source

NavData? navData { private set }

Returns the latest Nav Data or null if not connected. Note that this instance always contains a culmination of all the latest nav options received.

networkConfig

Source

const NetworkConfig networkConfig

The network configuration as passed to the ctor.

onBatteryDrain

Source

|Int,Drone? onBatteryDrain

Event hook that's called when the drone's battery loses a percentage of charge. The function is called with the new battery percentage level (0 - 100).

Throws NotImmutableErr if the function is not immutable. Note this hook is called from a different Actor / thread to the one that sets it.

onBatteryLow

Source

|Drone? onBatteryLow

Event hook that's called when the drone's battery reaches a critical level ~ 20%.

Throws NotImmutableErr if the function is not immutable. Note this hook is called from a different Actor / thread to the one that sets it.

onDisconnect

Source

|Bool,Drone? onDisconnect

Event hook that's called when the drone is disconnected. The abnormal boolean is set to true if the drone is disconnected due to a communication / socket error. This may happen if the battery drains too low or the drone is switched off.

Throws NotImmutableErr if the function is not immutable. Note this hook is called from a different Actor / thread to the one that sets it.

onEmergency

Source

|Drone? onEmergency

Event hook that's called when the drone enters emergency mode. When this happens, the engines are cut and the drone will not respond to commands until emergency mode is cleared.

Note this hook is only called when the drone is flying.

Throws NotImmutableErr if the function is not immutable. Note this hook is called from a different Actor / thread to the one that sets it.

onNavData

Source

|NavData,Drone? onNavData

Event hook that's notified when the drone sends new NavData. Expect the function to be called many times a second.

The nav data is raw from the drone so does not contain a culmination of all option data. Note Drone.navData is updated with the new contents before the hook is called.

Throws NotImmutableErr if the function is not immutable. Note this hook is called from a different Actor / thread to the one that sets it.

onStateChange

Source

|FlightState,Drone? onStateChange

Event hook that's called when the drone's state is changed.

Throws NotImmutableErr if the function is not immutable. Note this hook is called from a different Actor / thread to the one that sets it.

onVideoFrame

Source

|Buf,PaveHeader,Drone? onVideoFrame

Event hook that's called when video frame is received. (On Drone TCP port 5555.)

The payload is a raw frame from the H.264 codec.

Setting this hook instructs the drone to start streaming video. Setting this to null instructs the drone to stop streaming video.

Throws NotImmutableErr if the function is not immutable. Note this hook is called from a different Actor / thread to the one that sets it.

sendConfig

Source

Void sendConfig(Str key, Obj val, Str? sessionId := null, Str? userId := null, Str? appId := null)

(Advanced) Sends a config cmd to the drone, and blocks until it's been acknowledged.

val may be a Bool, Int, Float, Str, or a List of said types.

For multi-config support, pass in the appropriate IDs.

setEmergencyLanding

Source

Void setEmergencyLanding(Duration? timeout := null)

Sends a emergency signal which cuts off the drone's motors, causing a crash landing.

If timeout is null it defaults to DroneConfig.configCmdAckTimeout.

spinAntiClockwise

Source

Void spinAntiClockwise(Float angularSpeed, Duration? duration := null, Bool? block := (Bool?)true)

Spins the drone anti-clockwise.

The angularSpeed (aka yaw) is a percentage of the maximum angular speed and should be a value between -1 and 1. A positive value makes the drone spin anti-clockwise; a negative value makes it spin clockwise.

duration is how long the drone should move for, during which the move command is resent every config.cmdInterval. Movement is cancelled if land() is called or an emergency flag is set.

Should block be false, this method returns immediately and movement commands are sent in the background. Call the returned function to cancel movement before the duration interval is reached. Calling the function after duration does nothing.

// move the drone
cancel := drone.spinAntiClockwise(0.5f, 5sec, false)

// wait a bit
Actor.sleep(2sec) 

// cancel the move
cancel()

If duration is null then the movement command is sent just the once.

See config command control:control_yaw.

spinClockwise

Source

|->Void? spinClockwise(Float angularSpeed, Duration? duration := null, Bool? block := (Bool?)true)

Spins the drone clockwise.

The angularSpeed (aka yaw) is a percentage of the maximum angular speed and should be a value between -1 and 1. A positive value makes the drone spin clockwise; a negative value makes it spin anti-clockwise.

duration is how long the drone should move for, during which the move command is resent every config.cmdInterval. Movement is cancelled if land() is called or an emergency flag is set.

Should block be false, this method returns immediately and movement commands are sent in the background. Call the returned function to cancel movement before the duration interval is reached. Calling the function after duration does nothing.

// move the drone
cancel := drone.spinClockwise(0.5f, 5sec, false)

// wait a bit
Actor.sleep(2sec) 

// cancel the move
cancel()

If duration is null then the movement command is sent just the once.

See config command control:control_yaw.

takeOff

Source

Void takeOff(Bool block := true, Duration? timeout := null)

Repeatedly sends a take off command to the drone until it reports its state as either hovering or flying.

If block is true then this method blocks until a stable hover has been achieved; which usually takes ~ 6 seconds.

If timeout is null it defaults to DroneConfig.defaultTimeout.