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

Class GnssSensor

PythonAPI/examples/manual_control_rss.py:692–712  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

690
691
692class GnssSensor(object):
693 def __init__(self, parent_actor):
694 self.sensor = None
695 self._parent = parent_actor
696 self.lat = 0.0
697 self.lon = 0.0
698 world = self._parent.get_world()
699 bp = world.get_blueprint_library().find('sensor.other.gnss')
700 self.sensor = world.spawn_actor(bp, carla.Transform(carla.Location(x=1.0, z=2.8)), attach_to=self._parent)
701 # We need to pass the lambda a weak reference to self to avoid circular
702 # reference.
703 weak_self = weakref.ref(self)
704 self.sensor.listen(lambda event: GnssSensor._on_gnss_event(weak_self, event))
705
706 @staticmethod
707 def _on_gnss_event(weak_self, event):
708 self = weak_self()
709 if not self:
710 return
711 self.lat = event.latitude
712 self.lon = event.longitude
713
714# ==============================================================================
715# -- RssSensor --------------------------------------------------------

Callers 1

restartMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected