def groundElevationAt(self, pos): origin = utils.scenicToLGSVLPosition(pos, 100000) result = self.client.raycast(origin, lgsvl.Vector(0, -1, 0), 1) if result is None: warnings.warn(f'no ground at position {pos}') return 0 return result.point.y
def createObjectInSimulator(self, obj): # Figure out what type of LGSVL object this is if not hasattr(obj, 'lgsvlName'): raise RuntimeError(f'object {obj} does not have an lgsvlName property') if not hasattr(obj, 'lgsvlAgentType'): raise RuntimeError(f'object {obj} does not have an lgsvlAgentType property') name = obj.lgsvlName agentType = obj.lgsvlAgentType # Set up position and orientation state = lgsvl.AgentState() elevation = obj.elevation if elevation is None: elevation = self.groundElevationAt(obj.position) state.transform.position = utils.scenicToLGSVLPosition(obj.position, elevation) state.transform.rotation = utils.scenicToLGSVLRotation(obj.heading) # Create LGSVL object lgsvlObj = self.client.add_agent(name, agentType, state) obj.lgsvlObject = lgsvlObj # Initialize Data self.data[obj] = {} # Initialize Apollo if needed if getattr(obj, 'apolloVehicle', None): self.initApolloFor(obj, lgsvlObj)
def __init__(self, waypoints): self.waypoints = tuple(waypoints) if not isinstance(self.waypoints[0], lgsvl.DriveWaypoint): pts = [] for wp in self.waypoints: elev = veneer.simulation().groundElevationAt(wp.position) pos = utils.scenicToLGSVLPosition(wp.position, y=elev) rot = utils.scenicToLGSVLRotation(wp.heading) pt = lgsvl.DriveWaypoint(pos, wp.speed, rot) pts.append(pt) self.waypoints = tuple(pts) self.lastTime = -2
def __init__(self, scene, client, verbosity=0): timestep = scene.params.get('time_step', 1.0 / 10) super().__init__(scene, timestep=timestep, verbosity=verbosity) self.client = client self.usingApollo = False self.data = {} self.collisionOccurred = False # Reset simulator (deletes all existing objects) self.client.reset() # Create LGSVL objects corresponding to Scenic objects self.lgsvlObjects = {} for obj in self.objects: # Figure out what type of LGSVL object this is if not hasattr(obj, 'lgsvlObject'): continue # not an LGSVL object if not hasattr(obj, 'lgsvlName'): raise RuntimeError( f'object {obj} does not have an lgsvlName property') if not hasattr(obj, 'lgsvlAgentType'): raise RuntimeError( f'object {obj} does not have an lgsvlAgentType property') name = obj.lgsvlName agentType = obj.lgsvlAgentType # Set up position and orientation state = lgsvl.AgentState() elevation = obj.elevation if elevation is None: elevation = self.groundElevationAt(obj.position) state.transform.position = utils.scenicToLGSVLPosition( obj.position, elevation) state.transform.rotation = utils.scenicToLGSVLRotation(obj.heading) # Create LGSVL object lgsvlObj = self.client.add_agent(name, agentType, state) obj.lgsvlObject = lgsvlObj # Initialize Data self.data[obj] = {} # Initialize Apollo if needed if getattr(obj, 'apolloVehicle', None): self.initApolloFor(obj, lgsvlObj)