MCPcopy Create free account
hub / github.com/AdaCompNUS/summit / GnssSensor

Class GnssSensor

PythonAPI/examples/automatic_control.py:451–472  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

449
450
451class GnssSensor(object):
452 def __init__(self, parent_actor):
453 self.sensor = None
454 self._parent = parent_actor
455 self.lat = 0.0
456 self.lon = 0.0
457 world = self._parent.get_world()
458 bp = world.get_blueprint_library().find('sensor.other.gnss')
459 self.sensor = world.spawn_actor(bp, carla.Transform(carla.Location(x=1.0, z=2.8)),
460 attach_to=self._parent)
461 # We need to pass the lambda a weak reference to self to avoid circular
462 # reference.
463 weak_self = weakref.ref(self)
464 self.sensor.listen(lambda event: GnssSensor._on_gnss_event(weak_self, event))
465
466 @staticmethod
467 def _on_gnss_event(weak_self, event):
468 self = weak_self()
469 if not self:
470 return
471 self.lat = event.latitude
472 self.lon = event.longitude
473
474# ==============================================================================
475# -- CameraManager -------------------------------------------------------------

Callers 1

restartMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected