Skip to content

Commit 1eb95ef

Browse files
committed
Add example script to create objects
1 parent 6bc4300 commit 1eb95ef

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import setup_path
2+
import airsim
3+
import random
4+
import time
5+
6+
client = airsim.VehicleClient()
7+
client.confirmConnection()
8+
9+
assets = client.simListAssets()
10+
print(f"Assets: {assets}")
11+
12+
scale = airsim.Vector3r(1.0, 1.0, 1.0)
13+
14+
# asset_name = random.choice(assets)
15+
asset_name = '1M_Cube_Chamfer'
16+
17+
desired_name = f"{asset_name}_spawn_{random.randint(0, 100)}"
18+
pose = airsim.Pose(position_val=airsim.Vector3r(5.0, 0.0, 0.0))
19+
20+
obj_name = client.simSpawnObject(desired_name, asset_name, pose, scale, True)
21+
22+
print(f"Created object {obj_name} from asset {asset_name} "
23+
f"at pose {pose}, scale {scale}")
24+
25+
all_objects = client.simListSceneObjects()
26+
if obj_name not in all_objects:
27+
print(f"Object {obj_name} not present!")
28+
29+
time.sleep(30.0)
30+
31+
print(f"Destroying {obj_name}")
32+
client.simDestroyObject(obj_name)

0 commit comments

Comments
 (0)