Class AirSim<T>

Type Parameters

Hierarchy

  • AirSim

Constructors

  • new AirSim<T>(vehicleClass: Constructor<T>, port?: number): AirSim<T>
  • new AirSim<T>(vehicleClass: Constructor<T>, ipAddress?: string): AirSim<T>
  • new AirSim<T>(vehicleClass: Constructor<T>, port?: number, ipAddress?: string): AirSim<T>
  • Create an AirSim client to a server on localhost. AirSim serves as a factory for Vehicles, (e.g., Car, Multirotor) hosted in an AirSim environment. When constructing a new AirSim client instance you must provide the class of Vehicle hosted by AirSim.

    Example

    new AirSim(Vehicle);
    new AirSim(Car, 80);

    Type Parameters

    Parameters

    • vehicleClass: Constructor<T>

      The type of vehicle hosted by the AirSim server

    • Optional port: number

      The AirSim server port number, default = 41451

    Returns AirSim<T>

  • Create an AirSim client to a server on host at ipAddress with default port, 41451. AirSim serves as a factory for Vehicles, (e.g., Car, Multirotor) hosted in an AirSim environment. When constructing a new AirSim client instance you must provide the class of Vehicle hosted by AirSim.

    Example

    new AirSim(Vehicle);
    new AirSim(Multirotor, '127.0.0.1');
    new AirSim(Car, 'localhost');

    Type Parameters

    Parameters

    • vehicleClass: Constructor<T>

      The type of vehicle hosted by the AirSim server

    • Optional ipAddress: string

    Returns AirSim<T>

  • Create an AirSim client to a server on host ip:port. AirSim serves as a factory for Vehicles, (e.g., Car, Multirotor) hosted in an AirSim environment. When constructing a new AirSim client instance you must provide the class of Vehicle hosted by AirSim.

    new AirSim(Vehicle);
    new AirSim(Multirotor, 80);
    new AirSim(Car, 80, '127.0.0.1');

    Type Parameters

    Parameters

    • vehicleClass: Constructor<T>

      The type of vehicle hosted by the AirSim server

    • Optional port: number

      The AirSim server port number, default = 41451

    • Optional ipAddress: string

    Returns AirSim<T>

Properties

_ip: string
_port: number
_session: Session
_vehicles: Map<string, T>

Accessors

  • get session(): Session
  • Access the Session with an AirSim server. Use hasSession() if you are not sure if the session has been created.

    Thows

    Error - When no session exists.

    Returns Session

