Class Multirotor

The base class for AirSim vehicles providing access to a vehicle's state, position, orientation, sensor data, cameras and images, collision info and visibility to points test.

Hierarchy

Constructors

  • new Multirotor(name: string, controller?: string, pawnPath?: string): Multirotor
  • Create a new instance.

    Parameters

    • name: string

      The name of the vehicle.

    • controller: string = Multirotor.DEFAULT_CONTROLLER

      The vehicle controller, default = SimpleFlight

    • pawnPath: string = ''

      Vehicle blueprint path, when undefined uses the default blueprint.

    Returns Multirotor

Properties

_session: Session

The low-level AirSim api and network connection.

controller: string = ''
name: string
pawnPath: string = ''

Accessors

  • get DEFAULT_CONTROLLER(): string
  • Access the default controller (e.g., flight controller) of the vehicle.

    Returns string

Methods

  • arm(): Promise<boolean>
  • The drone must be armed before it will fly. Set arm to true to arm the drone. On some drones arming may cause the motors to spin on low throttle, this is normal.

    Returns

    Promise if successful.

    Returns Promise<boolean>

  • Experimental - Rotate a camera to point towards a target position.

    Returns

    A Promise with the camera rotation..

    Parameters

    • cameraName: CameraName

      The name or id of the camera to move.

    • target: Vector3

      The position to point camera towards.

    • rearFacing: boolean = false

      Set True when camera is mounting looking towards the rear of the vehicle, default = false.

    Returns Promise<Pose>

  • Experimental - Rotate a camera to point towards a target position.

    Returns

    A Promise with the camera rotation..

    Parameters

    • cameraName: CameraName

      The name or id of the camera to move.

    • target: Vector3

      The position to point camera towards.

    • rearFacing: boolean = false

      Set True when camera is mounting looking towards the rear of the vehicle, default = false.

    Returns Promise<Pose>

  • cancelLastTask(): Promise<unknown>
  • Terminate the current task execution.

    Returns

    Promise when the current task is terminated

    Returns Promise<unknown>

  • disableApiControl(): Promise<void>
  • disarm(): Promise<boolean>
  • This will disable the motors, so don't do that unless the drone is on the ground! Arming the drone also sets the "home position" This home position is local position x=0,y=0,z=0. You can query what GPS location that is via getHomeGeo().

    Returns

    Promise if successful.

    Returns Promise<boolean>

  • enableApiControl(): Promise<void>
  • getBarometerData(barometerName?: string): Promise<BarometerData>
  • Access the data from an barometer sensor.

    Returns

    The barometer sensor data

    Parameters

    • barometerName: string = ''

      Name of barometer to get data from, specified in settings.json

    Returns Promise<BarometerData>

  • Get details about the vehicle camera.

    Note if the cameraName is unknown to airsim, the server may crash.

    Returns

    A CameraInfo promise

    Parameters

    • cameraName: CameraName

      Name of the camera, for backwards compatibility, ID numbers such as 0,1,etc. can also be used

    Returns Promise<CameraInfo>

  • getDefaultCameraNames(): string[]
  • Get details about the vehicle camera.

    Note if the cameraName is unknown to airsim, the server may crash.

    Returns

    A CameraInfo promise

    Returns string[]

  • Access distance sensor data.

    Returns

    The distance data

    Parameters

    • distanceSensorName: string = ''

      Name of distance sensor to get data from, specified in settings.json

    Returns Promise<DistanceSensorData>

  • Get ground truth environment state The position inside the returned EnvironmentState is in the frame of the vehicle's starting point

    Returns

    Ground truth environment state

    Returns Promise<EnvironmentState>

  • Get ground-truth kinematics of the vehicle The position inside the returned KinematicsState is in the frame of the vehicle's starting point

    Returns

    Ground truth of the vehicle

    Returns Promise<KinematicsState>

  • Get the Home NED-frame location (north, east, down) of the vehicle.

    Returns

    The Home location of the vehicle

    Returns Promise<GeoPoint>

  • Get a single image in compressed PNG format.

    Returns

    Promise of compressed png image data

    Parameters

    • cameraName: CameraName

      Name of the camera, for backwards compatibility, ID numbers such as 0,1,etc. can also be used

    • imageType: ImageType = ImageType.Scene

      Type of image

    Returns Promise<Uint8Array>

  • getImuData(imuName?: string): Promise<ImuData>
  • Access the data from an IMU sensor.

    Returns

    The IMU sensor data

    Parameters

    • imuName: string = ''

      Name of IMU to get data from, specified in settings.json

    Returns Promise<ImuData>

  • getLidarData(lidarName?: string): Promise<LidarData>
  • Access the data from a LIDAR sensor.

    Returns

    The LIDAR sensor data

    Parameters

    • lidarName: string = ''

      Name of IMU to get data from, specified in settings.json

    Returns Promise<LidarData>

  • Access the data from an magnetometer sensor.

    Returns

    The magnetometer sensor data

    Parameters

    • magnetometerName: string = ''

      Name of Magnetometer to get data from, specified in settings.json

    Returns Promise<MagnetometerData>

  • getPose(): Promise<Pose>
  • Access the vehicle's Pose

    Returns

    The vehicle pose.

    Returns Promise<Pose>

  • Obtain the current state of all a multirotor's rotors. The state includes the speeds, thrusts and torques for all rotors.

    Returns

    RotorStates containing a timestamp, the speed, thrust and torque of all rotors

    Returns Promise<RotorStates>

  • The position inside the returned MultirotorState is in the frame of the vehicle's starting point

    Returns

    The drone state

    Returns Promise<MultirotorState>

  • goHome(timeoutSec?: number): Promise<boolean>
  • Initiate a return-to-home, i.e. Launch location, task which must be completed within timeoutSec.

    Returns

    Promise if success

    Parameters

    • timeoutSec: number = 3e+38

      Timeout (seconds) to complete task.

    Returns Promise<boolean>

  • hover(): Promise<void>
  • Hover at the current x, y, and z. If the drone is moving when this is called, it will try and move back to the location it was at when this command was received and hover there.

    Returns

    A void promise to await on.

    Returns Promise<void>

  • isApiControlEnabled(): Promise<boolean>
  • Returns true if API control is established.

    Returns

    Promise if API is enabled.

    Returns Promise<boolean>

  • land(timeoutSec?: number): Promise<boolean>
  • At any point this command will disable offboard control and land the drone at the current GPS location How quickly the drone descends is up to the drone. Some models will descend slowly if they have no lidar telling them how far it is to the ground, while others that can see the ground will descend more quickly until they get near the ground. None of that behavior is defined in this API because it is depends on what kind of hardware the drone has onboard. Pass non-zero timeoutSec if you want the method to wait until the drone reports it has landed, the timeout here is a bit tricky, depends on how high you are and what the drone's configured descent velocity is. If you don't want to wait pass zero. You can also periodically check getLandedState() to see if it has landed.

    Returns

    Promise when successful

    Parameters

    • timeoutSec: number = 60

      Timeout (seconds) for the vehicle to land

    Returns Promise<boolean>

  • moveByRC(rcdata: RCData): Promise<void>
  • Apply radio controller data commands and settings.

    Returns

    A Promise to await on.

    Parameters

    • rcdata: RCData

      The radio controller settings to apply.

    Returns Promise<void>

  • moveByVelocity(vx: number, vy: number, vz: number, duration: number, drivetrain?: DrivetrainType, yawMode?: YawMode): Promise<boolean>
  • Move by velocity to the world (NED) XYZ axes.

    Returns

    Promise on success.

    Parameters

    • vx: number

      Desired velocity in world (NED) X axis.

    • vy: number

      Desired velocity in world (NED) Y axis.

    • vz: number

      Desired velocityvin world (NED) Z axis.

    • duration: number

      Amount of time (seconds), to send this command.

    • drivetrain: DrivetrainType = DrivetrainType.MaxDegreeOfFreedom

      The drivetrain mode to use.

    • yawMode: YawMode = DEFAULT_YAW_MODE

      The rate (deg/sec) or angle (deg) of yaw maneuvering

    Returns Promise<boolean>

  • moveByVelocityBodyFrame(vx: number, vy: number, vz: number, duration: number, drivetrain?: DrivetrainType, yawMode?: YawMode): Promise<boolean>
  • Move by velocity relative to the vehicle's XYZ axies.

    Parameters

    • vx: number

      Desired velocity in the X axis of the vehicle's local NED frame.

    • vy: number

      Desired velocity in the Y axis of the vehicle's local NED frame.

    • vz: number

      Desired velocity in the Z axis of the vehicle's local NED frame.

    • duration: number

      Desired amount of time (seconds), to send this command.

    • drivetrain: DrivetrainType = DrivetrainType.MaxDegreeOfFreedom

      The drivetrain mode to use.

    • yawMode: YawMode = DEFAULT_YAW_MODE

      The rate (deg/sec) or angle (deg) of yaw maneuvering

    Returns Promise<boolean>

  • moveByVelocityZ(vx: number, vy: number, z: number, duration: number, drivetrain?: DrivetrainType, yawMode?: YawMode): Promise<boolean>
  • Move by velocity to the world (NED) XY axes with fixed Z (NED) position.

    Returns

    Promise on success.

    Parameters

    • vx: number

      Desired velocity in world (NED) X axis.

    • vy: number

      Desired velocity in world (NED) Y axis.

    • z: number

      Desired Z position in world (NED) Z axis.

    • duration: number

      Amount of time (seconds), to send this command.

    • drivetrain: DrivetrainType = DrivetrainType.MaxDegreeOfFreedom

      The drivetrain mode to use.

    • yawMode: YawMode = DEFAULT_YAW_MODE

      The rate (deg/sec) or angle (deg) of yaw maneuvering

    Returns Promise<boolean>

  • moveByVelocityZBodyFrame(vx: number, vy: number, z: number, duration: number, drivetrain?: DrivetrainType, yawMode?: YawMode): Promise<boolean>
  • Move by velocity relative to the vehicle's XY axies at Z altitude.

    Parameters

    • vx: number

      Desired velocity (m/s) in the X axis of the vehicle's local NED frame.

    • vy: number

      Desired velocity (m/s) in the Y axis of the vehicle's local NED frame.

    • z: number

      Desired Z position (m) in vehicle's local NED frame.

    • duration: number

      Desired amount of time (seconds), to send this command.

    • drivetrain: DrivetrainType = DrivetrainType.MaxDegreeOfFreedom

      The drivetrain mode to use.

    • yawMode: YawMode = DEFAULT_YAW_MODE

      The rate (deg/sec) or angle (deg) of yaw maneuvering

    Returns Promise<boolean>

  • moveOnPath(waypoints: Vector3[], velocity: number, timeoutSec?: number, drivetrain?: DrivetrainType, yawMode?: YawMode, lookahead?: number, adaptiveLookahead?: number): Promise<unknown>
  • Initiate a task to follow a path consisting of waypoints.

    Returns

    Promise if successful completion

    Parameters

    • waypoints: Vector3[]

      The 3d points for the path trajectory

    • velocity: number

      The target speed (m/s)

    • timeoutSec: number = 3e+38

      The maximum time (seconds) for this task to complete

    • drivetrain: DrivetrainType = DrivetrainType.MaxDegreeOfFreedom

      The drivetrain mode to use

    • yawMode: YawMode = DEFAULT_YAW_MODE

      The yaw configuration

    • lookahead: number = -1

      How far to look ahead on the path (default -1 means auto)

    • adaptiveLookahead: number = 1

      Whether to apply adaptive lookahead (1=yes, 0=no)

    Returns Promise<unknown>

  • moveToGPS(latitude: number, longitude: number, altitude: number, velocity: any, timeoutSec?: number, drivetrain?: DrivetrainType, yaw_mode?: YawMode, lookahead?: number, adaptive_lookahead?: number): Promise<boolean>
  • Initiate task to relocate vehile to a XY position with fixed Z (height) within timeoutSec.

    Returns

    A Promise on successful completion.

    Parameters

    • latitude: number

      Target latitude (North, South) coordinate.

    • longitude: number

      Target longitude (East, West) coordinate.

    • altitude: number

      Altitude in meters

    • velocity: any

      The velocity m/s by which to relocate.

    • timeoutSec: number = 3e+38

      The maximum time (seconds) to complete this relocation.

    • drivetrain: DrivetrainType = DrivetrainType.MaxDegreeOfFreedom
    • yaw_mode: YawMode = DEFAULT_YAW_MODE
    • lookahead: number = -1

      How far (m) to look ahead on the path (default -1 means auto)

    • adaptive_lookahead: number = 1

    Returns Promise<boolean>

  • moveToPosition(position: Vector3, velocity: number, timeoutSec?: number, drivetrain?: DrivetrainType, yawMode?: YawMode, lookahead?: number, adaptiveLookahead?: number): Promise<void>
  • Initiate task to relocate vehile to a new 3D position within timeoutSec.

    Returns

    A void promise to await on

    Parameters

    • position: Vector3

      The target position.

    • velocity: number

      The velocity (m/s) by which to relocate.

    • timeoutSec: number = 3e+38

      The maximum time (seconds) to complete this relocation.

    • drivetrain: DrivetrainType = DrivetrainType.MaxDegreeOfFreedom

      The drivetrain mode to use

    • yawMode: YawMode = DEFAULT_YAW_MODE

      The rate of yaw maneuvering

    • lookahead: number = -1

      How far to look ahead on the path (default -1 means auto)

    • adaptiveLookahead: number = 1

      Whether to apply adaptive lookahead (1=yes, 0=no)

    Returns Promise<void>

  • moveToZ(z: number, velocity: number, timeoutSec?: number, yawMode?: YawMode, lookahead?: number, adaptiveLookahead?: number): Promise<void>
  • Initiate task to relocate vehile to a XY position with fixed Z (height) within timeoutSec.

    Returns

    A Promise to await on

    Parameters

    • z: number

      The target NED Z position (negative is up) in meters,.

    • velocity: number

      The velocity m/s by which to relocate.

    • timeoutSec: number = 3e+38

      The maximum time (seconds) to complete this relocation.

    • yawMode: YawMode = DEFAULT_YAW_MODE

      The rate of yaw maneuvering

    • lookahead: number = -1

      How far to look ahead on the path (default -1 means auto)

    • adaptiveLookahead: number = 1

      Whether to apply adaptive lookahead (1=yes, 0=no)

    Returns Promise<void>

  • rotateByYawRate(yawRate: YawMode, duration: number): Promise<boolean>
  • Rotate the drone to the specified yaw rate while remaining stationery at the current x, y, and z.

    Returns

    Promise on success

    Parameters

    • yawRate: YawMode

      rate in degrees/second

    • duration: number

      length of time to apply this command

    Returns Promise<boolean>

  • rotateToYaw(yaw: number, timeoutSec?: number, margin?: number): Promise<unknown>
  • Initiate rotation task to absolute yaw angle (deg) of home position in degrees.

    Returns

    Promise on success

    Parameters

    • yaw: number

      angle in degrees

    • timeoutSec: number = 3e+38

      maximum time in seconds to complete manuever

    • margin: number = 5

      +/- allowable error in degrees

    Returns Promise<unknown>

  • setCameraFov(cameraName: CameraName, fovDegrees: number): Promise<void>
  • Control the field of view of a selected camera

    Returns

    A Promise to await on.

    Parameters

    • cameraName: CameraName

      Name of the camera to be controlled

    • fovDegrees: number

      Value of field of view in degrees

    Returns Promise<void>

  • Control the pose of a selected camera

    Returns

    A void promise to await on.

    Parameters

    • cameraName: CameraName

      Name of the camera to be controlled

    • pose: Pose

      Pose representing the desired position and orientation of the camera

    Returns Promise<void>

  • setKinematics(state: KinematicsState, ignoreCollision: boolean): Promise<void>
  • Set the kinematics state of the vehicle If you don't want to change position (or orientation) then just set components of position (or orientation) to floating point nan values

    Parameters

    • state: KinematicsState

      Desired Pose pf the vehicle

    • ignoreCollision: boolean

      Whether to ignore any collision or not

    Returns Promise<void>

  • setPose(pose: Pose, ignorecollision?: boolean): Promise<void>
  • Set the pose of the vehicle.

    Returns

    A Promise to await on.

    Parameters

    • pose: Pose

      The new pose.

    • ignorecollision: boolean = true

      Whether to ignore any collision or not

    Returns Promise<void>

  • setTraceLine(color: Color, thickness?: number): Promise<void>
  • Modify the color and thickness of the line when tracing is enabled. Tracing can be enabled by pressing T in the Editor or setting EnableTrace to True in the Vehicle Settings

    Returns

    A Promise to await on.

    Parameters

    • color: Color

      the RGBA tuple or CSS color name.

    • thickness: number = 1.0

      Thickness of the line

    Returns Promise<void>

  • Configure a camera to perform a computer vision search and detection of specific mesh object(s).

    Returns

    A Promise to await on

    Example

    Example for detecting all instances named "Car_*"

    startDetectionSearch(
    {
    camera: 'front_center',
    image_type: ImageType.Scene,
    meshName: 'Car_*'
    }
    );

    Parameters

    Returns Promise<void>

  • takeoff(timeoutSec?: number): Promise<boolean>
  • When armed you can tell the drone to takeoff. This will fly to a preset altitude of 3 metters above the home position. Once the drone is safely in the air you can use other commands to fly from there. If the drone is already flying takeoff will be ignored. Pass non-zer max_wait_seconds if you want the method to also wait until the takeoff altitude is achieved.

    Returns

    A boolean Promise

    Parameters

    • timeoutSec: number = 20

      Timeout (seconds) for the vehicle to reach desired altitude. A value of 0 implies no timeout.

    Returns Promise<boolean>

  • testLineOfSightToPoint(point: GeoPoint): Promise<boolean>
  • Returns whether the target point is visible from the perspective of the vehicle

    Returns

    Promise if target point is visible.

    Parameters

    Returns Promise<boolean>

  • waitOnLastTask(timeoutSec?: number): Promise<unknown>
  • Wait on the current task being executed.

    Returns

    Promise if the task completed without cancellation or timeout

    Parameters

    • timeoutSec: number = 3e+38

      seconds to wait for task completion.

    Returns Promise<unknown>