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

Method set_sensor

PythonAPI/examples/manual_control_rss.py:805–824  ·  view source on GitHub ↗
(self, index, notify=True, force_respawn=False)

Source from the content-addressed store, hash-verified

803 self.set_sensor(self.index, notify=False, force_respawn=True)
804
805 def set_sensor(self, index, notify=True, force_respawn=False):
806 index = index % len(self.sensors)
807 needs_respawn = True if self.index is None else \
808 (force_respawn or (self.sensors[index][0] != self.sensors[self.index][0]))
809 if needs_respawn:
810 if self.sensor is not None:
811 self.sensor.destroy()
812 self.surface = None
813 self.sensor = self._parent.get_world().spawn_actor(
814 self.sensors[index][-1],
815 self._camera_transforms[self.transform_index][0],
816 attach_to=self._parent,
817 attachment_type=self._camera_transforms[self.transform_index][1])
818 # We need to pass the lambda a weak reference to self to avoid
819 # circular reference.
820 weak_self = weakref.ref(self)
821 self.sensor.listen(lambda image: CameraManager._parse_image(weak_self, image))
822 if notify:
823 self.hud.notification(self.sensors[index][2])
824 self.index = index
825
826 def next_sensor(self):
827 self.set_sensor(self.index + 1)

Callers 4

toggle_cameraMethod · 0.95
next_sensorMethod · 0.95
restartMethod · 0.45
parse_eventsMethod · 0.45

Calls 4

destroyMethod · 0.45
spawn_actorMethod · 0.45
_parse_imageMethod · 0.45
notificationMethod · 0.45

Tested by

no test coverage detected