Object Interactions

Overview

AirGen's object functionalities offer dynamic interaction capabilities with the environment. Users can place, manipulate, and remove objects, setting up diverse robot testing scenarios.

  • Spawn an object: Spawns a new object from a library of existing objects in the simulation context. For example, the following code spawns a cube 20 meters in front of the robot.

    client = airgen.VehicleClient()
    asset_list = client.simListAssets()
    pose = client.simGetVehiclePose()
    pose.position.x_val += 20
    scale = airgen.Vector3r(1,1,1)
    client.simSpawnObject("Cube_new", "Cube", pose, scale, physics_enabled=True)
    
  • List available assets: Returns a list of all the assets available within the scope of the current scene.

Once an object is created, its location/size etc. can be customized. For example, we can use the following functions to get and change the characteristics of the cube we spawned earlier.

  • Get current pose of an object: simGetObjectPose fetches the current pose of a specified object.

    pose = client.simGetObjectPose("Cube_new")
    
  • Change object pose: simSetObjectPose can be used to change an object's position and orientation.

    pose.position.x_val += 5
    client.simSetObjectPose("Cube_new", pose)
    
  • Get current scale of an object:

    scale = client.simGetObjectScale("Cube_new")
    
  • Change scale of an object:

    client.simSetObjectScale("Cube_new", airgen.Vector3r(5, 5, 5))
    
  • List all objects in a scene: To get a list of all the objects in a scene (and to select the ones we wish to control), we can use simListSceneObjects(). The objects can also be filtered using wildcards to find some that fit a name pattern.

    obj_list = client.simListSceneObjects()
    cubes_list = client.simListSceneObjects('Cube.*')
    
  • Remove an object: Finally, to remove an object from a scene, we can use simDestroyObject.

    client.simDestroyObject("Cube_new")
    

Quick Tips:

  • Ensure object paths are correct to avoid spawn errors.

  • Handle physics-enabled objects with caution.

  • Save your environment state often.