Skip to content

Commit 373f303

Browse files
committed
Add destinations to spawn points
1 parent e84983c commit 373f303

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

lgsvl/geometry.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,3 +105,29 @@ def to_json(self):
105105

106106
def __repr__(self):
107107
return "Transform(position={}, rotation={})".format(self.position, self.rotation)
108+
109+
110+
class Spawn:
111+
def __init__(self, transform=None, destinations=None):
112+
if transform is None: transform = Transform()
113+
if destinations is None: destinations = []
114+
self.position = transform.position
115+
self.rotation = transform.rotation
116+
self.destinations = destinations
117+
118+
@staticmethod
119+
def from_json(j):
120+
spawn_point = Transform.from_json(j)
121+
destinations = []
122+
for d in j["destinations"]:
123+
destinations.append(Transform.from_json(d))
124+
125+
return Spawn(spawn_point, destinations)
126+
127+
def to_json(self):
128+
return {"position": self.position.to_json(), "rotation": self.rotation.to_json()}
129+
130+
def __repr__(self):
131+
return "Spawn(position={}, rotation={}, destinations={})".format(
132+
self.transform.position, self.transform.rotation, self.destinations
133+
)

lgsvl/simulator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from .remote import Remote
88
from .agent import Agent, AgentType, AgentState
99
from .sensor import GpsData
10-
from .geometry import Vector, Transform
10+
from .geometry import Vector, Transform, Spawn
1111
from .utils import accepts, ObjectState
1212
from .controllable import Controllable
1313

@@ -171,7 +171,7 @@ def set_time_of_day(self, time, fixed=True):
171171

172172
def get_spawn(self):
173173
spawns = self.remote.command("map/spawn/get")
174-
return [Transform.from_json(spawn) for spawn in spawns]
174+
return [Spawn.from_json(spawn) for spawn in spawns]
175175

176176
@accepts(Transform)
177177
def map_to_gps(self, transform):

0 commit comments

Comments
 (0)