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

Method set_sensor

PythonAPI/examples/manual_control.py:927–946  ·  view source on GitHub ↗
(self, index, notify=True, force_respawn=False)

Source from the content-addressed store, hash-verified

925 self.set_sensor(self.index, notify=False, force_respawn=True)
926
927 def set_sensor(self, index, notify=True, force_respawn=False):
928 index = index % len(self.sensors)
929 needs_respawn = True if self.index is None else \
930 (force_respawn or (self.sensors[index][2] != self.sensors[self.index][2]))
931 if needs_respawn:
932 if self.sensor is not None:
933 self.sensor.destroy()
934 self.surface = None
935 self.sensor = self._parent.get_world().spawn_actor(
936 self.sensors[index][-1],
937 self._camera_transforms[self.transform_index][0],
938 attach_to=self._parent,
939 attachment_type=self._camera_transforms[self.transform_index][1])
940 # We need to pass the lambda a weak reference to self to avoid
941 # circular reference.
942 weak_self = weakref.ref(self)
943 self.sensor.listen(lambda image: CameraManager._parse_image(weak_self, image))
944 if notify:
945 self.hud.notification(self.sensors[index][2])
946 self.index = index
947
948 def next_sensor(self):
949 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