cozmo.world
The “world” represents the robot’s known view of its environment.
This view includes objects, faces and pets it knows about and can currently “see” with its camera, along with what actions or behaviors the robot is current performing and the images coming back from the camera (if any).
Almost all events emitted by the robot itself, objects, faces, pets and the
camera can be observed directly on the World
object, which is
itself accessible as cozmo.robot.Robot.world
.
For example, if you only need to know whether a particular cube has been
tapped, you can call the wait_for()
method
directly on that cube’s cozmo.objects.LightCube
instance. Eg:
my_cube.wait_for(cozmo.objects.EvtObjectTapped)
If, however, you want to wait for any cube to be tapped, you could instead
call the wait_for()
method on the
World
object instead. Eg:
robot.world.wait_for(cozmo.objects.EvtObjectTapped)
In either case, wait_for
will return the instance of the event’s
EvtObjectTapped
class, which includes a
obj
attribute, which identifies
exactly which cube has been tapped.
The World
object also has a cozmo.camera.Camera
instance
associated with it. It emits EvtNewCameraImage
objects whenever
a new camera image is available (generally up to 15 times per second),
which includes the raw image from the camera, as well as an annotated version
showing where faces, pets and objects have been observed.
Note
The camera must first be enabled to receive images by setting
image_stream_enabled
to True
.
Classes
|
A single image from Cozmo's camera. |
|
Dispatched when a new camera image is received and processed from the robot's camera. |
|
Represents the state of the world, as known to a Cozmo robot. |