Skip to content

Commit

Permalink
Add Python API for new object functions (#2897)
Browse files Browse the repository at this point in the history
* Add Python API for scale/spawn/destroy object functions
  • Loading branch information
Sai Vemprala authored Jul 31, 2020
1 parent 91e0da4 commit fd4a8fe
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions PythonClient/airsim/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,32 @@ def simSetObjectPose(self, object_name, pose, teleport = True):
"""
return self.client.call('simSetObjectPose', object_name, pose, teleport)

def simGetObjectScale(self, object_name):
"""
Gets scale of an object in the world
Args:
object_name (str): Object to get the scale of
Returns:
airsim.Vector3r: Scale
"""
scale = self.client.call('simGetObjectScale', object_name)
return Vector3r.from_msgpack(scale)

def simSetObjectScale(self, object_name, scale_vector):
"""
Sets scale of an object in the world
Args:
object_name (str): Object to set the scale of
scale_vector (airsim.Vector3r): Desired scale of object
Returns:
bool: True if scale change was successful
"""
return self.client.call('simSetObjectScale', object_name, scale_vector)

def simListSceneObjects(self, name_regex = '.*'):
"""
Lists the objects present in the environment
Expand All @@ -357,6 +383,31 @@ def simListSceneObjects(self, name_regex = '.*'):
"""
return self.client.call('simListSceneObjects', name_regex)

def simSpawnObject(self, object_name, asset_name, pose, scale):
"""Spawned selected object in the world
Args:
object_name (str): Desired name of new object
asset_name (str): Name of asset(mesh) in the project database
pose (airsim.Pose): Desired pose of object
scale (airsim.Vector3r): Desired scale of object
Returns:
str: Name of spawned object, in case it had to be modified
"""
return self.client.call('simSpawnObject', object_name, asset_name, pose, scale)

def simDestroyObject(self, object_name):
"""Removes selected object from the world
Args:
object_name (str): Name of object to be removed
Returns:
bool: True if object is queued up for removal
"""
return self.client.call('simDestroyObject', object_name)

def simSetSegmentationObjectID(self, mesh_name, object_id, is_name_regex = False):
"""
Set segmentation ID for specific objects
Expand Down

0 comments on commit fd4a8fe

Please sign in to comment.