Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Python API for new object functions #2897

Merged
merged 2 commits into from
Jul 31, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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