Methods

  • addVehicle(vehicle: T, pose: Pose): Promise<boolean>
  • Create vehicle at runtime

    Returns

    Promise when vehicle was created

    Parameters

    • vehicle: T
    • pose: Pose

      Initial pose of the vehicle

    Returns Promise<boolean>

  • Clear a detection search

    Returns

    A Promise to await on

    Parameters

    Returns Promise<void>

  • clearPersistentMarkers(): Promise<void>
  • Clear any persistent markers from being displayed, i.e., those plotted with parameter isPersistent=true

    Returns

    A Promise to await on.

    Returns Promise<void>

  • close(): void
  • Close and shutdown the AirSim session.

    Returns void

  • confirmConnection(): Promise<void>
  • Checks state of connection and reports in Console so user can see the progress for connection.

    Returns Promise<void>

  • connect(): Promise<boolean>
  • Create a network connection to an AirSim server.

    Returns

    Promise if successful.

    Returns Promise<boolean>

  • continueForFrames(frames: number): Promise<void>
  • Continue (or resume if paused) the simulation for the specified number of frames, after which the simulation will be paused.

    Returns

    A Promise to await on.

    Parameters

    • frames: number

      Frames to run the simulation for

    Returns Promise<void>

  • continueForTime(seconds: number): Promise<void>
  • Continue the simulation for the specified number of seconds

    Returns

    A Promise to await on.

    Parameters

    • seconds: number

      Time (seconds) to run the simulation

    Returns Promise<void>

  • destroyObject(objectName: string): Promise<boolean>
  • Delete an object from the AirSim server environment.

    Returns

    Promise if success

    Parameters

    • objectName: string

      Name of object to delete

    Returns Promise<boolean>

  • disableWeather(): Promise<void>
  • Disable Weather effects. Needs to be called before using setWeatherParameter API

    Returns

    A Promise to await on.

    Returns Promise<void>

  • enableWeather(): Promise<void>
  • Enable Weather effects. Needs to be called before using setWeatherParameter() API

    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[]>

  • getAssets(): Promise<string[]>
  • The name of the assets that make up the scene.

    Returns

    An array of asset names.

    Returns Promise<string[]>

  • Get details about the external 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>

  • getClientVersion(): number
  • Get the client version number, an increaing sequence 1, 2, 3, ...

    Returns

    The client version number.

    Returns number

  • Get a single image

    Returns

    Uint8Array of compressed png image

    Parameters

    • cameraName: CameraName

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

    • imageType: ImageType

      Type of image required

    Returns Promise<Uint8Array>

  • getMinRequiredClientVersion(): Promise<number>
  • Get the lowest compatible client version.

    Returns

    The minimum compatible client version.

    Returns Promise<number>

  • getMinRequiredServerVersion(): number
  • Get the lowest compatible server version.

    Returns

    The minimum compatible server version.

    Returns number

  • getObjectPose(objectName: string): Promise<Pose>
  • Get the pose of a simulation object in the world frame.

    Returns

    The pose

    Parameters

    • objectName: string

      The name of the object who's pose is being requested.

    Returns Promise<Pose>

  • getObjectScale(objectName: string): Promise<Vector3>
  • Gets scale of an object in the world frame

    Returns

    The object scale

    Parameters

    • objectName: string

      Object to get the scale of

    Returns Promise<Vector3>

  • getSceneObjectNames(regEx?: string): Promise<string[]>
  • Get a listing of the names of all objects that makeup the AirSim seem.

    Returns

    An array of object names.

    Parameters

    • regEx: string = '.*'

      A regex for filtering the names.

    Returns Promise<string[]>

  • getServerVersion(): Promise<number>
  • Get the AirSim server version number, an increaing sequence 1, 2, 3, ...

    Returns

    The server version number.

    Returns Promise<number>

  • getSettingsString(): Promise<string>
  • Get a JSON string of the AirSim server settings.

    See

    Link

    Returns

    A JSON string.

    Returns Promise<string>

  • getVehicle(name: string): Promise<T>
  • Access a vehicle instance by name.

    Returns

    The vehicle

    Parameters

    • name: string

      The name of the vehicle.

    Returns Promise<T>

  • getVehicles(): Promise<T[]>
  • Lists the names of vehicles in the simulation.

    Returns

    List containing names of all vehicles

    Returns Promise<T[]>

  • Returns GeoPoints representing the minimum and maximum extents of the world

    Returns

    Tuple of GeoPoints [min,max]

    Returns Promise<[Vector3, Vector3]>

  • hasSession(): boolean
  • Test if a Session with an AirSim server exists.

    Returns

    True if session exists.

    Returns boolean

  • init(): Promise<void>
  • Initialize the internal state such as cache vehicles from an AirSim server.

    Returns Promise<void>

  • isPaused(): Promise<boolean>
  • Returns true if the simulation is paused

    Returns

    A Promise if the simulation is paused

    Returns Promise<boolean>

  • pause(): Promise<void>
  • Pauses simulation execution. Use resume() to continue.

    Returns

    A Promise to await on.

    Returns Promise<void>

  • ping(): Promise<boolean>
  • Ensure the AirSim server is reachable and active to respond to api requests.

    Returns

    Promise on success.

    Returns Promise<boolean>

  • plotArrow(start: Vector3, end: Vector3, color?: Color, thickness?: number, arrowSize?: number, durationOrPersistent?: number | true): Promise<void>
  • Plot an arrow in World NED frame.

    Returns

    A Promise to await on.

    Parameters

    • start: Vector3

      The 3D start positions of arrow, specified as Vector3 objects

    • end: Vector3

      The 3D end position of arrow, specified as Vector3 objects

    • color: Color = 'red'

      Line color as RGBA tuple of values from 0.0 to 1.0 or CSS color name. Default = 'red'.

    • thickness: number = 5.0

      Thickness of line. Default = 5.0.

    • arrowSize: number = 2.0

      Size of arrow head. Default = 2.0.

    • durationOrPersistent: number | true = true

      Duration (seconds) to display arrows or True to display indefinetly. Default = True.

    Returns Promise<void>

  • plotArrows(pointsStart: Vector3[], pointsEnd: Vector3[], color?: Color, thickness?: number, arrowSize?: number, durationOrPersistent?: number | true): Promise<void>
  • Plots a list of arrow in World NED frame, defined from points_start[0] to points_end[0], points_start[1] to points_end[1], ... , points_start[n-1] to points_end[n-1]

    Returns

    A Promise to await on.

    Parameters

    • pointsStart: Vector3[]
    • pointsEnd: Vector3[]
    • color: Color = 'red'

      Line color as RGBA tuple of values from 0.0 to 1.0 or CSS color name. Default = 'red'.

    • thickness: number = 5.0

      Thickness of line. Default = 5.0.

    • arrowSize: number = 2.0

      Size of arrow head. Default = 2.0.

    • durationOrPersistent: number | true = true

      Duration (seconds) to display arrows or True to display indefinetly. Default = True.

    Returns Promise<void>

  • plotLine(start: Vector3, end: Vector3, color?: Color, thickness?: number, durationOrPersistent?: number | boolean): Promise<void>
  • Plots a line strip in World NED frame, defined from points[0] to points[1], points[2] to points[3], ... , points[n-2] to points[n-1]

    Returns

    A Promise to await on.

    Parameters

    • start: Vector3
    • end: Vector3
    • color: Color = 'red'

      Line color as RGBA tuple of values from 0.0 to 1.0 or CSS color name. Default = 'red'.

    • thickness: number = 5.0

      Thickness of line. Default = 5.0.

    • durationOrPersistent: number | boolean = true

      Duration (seconds) to display lines or True to display indefinetly. Default = True.

    Returns Promise<void>

  • plotLineList(points: Vector3[], color?: Color, thickness?: number, durationOrPersistent?: number | boolean): Promise<void>
  • Plots a line strip in World NED frame, defined from points[0] to points[1], points[2] to points[3], ... , points[n-2] to points[n-1]

    Returns

    A Promise to await on.

    Parameters

    • points: Vector3[]

      List of 3D locations of line start and end points, specified as Vector3r objects. Must be even

    • color: Color = 'red'

      Line color as RGBA tuple of values from 0.0 to 1.0 or CSS color name. Default = 'red'.

    • thickness: number = 5.0

      Thickness of line. Default = 5.0.

    • durationOrPersistent: number | boolean = true

      Duration (seconds) to display lines or True to display indefinetly. Default = True.

    Returns Promise<void>

  • plotLineStrip(points: Vector3[], color?: Color, thickness?: number, durationOrPersistent?: number | true): Promise<void>
  • Plots a line strip in World NED frame, defined from points[0] to points[1], points[1] to points[2], ... , points[n-2] to points[n-1]

    Returns

    A Promise to await on.

    Parameters

    • points: Vector3[]

      Array of 3D locations of line start and end points, specified as Vector3r objects

    • color: Color = 'red'

      Line color as RGBA tuple of 0.0 to 1.0 values or CSS color name. Default = 'red'.

    • thickness: number = 5.0

      Thickness of line. Default = 5.

    • durationOrPersistent: number | true = true

      Duration (seconds) to display line-strip or True to display indefinetly. Default = true.

    Returns Promise<void>

  • plotPoint(point: Vector3, color?: Color, size?: number, durationOrPersistent?: number | true): Promise<void>
  • Plot a 3D point in World NED frame

    Returns

    A Promise to await on.

    Parameters

    • point: Vector3

      A Vector3 object

    • color: Color = 'red'

      Color of points as an RGBA tuple with value 0.0 to 1.0 or CSS color name, Default = 'red'.

    • size: number = 10

      Size of plotted point. Default = 10.

    • durationOrPersistent: number | true = true

      Duration (seconds) to display points or True to display indefinetly. Default = True.

    Returns Promise<void>

  • plotPoints(points: Vector3[], color?: Color, size?: number, durationOrPersistent?: number | true): Promise<void>
  • Plot a list of 3D points in World NED frame

    Returns

    A Promise to await on.

    Parameters

    • points: Vector3[]

      List of Vector3 objects

    • color: Color = 'red'

      Color of points as an RGBA tuple with value 0.0 to 1.0 or CSS color name, Default = 'red'.

    • size: number = 10

      Size of plotted point. Default = 10.

    • durationOrPersistent: number | true = true

      Duration (seconds) to display points or True to display indefinetly. Default = True.

    Returns Promise<void>

  • plotString(s: string, position: Vector3, scale?: number, color?: Color, durationOrPersistent?: number | true): Promise<void>
  • Plot a string at desired position in World NED frame.

    Returns

    A Promise to await on.

    Parameters

    • s: string
    • position: Vector3

      The position where the strings should be plotted.

    • scale: number = 5

      Font scale of transform name. Default = 5.

    • color: Color = 'red'

      Text color as RGBA tuple of values from 0.0 to 1.0 or CSS color name. Default = 'red'.

    • durationOrPersistent: number | true = true

      Duration (seconds) to display strings or True to display indefinetly. Default = True.

    Returns Promise<void>

  • plotStrings(strings: string[], positions: Vector3[], scale?: number, color?: Color, durationOrPersistent?: number | true): Promise<void>
  • Plots a list of strings at desired positions in World NED frame.

    Returns

    A Promise to await on.

    Parameters

    • strings: string[]

      List of strings to plot

    • positions: Vector3[]

      List of positions where the strings should be plotted. Should be in one-to-one correspondence with the strings' list

    • scale: number = 5

      Font scale of transform name. Default = 5.

    • color: Color = 'red'

      Text color as RGBA tuple of values from 0.0 to 1.0 or CSS color name. Default = 'red'.

    • durationOrPersistent: number | true = true

      Duration (seconds) to display strings or True to display indefinetly. Default = True.

    Returns Promise<void>

  • plotTransform(pose: Pose, scale?: number, thickness?: number, durationOrPersistent?: number | true): Promise<void>
  • Plots a transform in World NED frame.

    Returns

    A Promise to await on.

    Parameters

    • pose: Pose

      Pose object representing the transforms to plot

    • scale: number = 5.0

      Length of transform axes. Default = 5.

    • thickness: number = 5.0

      Thickness of transform axes. Default = 5.0.

    • durationOrPersistent: number | true = true

      Duration (seconds) to display transform or True to display indefinetly. Default = True.

    Returns Promise<void>

  • plotTransforms(poses: Pose[], scale?: number, thickness?: number, durationOrPersistent?: number | true): Promise<void>
  • Plots a list of transforms in World NED frame.

    Returns

    A Promise to await on.

    Parameters

    • poses: Pose[]

      Pose objects representing the transforms to plot

    • scale: number = 5.0

      Length of transforms' axes. Default = 5.

    • thickness: number = 5.0

      Thickness of transforms' axes. Default = 5.0.

    • durationOrPersistent: number | true = true

      Duration (seconds) to display transform or True to display indefinetly. Default = True.

    Returns Promise<void>

  • plotTransformsWithNames(poses: Pose[], names: string[], scale?: number, thickness?: number, textScale?: number, textColor?: Color, durationOrPersistent?: number | true): Promise<void>
  • Plots a list of transforms with their names in World NED frame.

    Returns

    A Promise to await on.

    Parameters

    • poses: Pose[]

      Pose objects representing the transforms to plot

    • names: string[]

      Strings with one-to-one correspondence to list of poses

    • scale: number = 5.0

      Length of transforms' axes. Default = 5.0.

    • thickness: number = 5.0

      Thickness of transforms' axes. Default = 5.0.

    • textScale: number = 10.0

      Font scale of transform name. Default = 10. *

    • textColor: Color = 'red'

      Color of transform name as RGBA tuple

      • of values from 0.0 to 1.0 or CSS color name. Default = 'red'.
    • durationOrPersistent: number | true = true

      Duration (seconds) to display transforms or True to display indefinetly. Default = True.

    Returns Promise<void>

  • printLogMessage(message: string, messageParam?: string, severity?: LogSeverity): Promise<void>
  • Prints the specified message in the simulator's window. If messageParam is supplied, then it's printed next to the message and in that case if this API is called with same message value but different messageParam again then previous line is overwritten with new line (instead of API creating new line on display). For example, printLogMessage("Iteration: ", i.toString()) keeps updating same line on display when API is called with different values of i. The valid values of severity parameter corresponds to different colors.

    Returns

    A Promise to await on.

    Parameters

    • message: string

      Message to be printed

    • messageParam: string = ''

      Parameter to be printed next to the message

    • severity: LogSeverity = LogSeverity.INFO

      The severity level of the message

    Returns Promise<void>

  • reset(): Promise<void>
  • Reset the vehicle to its original starting state Note that you must call enableApiControl() and arm() again after the call to reset

    Returns

    A Promise to await on.

    Returns Promise<void>

  • resume(): Promise<void>
  • Resume simulation execution.

    Returns

    A Promise to await on.

    Returns Promise<void>

  • runConsoleCommand(cmd: string): Promise<boolean>
  • Allows the client to execute a command in Unreal's native console, via an API. Affords access to the countless built-in commands such as "stat unit", "stat fps", "open [map]", adjust any config settings, etc. Allows the user to create bespoke APIs very easily, by adding a custom event to the level blueprint, and then calling the console command "ce MyEventName [args]". No recompilation of AirSim needed!

    Returns

    Promise if successful.

    Parameters

    • cmd: string

      Unreal Engine Console command to run

    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 degree

    Returns Promise<void>

  • Control the pose of a selected camera

    Returns

    A 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 void

  • setLightIntensity(lightName: string, intensity: number): Promise<boolean>
  • Change intensity of named light

    Returns

    Promise if successful, otherwise False

    Parameters

    • lightName: string

      Name of light to change

    • intensity: number

      New intensity value [0-1]

    Returns Promise<boolean>

  • setObjectPose(objectName: string, pose: Pose, teleport?: boolean): Promise<boolean>
  • Set the pose of the object(actor) in the environment The specified actor must have Mobility set to movable, otherwise there will be undefined behaviour. @ see

    Link

    for details on how to set Mobility and the effect of Teleport parameter

    Returns

    Promise when the move was successful

    Parameters

    • objectName: string

      Name of the object(actor) to move

    • pose: Pose

      Desired Pose of the object

    • teleport: boolean = true

      Whether to move the object immediately without affecting their velocity

    Returns Promise<boolean>

  • setObjectScale(objectName: string, scaleVector: Vector3): Promise<boolean>
  • Sets scale of an object in the world frame

    Returns

    Promise when scale change was successful

    Parameters

    • objectName: string

      Object to set the scale of

    • scaleVector: Vector3

      Desired scale of object

    Returns Promise<boolean>

  • setTimeOfDay(isEnabled: boolean, startDatetime?: string, isStartDatetimeDst?: boolean, celestialClockSpeed?: number, updateIntervalSecs?: number, moveSun?: boolean): Promise<void>
  • Control the position of Sun in the environment. The Sun's position is computed using the coordinates specified in OriginGeopoint in settings for the date-time specified in the argument, else if the string is empty, current date & time is used

    Returns

    A Promise to await on.

    Parameters

    • isEnabled: boolean

      True to enable time-of-day effect, False to reset the position to original

    • startDatetime: string = ''

      Date & Time in %Y-%m-%d %H:%M:%S format, e.g. 2018-02-12 15:20:00

    • isStartDatetimeDst: boolean = false

      True to adjust for Daylight Savings Time

    • celestialClockSpeed: number = 1

      Run celestial clock faster or slower than simulation clock E.g. Value 100 means for every 1 second of simulation clock, Sun's position is advanced by 100 seconds so Sun will move in sky much faster

    • updateIntervalSecs: number = 60

      Interval to update the Sun's position

    • moveSun: boolean = true

      Whether or not to move the Sun

    Returns Promise<void>

  • Enable various weather effects

    Returns

    A Promise to await on.

    Parameters

    • param: WeatherParameter

      Weather effect to be enabled

    • val: number

      Intensity of the effect, Range 0-1

    Returns Promise<void>

  • setWind(wind: Vector3): Promise<void>
  • Set simulated wind, in World frame, NED direction, m/s

    Returns

    A Promise to await on.

    Parameters

    • wind: Vector3

      Wind, in World frame, NED direction, in m/s

    Returns Promise<void>

  • spawnObject(objectName: string, assetName: string, pose: Pose, scale: Vector3, physicsEnabled?: boolean, isBlueprint?: boolean): Promise<string>
  • Spawn a new instance of an existing sim object

    Returns

    Name of spawned object, in case it had to be modified

    Parameters

    • objectName: string

      Desired name of new object

    • assetName: string

      Name of asset(mesh) in the project database

    • pose: Pose

      Desired pose of object

    • scale: Vector3

      Desired scale of object

    • physicsEnabled: boolean = false

      Whether to enable physics for the object

    • isBlueprint: boolean = false

      Whether to spawn a blueprint or an actor

    Returns Promise<string>

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

  • testLineOfSightBetweenPoints(point1: GeoPoint, point2: GeoPoint): Promise<boolean>
  • Returns whether the target point is visible from the perspective of the source point

    Returns

    True if success; false otherwise

    Parameters

    Returns Promise<boolean>