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.
- absoluteAccuracy
- Float absoluteAccuracy- How accurate absolute mode is. Should be a number between 0 - 1. - Defaults to - 0.1f.
- absoluteMode
- Bool absoluteMode- Turns the drone's absolute movement mode on and off. Absolute mode is where the drone's left / right / forward / backward movement is fixed to a set compass position and is not relative to where the drone is facing. - The compass direction is set when absolute mode is turned on. If you make sure the drone is facing away from you when this happens, then it should make for easier drone control. 
- animateFlight
- 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 - nullthen the default duration of the enum is used.- Corresponds to the - control:flight_animconfig cmd.
- animateLeds
- 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 - freqInHzis- nullthen the default frequency of the enum is used.- Corresponds to the - leds:leds_animconfig cmd.- This method does not block. 
- calibrate
- 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. 
- clearEmergency
- Void clearEmergency(Duration? timeout := null)- Clears the emergency landing and the user emergency flags on the drone. - timeoutis how long it should wait for an acknowledgement from the drone before throwing a- TimeoutErr. If- nullthen it defaults to- NetworkConfig.configCmdAckTimeout.
- config
- DroneConfig config()- Returns config for the drone. Note all data is backed by the raw - configMap.
- configMap
- 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, see configRefresh() obtain fresh data from the drone. 
- configRefresh
- Void configRefresh()- Reloads the - configMapwith fresh data from the drone.
- connect
- 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. 
- disconnect
- This disconnect(Duration timeout := 2sec)- Disconnects all comms to the drone. Performs the - crashLandOnExitstrategy should the drone still be flying.- This method blocks until it's finished. 
- droneVersion
- Version droneVersion { private set }- The version of the drone, as reported by an FTP of - version.txt.
- exitStrategy
- ExitStrategy exitStrategy- Should this - Droneclass 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 -9command.
- flatTrim
- 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
- FlightState? flightState { private set }- Returns the current flight state of the Drone. 
- hover
- Void hover(Bool block := true, Duration? timeout := null)- Repeatedly sends a hover command to the drone until it reports its state as - hovering.- If - blockis- truethen this method blocks until the drone hovers.- timeoutis how long it should wait for the drone to reach the desired state before throwing a- TimeoutErr. If- nullthen it defaults to- NetworkConfig.actionTimeout.
- isConnected
- Bool isConnected()- Returns - trueif connected to the drone.
- land
- Void land(Bool block := true, Duration? timeout := null)- Repeatedly sends a land command to the drone until it reports its state as - landed.- If - blockis- truethen this method blocks until the drone has landed.- timeoutis how long it should wait for the drone to reach the desired state before throwing a- TimeoutErr. If- nullthen it defaults to- NetworkConfig.actionTimeout.
- make
- new make(NetworkConfig networkConfig := NetworkConfig.<ctor>(), |This? f := null)- Creates a - Droneinstance, optionally passing in network configuration.
- move
- |->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
- |->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.- durationis 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 - blockbe- false, this method returns immediately and movement commands are sent in the background. Call the returned function to cancel movement before the- durationinterval is reached. Calling the function after- durationdoes nothing.- // move the drone for 5secscancel := drone.moveBackward(0.5f, 5sec, false)- // wait a bitActor.sleep(2sec)- // cancel the move prematurelycancel()- If - durationis- nullthen the movement command is sent just the once.- See config command - CONTROL:euler_angle_max.
- moveDown
- |->Void? moveDown(Float verticalSpeed, Duration? duration := null, Bool? block := (Bool?)true)- Moves the drone vertically downwards. - verticalSpeedis 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.- durationis 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 - blockbe- false, this method returns immediately and movement commands are sent in the background. Call the returned function to cancel movement before the- durationinterval is reached. Calling the function after- durationdoes nothing.- // move the drone for 5secscancel := drone.moveDown(0.5f, 5sec, false)- // wait a bitActor.sleep(2sec)- // cancel the move prematurelycancel()- If - durationis- nullthen the movement command is sent just the once.- See config commands - CONTROL:altitude_min,- CONTROL:control_vz_max.
- moveForward
- |->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.- durationis 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 - blockbe- false, this method returns immediately and movement commands are sent in the background. Call the returned function to cancel movement before the- durationinterval is reached. Calling the function after- durationdoes nothing.- // move the drone for 5secscancel := drone.moveForward(0.5f, 5sec, false)- // wait a bitActor.sleep(2sec)- // cancel the move prematurelycancel()- If - durationis- nullthen the movement command is sent just the once.- See config command - CONTROL:euler_angle_max.
- moveLeft
- |->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.- durationis 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 - blockbe- false, this method returns immediately and movement commands are sent in the background. Call the returned function to cancel movement before the- durationinterval is reached. Calling the function after- durationdoes nothing.- // move the drone for 5secscancel := drone.moveLeft(0.5f, 5sec, false)- // wait a bitActor.sleep(2sec)- // cancel the move prematurelycancel()- If - durationis- nullthen the movement command is sent just the once.- See config command - CONTROL:euler_angle_max.
- moveRight
- |->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.- durationis 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 - blockbe- false, this method returns immediately and movement commands are sent in the background. Call the returned function to cancel movement before the- durationinterval is reached. Calling the function after- durationdoes nothing.- // move the drone for 5secscancel := drone.moveRight(0.5f, 5sec, false)- // wait a bitActor.sleep(2sec)- // cancel the move prematurelycancel()- If - durationis- nullthen the movement command is sent just the once.- See config command - CONTROL:euler_angle_max.
- moveUp
- |->Void? moveUp(Float verticalSpeed, Duration? duration := null, Bool? block := (Bool?)true)- Moves the drone vertically upwards. - verticalSpeedis 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.- durationis 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 - blockbe- false, this method returns immediately and movement commands are sent in the background. Call the returned function to cancel movement before the- durationinterval is reached. Calling the function after- durationdoes nothing.- // move the drone for 5secscancel := drone.moveUp(0.5f, 5sec, false)- // wait a bitActor.sleep(2sec)- // cancel the move prematurelycancel()- If - durationis- nullthen the movement command is sent just the once.- See config commands - CONTROL:altitude_max,- CONTROL:control_vz_max.
- NavData? navData { private set }- Returns the latest Nav Data or - nullif not connected. Note that this instance always contains a culmination of all the latest nav options received.
- networkConfig
- const NetworkConfig networkConfig- The network configuration as passed to the ctor. 
- 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 - NotImmutableErrif the function is not immutable. Note this hook is called from a different Actor / thread to the one that sets it.
- onBatteryLow
- |Drone? onBatteryLow- Event hook that's called when the drone's battery reaches a critical level ~ 20%. - Throws - NotImmutableErrif the function is not immutable. Note this hook is called from a different Actor / thread to the one that sets it.
- onDisconnect
- Event hook that's called when the drone is disconnected. The - abnormalboolean is set to- trueif 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 - NotImmutableErrif the function is not immutable. Note this hook is called from a different Actor / thread to the one that sets it.
- onEmergency
- |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 - NotImmutableErrif the function is not immutable. Note this hook is called from a different Actor / thread to the one that sets it.
- 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.navDatais updated with the new contents before the hook is called.- Throws - NotImmutableErrif the function is not immutable. Note this hook is called from a different Actor / thread to the one that sets it.
- onRecordErr
- Event hook that's called when there's an error decoding the video record stream. - Given the nature of streaming chunks, errors may be un-recoverable and future video frames may not be decoded. Therefore on error, it is advised to restart the video comms with the drone. 
- onStateChange
- |FlightState,Drone? onStateChange- Event hook that's called when the drone's state is changed. - Throws - NotImmutableErrif the function is not immutable. Note this hook is called from a different Actor / thread to the one that sets it.
- onVideoErr
- Event hook that's called when there's an error decoding the video stream. - Given the nature of streaming chunks, errors may be un-recoverable and future video frames may not be decoded. Therefore on error, it is advised to restart the video comms with the drone. 
- onVideoFrame
- |Buf,PaveHeader,Drone? onVideoFrame- Event hook that's called when a 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 live video. Setting to - nullinstructs the drone to stop streaming video.- Throws - NotImmutableErrif the function is not immutable. Note this hook is called from a different Actor / thread to the one that sets it.
- sendCmd
- Void sendCmd(Cmd cmd, Cmd? cmd2 := null)- (Advanced) Sends the given Cmd to the drone. If a second Cmd is given, it is sent in the same UDP data packet. - This method does not block. 
- sendConfig
- Void sendConfig(Str key, Obj val, Int? sessionId := null, Int? userId := null, Int? appId := null)- (Advanced) Sends a config cmd to the drone, and blocks until it's been acknowledged. - valmay be a Bool, Int, Float, Str, or a List of said types.- For multi-config support, pass in the appropriate IDs. 
- setUserEmergency
- Void setUserEmergency(Duration? timeout := null)- Sets the drone's emergency landing flag which cuts off the motors, causing a crash landing. - timeoutis how long it should wait for an acknowledgement from the drone before throwing a- TimeoutErr. If- nullthen it defaults to- NetworkConfig.configCmdAckTimeout.
- spinAntiClockwise
- |->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.- durationis 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 - blockbe- false, this method returns immediately and movement commands are sent in the background. Call the returned function to cancel movement before the- durationinterval is reached. Calling the function after- durationdoes nothing.- // move the drone for 5secscancel := drone.spinAntiClockwise(0.5f, 5sec, false)- // wait a bitActor.sleep(2sec)- // cancel the move prematurelycancel()- If - durationis- nullthen the movement command is sent just the once.- See config command - CONTROL:control_yaw.
- spinClockwise
- |->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.- durationis 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 - blockbe- false, this method returns immediately and movement commands are sent in the background. Call the returned function to cancel movement before the- durationinterval is reached. Calling the function after- durationdoes nothing.- // move the drone for 5secscancel := drone.spinClockwise(0.5f, 5sec, false)- // wait a bitActor.sleep(2sec)- // cancel the move prematurelycancel()- If - durationis- nullthen the movement command is sent just the once.- See config command - CONTROL:control_yaw.
- takeOff
- Void takeOff(Bool block := true, Duration? timeout := null)- Repeatedly sends a take off command to the drone until it reports its state as either - hoveringor- flying.- If - blockis- truethen this method blocks until a stable hover has been achieved; which usually takes ~ 6 seconds.- timeoutis how long it should wait for the drone to reach the desired state before throwing a- TimeoutErr. If- nullthen it defaults to- NetworkConfig.actionTimeout.