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

Method set_sensor

PythonAPI/examples/automatic_control.py:515–533  ·  view source on GitHub ↗
(self, index, notify=True)

Source from the content-addressed store, hash-verified

513 self.sensor.set_transform(self._camera_transforms[self.transform_index])
514
515 def set_sensor(self, index, notify=True):
516 index = index % len(self.sensors)
517 needs_respawn = True if self.index is None \
518 else self.sensors[index][0] != self.sensors[self.index][0]
519 if needs_respawn:
520 if self.sensor is not None:
521 self.sensor.destroy()
522 self.surface = None
523 self.sensor = self._parent.get_world().spawn_actor(
524 self.sensors[index][-1],
525 self._camera_transforms[self.transform_index],
526 attach_to=self._parent)
527 # We need to pass the lambda a weak reference to self to avoid
528 # circular reference.
529 weak_self = weakref.ref(self)
530 self.sensor.listen(lambda image: CameraManager._parse_image(weak_self, image))
531 if notify:
532 self.hud.notification(self.sensors[index][2])
533 self.index = index
534
535 def next_sensor(self):
536 self.set_sensor(self.index + 1)

Callers 2

next_sensorMethod · 0.95
restartMethod · 0.45

Calls 4

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

Tested by

no test coverage detected