Pegasus Interface

File: pegasus_interface.py
Author: Marcelo Jacinto (marcelo.jacinto@tecnico.ulisboa.pt)
License: BSD-3-Clause. Copyright (c) 2023, Marcelo Jacinto. All rights reserved.
Description: Definition of the PegasusInterface class (a singleton) that is used to manage the Pegasus framework.

Classes:

PegasusInterface

PegasusInterface is a singleton class (there is only one object instance at any given time) that will be used to

class pegasus.simulator.logic.interface.pegasus_interface.PegasusInterface

Bases: object

PegasusInterface is a singleton class (there is only one object instance at any given time) that will be used to

Methods:

__del__()

Destructor for the object.

__init__()

Initialize the PegasusInterface singleton object (only runs once at a time)

__new__(cls)

Allocates the memory and creates the actual PegasusInterface object is not instance exists yet.

clear_scene()

Method that when invoked will clear all vehicles and the simulation environment, leaving only an empty world with a physics environment.

generate_quadrotor_config_from_yaml(file)

_summary_

get_all_vehicles()

Method that returns a list of vehicles that are considered active in the simulator

get_default_environments()

Method that returns a dictionary containing all the default simulation environments and their path

get_vehicle(stage_prefix)

Method that returns the vehicle object given its 'stage_prefix', i.e., the name the vehicle was spawned with in the simulator.

initialize_world()

Method that initializes the world object

load_asset(usd_asset, stage_prefix)

Method that will attempt to load an asset into the current simulation world, given the USD asset path.

load_environment(usd_path[, force_clear])

Method that loads a given world (specified in the usd_path) into the simulator.

load_environment_async(usd_path[, backend, ...])

Method that loads a given world (specified in the usd_path) into the simulator asynchronously.

load_nvidia_environment([environment_asset])

Method that is used to load NVidia internally provided USD stages into the simulaton World

set_ardupilot_default_airframe(airframe)

Method that allows a user to save a new ArduPilot default airframe for the extension.

set_ardupilot_path(path)

Method that allows a user to save a new ArduPilot directory in the configuration files of the extension.

set_default_global_coordinates()

Method that sets the latitude, longitude and altitude from the pegasus interface to the default global coordinates specified in the extension configuration file

set_global_coordinates([latitude, ...])

Method that can be used to set the latitude, longitude and altitude of the simulation world at the origin.

set_new_default_global_coordinates([...])

set_px4_default_airframe(airframe)

Method that allows a user to save a new px4 default airframe for the extension.

set_px4_path(path)

Method that allows a user to save a new px4 directory in the configuration files of the extension.

set_viewport_camera(camera_position, ...)

Sets the viewport camera to given position and makes it point to another target position.

set_world_settings([physics_dt, ...])

Set the current world settings to the pre-defined settings.

Attributes:

altitude

The altitude of the origin of the simulated world in meters.

ardupilot_default_airframe

A string with the ArduPilot default airframe (if it was setup).

ardupilot_path

A string with the installation directory for ArduPilot (if it was setup).

latitude

The latitude of the origin of the simulated world in degrees.

longitude

The longitude of the origin of the simulated world in degrees.

px4_default_airframe

A string with the PX4 default airframe (if it was setup).

px4_path

A string with the installation directory for PX4 (if it was setup).

vehicle_manager

The instance of the VehicleManager.

world

The current omni.isaac.core.world World instance

__del__()

Destructor for the object. Destroys the only existing instance of this class.

__init__()

Initialize the PegasusInterface singleton object (only runs once at a time)

static __new__(cls)

Allocates the memory and creates the actual PegasusInterface object is not instance exists yet. Otherwise, returns the existing instance of the PegasusInterface class.

Returns:

the single instance of the VehicleManager class

Return type:

VehicleManger

clear_scene()

Method that when invoked will clear all vehicles and the simulation environment, leaving only an empty world with a physics environment.

generate_quadrotor_config_from_yaml(file)

_summary_

Parameters:

file (str) – _description_

Returns:

_description_

Return type:

_type_

get_all_vehicles()

Method that returns a list of vehicles that are considered active in the simulator

Returns:

A list of all vehicles that are currently instantiated.

Return type:

list

get_default_environments()

Method that returns a dictionary containing all the default simulation environments and their path

get_vehicle(stage_prefix)

Method that returns the vehicle object given its ‘stage_prefix’, i.e., the name the vehicle was spawned with in the simulator.

Parameters:

stage_prefix (str) – The name the vehicle will present in the simulator when spawned.

Returns:

Returns a vehicle object that was spawned with the given ‘stage_prefix’

Return type:

Vehicle

initialize_world()

Method that initializes the world object

load_asset(usd_asset, stage_prefix)

