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

Class GnssSensor

PythonAPI/examples/manual_control.py:747–767  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

745
746
747class GnssSensor(object):
748 def __init__(self, parent_actor):
749 self.sensor = None
750 self._parent = parent_actor
751 self.lat = 0.0
752 self.lon = 0.0
753 world = self._parent.get_world()
754 bp = world.get_blueprint_library().find('sensor.other.gnss')
755 self.sensor = world.spawn_actor(bp, carla.Transform(carla.Location(x=1.0, z=2.8)), attach_to=self._parent)
756 # We need to pass the lambda a weak reference to self to avoid circular
757 # reference.
758 weak_self = weakref.ref(self)
759 self.sensor.listen(lambda event: GnssSensor._on_gnss_event(weak_self, event))
760
761 @staticmethod
762 def _on_gnss_event(weak_self, event):
763 self = weak_self()
764 if not self:
765 return
766 self.lat = event.latitude
767 self.lon = event.longitude
768
769
770# ==============================================================================

Callers 1

restartMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected