Class Car

The AirSim Car vehicle. Provides access to car state and control api.

Hierarchy

Constructors

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

    Parameters

    • name: string

      Unique vehicle name

    • controller: string = Car.DEFAULT_CONTROLLER

      Type of vehicle, default = PhysXCar

    • pawnPath: string = ''

      Vehicle blueprint path, when undefined uses the default blueprint for cars, PhysXCar

    Returns Car

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>

  • disableApiControl(): Promise<void>
  • 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>

  • Get the current car control settings.

    Returns

    Promise

    Returns Promise<CarControls>

  • getDefaultCameraNames(): 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>

  • Get the car's state

    Returns

    Promise

    Returns Promise<CarState>

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

  • Command the car with a new set of control settings.

    Returns

    A Promise to await on.

    Parameters

    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>