Skip to content

Commit 05f610b

Browse files
daviduhmhadiTab
authored andcommitted
[AUTO-7652] Add example python API script for spawning multi robots
1 parent c6affda commit 05f610b

File tree

3 files changed

+70
-3
lines changed

3 files changed

+70
-3
lines changed

lgsvl/wise/wise.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ class DefaultAssets:
5757
# https://wise.svlsimulator.com/maps/profile/671868be-44f9-44a1-913c-cb0f29d12634
5858
map_straight2laneopposing = "671868be-44f9-44a1-913c-cb0f29d12634"
5959

60+
# Map loaded in the quickstart scripts. Changing the map may lead to unexpected behaviour in the quickstart scripts. Default value is "LGSeocho".
61+
# https://wise.svlsimulator.com/maps/profile/26546191-86e8-4b53-9432-1cecbbd95c87
62+
map_lgseocho = "26546191-86e8-4b53-9432-1cecbbd95c87"
63+
6064
# Ego vehicle that is loaded in most of the quickstart scripts. Default value is "Lincoln2017MKZ" using the "Apollo 5.0" sensor configuration.
6165
# This includes a bridge connection if needed and also bunch of sensors including LIDAR.
6266
# https://wise.svlsimulator.com/vehicles/profile/73805704-1e46-4eb6-b5f9-ec2244d5951e/edit/configuration/47b529db-0593-4908-b3e7-4b24a32a0f70
@@ -84,3 +88,19 @@ class DefaultAssets:
8488
# This has sensors for modular testing.
8589
# https://wise.svlsimulator.com/vehicles/profile/73805704-1e46-4eb6-b5f9-ec2244d5951e/edit/configuration/2e9095fa-c9b9-4f3f-8d7d-65fa2bb03921
8690
ego_lincoln2017mkz_apollo6_modular = "2e9095fa-c9b9-4f3f-8d7d-65fa2bb03921"
91+
92+
# Cloi robot that is loaded in quickstart/tests scripts. Default value is "LGCloi" using the "Navigation2" sensor configuration.
93+
# https://wise.svlsimulator.com/vehicles/profile/20609b67-6dbd-40ad-9b46-e6bc455278ed/edit/configuration/c2207cd4-c8d0-4a12-b5b7-c79ab748becc
94+
ego_lgcloi_navigation2 = "c2207cd4-c8d0-4a12-b5b7-c79ab748becc"
95+
96+
# Cloi robot that is loaded in quickstart/tests scripts. Default value is "LGCloi" using the "Nav2_Multi_Robot1" sensor configuration.
97+
# https://wise.svlsimulator.com/vehicles/profile/20609b67-6dbd-40ad-9b46-e6bc455278ed/edit/configuration/eee61d18-c6e3-4292-988d-445802aaee97
98+
ego_lgcloi_navigation2_multi_robot1 = "eee61d18-c6e3-4292-988d-445802aaee97"
99+
100+
# Cloi robot that is loaded in quickstart/tests scripts. Default value is "LGCloi" using the "Nav2_Multi_Robot2" sensor configuration.
101+
# https://wise.svlsimulator.com/vehicles/profile/20609b67-6dbd-40ad-9b46-e6bc455278ed/edit/configuration/f9c5ace0-969a-4ade-8208-87d09d1a53f8
102+
ego_lgcloi_navigation2_multi_robot2 = "f9c5ace0-969a-4ade-8208-87d09d1a53f8"
103+
104+
# Cloi robot that is loaded in quickstart/tests scripts. Default value is "LGCloi" using the "Nav2_Multi_Robot3" sensor configuration.
105+
# https://wise.svlsimulator.com/vehicles/profile/20609b67-6dbd-40ad-9b46-e6bc455278ed/edit/configuration/cfdb1484-91b7-4f27-b729-e313cc31ed8e
106+
ego_lgcloi_navigation2_multi_robot3 = "cfdb1484-91b7-4f27-b729-e313cc31ed8e"
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/usr/bin/env python3
2+
#
3+
# Copyright (c) 2021 LG Electronics, Inc.
4+
#
5+
# This software contains code licensed as described in LICENSE.
6+
#
7+
8+
import time
9+
from environs import Env
10+
import lgsvl
11+
12+
print("Python API Quickstart #35: Spawning multi robots with bridge connections")
13+
env = Env()
14+
15+
sim = lgsvl.Simulator(env.str("LGSVL__SIMULATOR_HOST", lgsvl.wise.SimulatorSettings.simulator_host), env.int("LGSVL__SIMULATOR_PORT", lgsvl.wise.SimulatorSettings.simulator_port))
16+
17+
map_seocho = lgsvl.wise.DefaultAssets.map_lgseocho
18+
robots = [
19+
lgsvl.wise.DefaultAssets.ego_lgcloi_navigation2_multi_robot1,
20+
lgsvl.wise.DefaultAssets.ego_lgcloi_navigation2_multi_robot2,
21+
lgsvl.wise.DefaultAssets.ego_lgcloi_navigation2_multi_robot3,
22+
]
23+
24+
if sim.current_scene == map_seocho:
25+
sim.reset()
26+
else:
27+
sim.load(map_seocho)
28+
29+
spawns = sim.get_spawn()
30+
spawn = spawns[1]
31+
right = lgsvl.utils.transform_to_right(spawn)
32+
33+
for i, robot in enumerate(robots):
34+
state = lgsvl.AgentState()
35+
state.transform.position = spawn.position + (1.0 * i * right)
36+
state.transform.rotation = spawn.rotation
37+
ego = sim.add_agent(robot, lgsvl.AgentType.EGO, state)
38+
print("Spawned a robot at:", state.transform.position)
39+
40+
ego.connect_bridge(env.str("LGSVL__AUTOPILOT_0_HOST", lgsvl.wise.SimulatorSettings.bridge_host), env.int("LGSVL__AUTOPILOT_0_PORT", lgsvl.wise.SimulatorSettings.bridge_port))
41+
print("Waiting for connection...")
42+
while not ego.bridge_connected:
43+
time.sleep(1)
44+
45+
print("Bridge connected:", ego.bridge_connected)
46+
47+
print("Running the simulation...")
48+
sim.run()

quickstart/36-send-destination-to-nav2.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@
1414

1515
sim = lgsvl.Simulator(env.str("LGSVL__SIMULATOR_HOST", lgsvl.wise.SimulatorSettings.simulator_host), env.int("LGSVL__SIMULATOR_PORT", lgsvl.wise.SimulatorSettings.simulator_port))
1616

17-
# TODO: Make public assets for LGSeocho with NavOrigin and cloi sensor config
18-
map_seocho = "9b494638-b3e9-4239-9f3f-51b2c68cd292"
19-
ego_cloi = "4717598d-6c67-48a1-9a02-988a89d8660c"
17+
map_seocho = lgsvl.wise.DefaultAssets.map_lgseocho
18+
ego_cloi = lgsvl.wise.DefaultAssets.ego_lgcloi_navigation2
2019

2120
if sim.current_scene == map_seocho:
2221
sim.reset()

0 commit comments

Comments
 (0)