Action
public class Action
Enable simple actions such as arming, taking off, and landing.
-
Initializes a new
Action
plugin.Normally never created manually, but used from the
Drone
helper class instead.Declaration
Swift
public convenience init(address: String = "localhost", port: Int32 = 50051, scheduler: SchedulerType = ConcurrentDispatchQueueScheduler(qos: .background))
Parameters
address
The address of the
MavsdkServer
instance to connect toport
The port of the
MavsdkServer
instance to connect toscheduler
The scheduler to be used by
Observable
s -
Undocumented
See moreDeclaration
Swift
public struct RuntimeActionError : Error
-
Undocumented
See moreDeclaration
Swift
public struct ActionError : Error
-
Yaw behaviour during orbit flight.
See moreDeclaration
Swift
public enum OrbitYawBehavior : Equatable
-
Result type.
See moreDeclaration
Swift
public struct ActionResult : Equatable
-
Send command to arm the drone.
Arming a drone normally causes motors to spin at idle. Before arming take all safety precautions and stand clear of the drone!
Declaration
Swift
public func arm() -> Completable
-
Send command to disarm the drone.
This will disarm a drone that considers itself landed. If flying, the drone should reject the disarm command. Disarming means that all motors will stop.
Declaration
Swift
public func disarm() -> Completable
-
Send command to take off and hover.
This switches the drone into position control mode and commands it to take off and hover at the takeoff altitude.
Note that the vehicle must be armed before it can take off.
Declaration
Swift
public func takeoff() -> Completable
-
Send command to land at the current position.
This switches the drone to ‘Land’ flight mode.
Declaration
Swift
public func land() -> Completable
-
Send command to reboot the drone components.
This will reboot the autopilot, companion computer, camera and gimbal.
Declaration
Swift
public func reboot() -> Completable
-
Send command to shut down the drone components.
This will shut down the autopilot, onboard computer, camera and gimbal. This command should only be used when the autopilot is disarmed and autopilots commonly reject it if they are not already ready to shut down.
Declaration
Swift
public func shutdown() -> Completable
-
Send command to terminate the drone.
This will run the terminate routine as configured on the drone (e.g. disarm and open the parachute).
Declaration
Swift
public func terminate() -> Completable
-
Send command to kill the drone.
This will disarm a drone irrespective of whether it is landed or flying. Note that the drone will fall out of the sky if this command is used while flying.
Declaration
Swift
public func kill() -> Completable
-
Send command to return to the launch (takeoff) position and land.
This switches the drone into Return mode which generally means it will rise up to a certain altitude to clear any obstacles before heading back to the launch (takeoff) position and land there.
Declaration
Swift
public func returnToLaunch() -> Completable
-
Send command to move the vehicle to a specific global position.
The latitude and longitude are given in degrees (WGS84 frame) and the altitude in meters AMSL (above mean sea level).
The yaw angle is in degrees (frame is NED, 0 is North, positive is clockwise).
Declaration
Swift
public func gotoLocation(latitudeDeg: Double, longitudeDeg: Double, absoluteAltitudeM: Float, yawDeg: Float) -> Completable
Parameters
latitudeDeg
Latitude (in degrees)
longitudeDeg
Longitude (in degrees)
absoluteAltitudeM
Altitude AMSL (in meters)
yawDeg
Yaw angle (in degrees, frame is NED, 0 is North, positive is clockwise)
-
Send command do orbit to the drone.
This will run the orbit routine with the given parameters.
Declaration
Swift
public func doOrbit(radiusM: Float, velocityMs: Float, yawBehavior: OrbitYawBehavior, latitudeDeg: Double, longitudeDeg: Double, absoluteAltitudeM: Double) -> Completable
Parameters
radiusM
Radius of circle (in meters)
velocityMs
Tangential velocity (in m/s)
yawBehavior
Yaw behavior of vehicle (ORBIT_YAW_BEHAVIOUR)
latitudeDeg
Center point latitude in degrees. NAN: use current latitude for center
longitudeDeg
Center point longitude in degrees. NAN: use current longitude for center
absoluteAltitudeM
Center point altitude in meters. NAN: use current altitude for center
-
Send command to hold position (a.k.a. “Loiter”).
Sends a command to drone to change to Hold flight mode, causing the vehicle to stop and maintain its current GPS position and altitude.
Note: this command is specific to the PX4 Autopilot flight stack as it implies a change to a PX4-specific mode.
Declaration
Swift
public func hold() -> Completable
-
Send command to set the value of an actuator.
Declaration
Swift
public func setActuator(index: Int32, value: Float) -> Completable
Parameters
index
Index of actuator (starting with 1)
value
Value to set the actuator to (normalized from [-1..1])
-
Send command to transition the drone to fixedwing.
The associated action will only be executed for VTOL vehicles (on other vehicle types the command will fail). The command will succeed if called when the vehicle is already in fixedwing mode.
Declaration
Swift
public func transitionToFixedwing() -> Completable
-
Send command to transition the drone to multicopter.
The associated action will only be executed for VTOL vehicles (on other vehicle types the command will fail). The command will succeed if called when the vehicle is already in multicopter mode.
Declaration
Swift
public func transitionToMulticopter() -> Completable
-
Get the takeoff altitude (in meters above ground).
Declaration
Swift
public func getTakeoffAltitude() -> Single<Float>
-
Set takeoff altitude (in meters above ground).
Declaration
Swift
public func setTakeoffAltitude(altitude: Float) -> Completable
Parameters
altitude
Takeoff altitude relative to ground/takeoff location (in meters)
-
Get the vehicle maximum speed (in metres/second).
Declaration
Swift
public func getMaximumSpeed() -> Single<Float>
-
Set vehicle maximum speed (in metres/second).
Declaration
Swift
public func setMaximumSpeed(speed: Float) -> Completable
Parameters
speed
Maximum speed (in metres/second)
-
Get the return to launch minimum return altitude (in meters).
Declaration
Swift
public func getReturnToLaunchAltitude() -> Single<Float>
-
Set the return to launch minimum return altitude (in meters).
Declaration
Swift
public func setReturnToLaunchAltitude(relativeAltitudeM: Float) -> Completable
Parameters
relativeAltitudeM
Return altitude relative to takeoff location (in meters)
-
Set current speed.
This will set the speed during a mission, reposition, and similar. It is ephemeral, so not stored on the drone and does not survive a reboot.
Declaration
Swift
public func setCurrentSpeed(speedMS: Float) -> Completable
Parameters
speedMS
Speed in meters/second