Class Vehicle

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 Vehicle(name: string, controller?: string, pawnPath?: string): Vehicle
  • Create vehicle

    Parameters

    • name: string

      Name of the vehicle being created

    • controller: string = ''
    • pawnPath: string = ''

      Vehicle blueprint path, default empty wbich uses the default blueprint for the vehicle type

    Returns Vehicle

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

  • 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>

  • Clear a detection search

    Returns

    A Promise to await on

    Parameters

    Returns Promise<void>

  • disableApiControl(): Promise<void>
  • Disables API control.

    Returns

    A Promise to await on.

    Returns Promise<void>

  • enableApiControl(): Promise<void>
  • Enables API control.

    Returns

    A Promise to await on.

    Returns Promise<void>

  • Find the detections in the camera field of view defined by the search details

    Returns

    Array of object detections

    Parameters

    Returns Promise<DetectionInfo[]>

  • 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>

  • Get the vehicle's collision state.

    Returns

    The collision state info.

    Returns Promise<CollisionInfo>

  • Access the names of the default cameras.

    See

    default cameras

    Returns

    The camera names for this type of vehicle.

    Returns CameraName[]

  • 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>

  • Get multiple images

    See

    Link

    for details and examples

    Returns

    The ImageResponse(s)

    Parameters

    Returns Promise<ImageResponse[]>

  • 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>

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

    Returns

    Promise if API is enabled.

    Returns Promise<boolean>

  • 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>

  • 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>