Method that will attempt to load an asset into the current simulation world, given the USD asset path.

Parameters:
  • usd_asset (str) – The path where the USD file describing the world is located.

  • stage_prefix (str) – The name the vehicle will present in the simulator when spawned.

load_environment(usd_path, force_clear=False)

Method that loads a given world (specified in the usd_path) into the simulator. If invoked from a python app, this method should have force_clear=False, as the world reset and stop are performed asynchronously by this method, and when we are operating in App mode, we want everything to run in sync.

Parameters:
  • usd_path (str) – The path where the USD file describing the world is located.

  • force_clear (bool) – Whether to perform a clear before loading the asset. Defaults to False.

async load_environment_async(usd_path, backend='px4', force_clear=False)

Method that loads a given world (specified in the usd_path) into the simulator asynchronously.

Parameters:
  • usd_path (str) – The path where the USD file describing the world is located.

  • force_clear (bool) – Whether to perform a clear before loading the asset. Defaults to False.

  • App (It should be set to True only if the method is invoked from an) –

load_nvidia_environment(environment_asset='Hospital/hospital.usd')

Method that is used to load NVidia internally provided USD stages into the simulaton World

Parameters:

environment_asset (str) – The name of the nvidia asset inside the /Isaac/Environments folder. Default to Hospital/hospital.usd.

set_ardupilot_default_airframe(airframe)

Method that allows a user to save a new ArduPilot default airframe for the extension.

Parameters:

airframe (str) – The new ArduPilot default airframe

set_ardupilot_path(path)

Method that allows a user to save a new ArduPilot directory in the configuration files of the extension.

Parameters:

absolute_path (str) – The new path of the ArduPilot installation directory

set_default_global_coordinates()

Method that sets the latitude, longitude and altitude from the pegasus interface to the default global coordinates specified in the extension configuration file

set_global_coordinates(latitude=None, longitude=None, altitude=None)

Method that can be used to set the latitude, longitude and altitude of the simulation world at the origin.

Parameters:
  • latitude (float) – The latitude of the origin of the simulated world in degrees. Defaults to None.

  • longitude (float) – The longitude of the origin of the simulated world in degrees. Defaults to None.

  • altitude (float) – The altitude of the origin of the simulated world in meters. Defaults to None.

set_new_default_global_coordinates(latitude=None, longitude=None, altitude=None)
set_px4_default_airframe(airframe)

Method that allows a user to save a new px4 default airframe for the extension.

Parameters:

absolute_path (str) – The new px4 default airframe

set_px4_path(path)

Method that allows a user to save a new px4 directory in the configuration files of the extension.

Parameters:

absolute_path (str) – The new path of the px4-autopilot installation directory

set_viewport_camera(camera_position, camera_target)

Sets the viewport camera to given position and makes it point to another target position.

Parameters:
  • camera_position (list) – A list with [X, Y, Z] coordinates of the camera in ENU inertial frame.

  • camera_target (list) – A list with [X, Y, Z] coordinates of the target that the camera should point to in the ENU inertial frame.

set_world_settings(physics_dt=None, stage_units_in_meters=None, rendering_dt=None, device=None)

Set the current world settings to the pre-defined settings. TODO - finish the implementation of this method. For now these new setting will never override the default ones.

property altitude

The altitude of the origin of the simulated world in meters.

Returns:

The latitude of the origin of the simulated world in meters.

Return type:

float

property ardupilot_default_airframe

A string with the ArduPilot default airframe (if it was setup). Otherwise it is None.

Returns:

A string with the ArduPilot default airframe (if it was setup). Otherwise it is None.

Return type:

str

property ardupilot_path

A string with the installation directory for ArduPilot (if it was setup). Otherwise it is None.

Returns:

A string with the installation directory for ArduPilot (if it was setup). Otherwise it is None.

Return type:

str

property latitude

The latitude of the origin of the simulated world in degrees.

Returns:

The latitude of the origin of the simulated world in degrees.

Return type:

float

property longitude

The longitude of the origin of the simulated world in degrees.

Returns:

The longitude of the origin of the simulated world in degrees.

Return type:

float

property px4_default_airframe

A string with the PX4 default airframe (if it was setup). Otherwise it is None.

Returns:

A string with the PX4 default airframe (if it was setup). Otherwise it is None.

Return type:

str

property px4_path

A string with the installation directory for PX4 (if it was setup). Otherwise it is None.

Returns:

A string with the installation directory for PX4 (if it was setup). Otherwise it is None.

Return type:

str

property vehicle_manager

The instance of the VehicleManager.

Returns:

The current instance of the VehicleManager.

Return type:

VehicleManager

property world

The current omni.isaac.core.world World instance

Returns:

The world instance

Return type:

omni.isaac.core.world