anki_vector.objects¶
Object and Light Cube recognition.
Vector can recognize and track a number of different types of objects.
These objects may be visible (currently observed by the robot’s camera) and tappable (in the case of the Light Cube that ships with the robot).
The Light Cube is known as a LightCube
by the SDK. The cube
has controllable lights, and sensors that can determine when it’s being
moved or tapped.
Objects can generate events which can be subscribed to from the anki_vector.events class, such as object_appeared (of type EvtObjectAppeared), and object_disappeared (of type EvtObjectDisappeared), which are broadcast based on both robot originating events and local state.
All observable objects have a marker of a known size attached to them, which allows Vector
to recognize the object and its position and rotation (“pose”). You can attach
markers to your own objects for Vector to recognize by printing them out from the
online documentation. They will be detected as CustomObject
instances.
Vector connects to his Light Cube with BLE.
Classes
|
Vector’s charger object, which the robot can observe and drive toward. |
|
An object defined by the SDK observed by the robot. |
|
An object archetype defined by the SDK. |
Defines all available custom object markers. |
|
Defines all available custom object types. |
|
|
Triggered whenever an object is first visually identified by a robot. |
|
Triggered whenever an object that was previously being observed is no longer visible. |
|
Triggered when an active object stops moving. |
|
Triggered whenever an object is visually identified by the robot. |
|
A fixed object defined by the SDK. |
|
Represents Vector’s Cube. |
|
Represents any object Vector can see in the world. |
-
anki_vector.objects.
LIGHT_CUBE_1_TYPE
= 2¶ LIGHT_CUBE_1_TYPE’s markers look like 2 concentric circles with lines and gaps.
-
anki_vector.objects.
OBJECT_VISIBILITY_TIMEOUT
= 0.8¶ Length of time in seconds to go without receiving an observed event before assuming that Vector can no longer see an object.
-
class
anki_vector.objects.
EvtObjectAppeared
(obj, image_rect, pose)¶ Triggered whenever an object is first visually identified by a robot.
This differs from EvtObjectObserved in that it’s only triggered when an object initially becomes visible. If it disappears for more than OBJECT_VISIBILITY_TIMEOUT seconds and then is seen again, a EvtObjectDisappeared will be dispatched, followed by another EvtObjectAppeared event.
For continuous tracking information about a visible object, see EvtObjectObserved.
import time import anki_vector from anki_vector.events import Events from anki_vector.util import degrees def handle_object_appeared(robot, event_type, event): # This will be called whenever an EvtObjectAppeared is dispatched - # whenever an Object comes into view. print(f"--------- Vector started seeing an object --------- \n{event.obj}") with anki_vector.Robot(default_logging=False, show_viewer=True, show_3d_viewer=True, enable_nav_map_feed=True) as robot: # Place Vector's cube where he can see it robot.events.subscribe(handle_object_appeared, Events.object_appeared) # If necessary, move Vector's Head and Lift down robot.behavior.set_lift_height(0.0) robot.behavior.set_head_angle(degrees(0.0)) time.sleep(3.0)
- Parameters
obj – The object that is starting to be observed
image_rect (
ImageRect
) – Ananki_vector.util.ImageRect
: defining where the object is within Vector’s camera viewpose (
Pose
) – Theanki_vector.util.Pose
: defining the position and rotation of the object
-
class
anki_vector.objects.
EvtObjectDisappeared
(obj)¶ Triggered whenever an object that was previously being observed is no longer visible.
import time import anki_vector from anki_vector.events import Events from anki_vector.util import degrees def handle_object_disappeared(robot, event_type, event): # This will be called whenever an EvtObjectDisappeared is dispatched - # whenever an Object goes out of view. print(f"--------- Vector stopped seeing an object --------- \n{event.obj}") with anki_vector.Robot(default_logging=False, show_viewer=True, show_3d_viewer=True, enable_nav_map_feed=True) as robot: # Place Vector's cube where he can see it robot.events.subscribe(handle_object_disappeared, Events.object_disappeared) # If necessary, move Vector's Head and Lift down robot.behavior.set_lift_height(0.0) robot.behavior.set_head_angle(degrees(0.0)) time.sleep(3.0)
- Parameters
obj – The object that is no longer being observed
-
class
anki_vector.objects.
EvtObjectFinishedMove
(obj, move_duration)¶ Triggered when an active object stops moving.
- Parameters
obj – The object that moved
move_duration (
float
) – The duration of the move
-
class
anki_vector.objects.
EvtObjectObserved
(obj, image_rect, pose)¶ Triggered whenever an object is visually identified by the robot.
A stream of these events are produced while an object is visible to the robot. Each event has an updated image_box field.
See EvtObjectAppeared if you only want to know when an object first becomes visible.
import time import anki_vector from anki_vector.events import Events from anki_vector.util import degrees def handle_object_observed(robot, event_type, event): # This will be called whenever an EvtObjectObserved is dispatched - # whenever an Object comes into view. print(f"--------- Vector observed an object --------- \n{event.obj}") with anki_vector.Robot(default_logging=False, show_viewer=True, show_3d_viewer=True, enable_nav_map_feed=True) as robot: # Place Vector's cube where he can see it robot.events.subscribe(handle_object_observed, Events.object_observed) # If necessary, move Vector's Head and Lift down robot.behavior.set_lift_height(0.0) robot.behavior.set_head_angle(degrees(0.0)) time.sleep(3.0)
- Parameters
obj – The object that was observed
image_rect (
ImageRect
) – Ananki_vector.util.ImageRect
: defining where the object is within Vector’s camera viewpose (
Pose
) – Theanki_vector.util.Pose
: defining the position and rotation of the object
-
class
anki_vector.objects.
Charger
(robot, object_id, **kw)¶ Vector’s charger object, which the robot can observe and drive toward. We get an
anki_vector.objects.EvtObjectObserved
message when the robot sees the charger.See parent class
ObservableObject
for additional properties and methods.import anki_vector # Position Vector so he can see his charger with anki_vector.Robot() as robot: if robot.world.charger: print('Robot is aware of charger: {0}'.format(robot.world.charger))
-
property
descriptive_name
¶ A descriptive name for this ObservableObject instance.
Note: Sub-classes should override this to add any other relevant info for that object type.
import anki_vector with anki_vector.Robot() as robot: if robot.world.charger: print(f"{robot.world.charger.descriptive_name}")
- Return type
-
property
object_id
¶ The internal ID assigned to the object.
import anki_vector # Position Vector so he can see his charger with anki_vector.Robot() as robot: if robot.world.charger: charger_object_id = robot.world.charger.object_id print(f"charger_object_id: {charger_object_id}")
This value can only be assigned once as it is static on the robot.
- Return type
-
teardown
()¶ All objects will be torn down by the world when the world closes.
-
property
-
class
anki_vector.objects.
CustomObjectArchetype
(custom_type, x_size_mm, y_size_mm, z_size_mm, marker_width_mm, marker_height_mm, is_unique)¶ An object archetype defined by the SDK. It is bound to a specific objectType e.g
CustomType00
.This defined object is given a size in the x,y and z axis. The dimensions of the markers on the object are also defined.
See
CustomObjectMarkers
.When the robot observes custom objects, they will be linked to these archetypes. These can be created using the methods
define_custom_box()
,define_custom_cube()
, ordefine_custom_wall()
.-
property
custom_type
¶ id of this archetype on the robot.
See
CustomObjectMarkers
.import anki_vector with anki_vector.Robot(enable_custom_object_detection=True) as robot: for obj in robot.world.custom_object_archetypes: print('custom object archetype defined with type: {0}'.format(obj.custom_type))
- Return type
EnumTypeWrapper
-
property
is_unique
¶ True if there should only be one of this object type in the world.
See
CustomObjectMarkers
.- Return type
-
property
marker_height_mm
¶ Height in millimeters of the marker on this object.
See
CustomObjectMarkers
.import anki_vector with anki_vector.Robot(enable_custom_object_detection=True) as robot: for obj in robot.world.custom_object_archetypes: print('custom object archetype defined with marker size: {0}mm x {1}mm'.format(obj.marker_width_mm, obj.marker_height_mm))
- Return type
-
property
marker_width_mm
¶ Width in millimeters of the marker on this object.
See
CustomObjectMarkers
.import anki_vector with anki_vector.Robot(enable_custom_object_detection=True) as robot: for obj in robot.world.custom_object_archetypes: print('custom object archetype defined with marker size: {0}mm x {1}mm'.format(obj.marker_width_mm, obj.marker_height_mm))
- Return type
-
property
x_size_mm
¶ Size of this object in its X axis, in millimeters.
See
CustomObjectMarkers
.import anki_vector with anki_vector.Robot(enable_custom_object_detection=True) as robot: for obj in robot.world.custom_object_archetypes: print('custom object archetype defined with dimensions: {0}mm x {1}mm x {2}mm'.format(obj.x_size_mm, obj.y_size_mm, obj.z_size_mm))
- Return type
-
property
y_size_mm
¶ Size of this object in its Y axis, in millimeters.
See
CustomObjectMarkers
.import anki_vector with anki_vector.Robot(enable_custom_object_detection=True) as robot: for obj in robot.world.custom_object_archetypes: print('custom object archetype defined with dimensions: {0}mm x {1}mm x {2}mm'.format(obj.x_size_mm, obj.y_size_mm, obj.z_size_mm))
- Return type
-
property
z_size_mm
¶ Size of this object in its Z axis, in millimeters.
See
CustomObjectMarkers
.import anki_vector with anki_vector.Robot(enable_custom_object_detection=True) as robot: for obj in robot.world.custom_object_archetypes: print('custom object archetype defined with dimensions: {0}mm x {1}mm x {2}mm'.format(obj.x_size_mm, obj.y_size_mm, obj.z_size_mm))
- Return type
-
property
-
class
anki_vector.objects.
CustomObject
(robot, archetype, object_id, **kw)¶ An object defined by the SDK observed by the robot. The object will reference a
CustomObjectArchetype
, with additional instance data.These objects are created automatically by the engine when Vector observes an object with custom markers. For Vector to see one of these you must first define an archetype with custom markers, via one of the following methods:
define_custom_box()
.define_custom_cube()
, ordefine_custom_wall()
See
CustomObjectMarkers
.-
property
archetype
¶ Archetype defining this custom object’s properties.
See
CustomObjectMarkers
.import anki_vector from anki_vector.objects import CustomObjectMarkers, CustomObjectTypes with anki_vector.Robot(enable_custom_object_detection=True) as robot: robot.world.define_custom_cube(custom_object_type=CustomObjectTypes.CustomType00, marker=CustomObjectMarkers.Circles2, size_mm=20.0, marker_width_mm=50.0, marker_height_mm=50.0) # have the robot observe a custom object in the real world with the Circles2 marker for obj in robot.world.visible_custom_objects: print('custom object seen with archetype: {0}'.format(obj.archetype))
- Return type
-
property
descriptive_name
¶ A descriptive name for this CustomObject instance.
See
CustomObjectMarkers
.import anki_vector from anki_vector.objects import CustomObjectMarkers, CustomObjectTypes with anki_vector.Robot(enable_custom_object_detection=True) as robot: robot.world.define_custom_cube(custom_object_type=CustomObjectTypes.CustomType00, marker=CustomObjectMarkers.Circles2, size_mm=20.0, marker_width_mm=50.0, marker_height_mm=50.0) # have the robot observe a custom object in the real world with the Circles2 marker for obj in robot.world.visible_custom_objects: print('custom object seen with name: {0}'.format(obj.descriptive_name))
- Return type
-
property
object_id
¶ The internal ID assigned to the object.
This value can only be assigned once as it is static on the robot.
See
CustomObjectMarkers
.import anki_vector from anki_vector.objects import CustomObjectMarkers, CustomObjectTypes with anki_vector.Robot(enable_custom_object_detection=True) as robot: robot.world.define_custom_cube(custom_object_type=CustomObjectTypes.CustomType00, marker=CustomObjectMarkers.Circles2, size_mm=20.0, marker_width_mm=50.0, marker_height_mm=50.0) # have the robot observe a custom object in the real world with the Circles2 marker for obj in robot.world.visible_custom_objects: print('custom object seen with id: {0}'.format(obj.object_id))
- Return type
-
teardown
()¶ All objects will be torn down by the world when no longer needed.
See
CustomObjectMarkers
.
-
property
-
class
anki_vector.objects.
CustomObjectMarkers
¶ Defines all available custom object markers.
For use with world.define_custom methods such as
anki_vector.world.World.define_custom_box()
,anki_vector.world.World.define_custom_cube()
, andanki_vector.world.World.define_custom_wall()
See
CustomObject
.import anki_vector from anki_vector.objects import CustomObjectMarkers, CustomObjectTypes with anki_vector.Robot(enable_custom_object_detection=True) as robot: robot.world.define_custom_cube(custom_object_type=CustomObjectTypes.CustomType00, marker=CustomObjectMarkers.Circles2, size_mm=20.0, marker_width_mm=50.0, marker_height_mm=50.0)
-
Circles2
= _CustomObjectMarker(name='Circles2', id=1)¶
-
Circles3
= _CustomObjectMarker(name='Circles3', id=2)¶
-
Circles4
= _CustomObjectMarker(name='Circles4', id=3)¶
-
Circles5
= _CustomObjectMarker(name='Circles5', id=4)¶
-
Diamonds2
= _CustomObjectMarker(name='Diamonds2', id=5)¶
-
Diamonds3
= _CustomObjectMarker(name='Diamonds3', id=6)¶
-
Diamonds4
= _CustomObjectMarker(name='Diamonds4', id=7)¶
-
Diamonds5
= _CustomObjectMarker(name='Diamonds5', id=8)¶
-
Hexagons2
= _CustomObjectMarker(name='Hexagons2', id=9)¶
-
Hexagons3
= _CustomObjectMarker(name='Hexagons3', id=10)¶
-
Hexagons4
= _CustomObjectMarker(name='Hexagons4', id=11)¶
-
Hexagons5
= _CustomObjectMarker(name='Hexagons5', id=12)¶
-
Triangles2
= _CustomObjectMarker(name='Triangles2', id=13)¶
-
Triangles3
= _CustomObjectMarker(name='Triangles3', id=14)¶
-
Triangles4
= _CustomObjectMarker(name='Triangles4', id=15)¶
-
Triangles5
= _CustomObjectMarker(name='Triangles5', id=16)¶
-
-
class
anki_vector.objects.
CustomObjectTypes
¶ Defines all available custom object types.
For use with world.define_custom methods such as
anki_vector.world.World.define_custom_box()
,anki_vector.world.World.define_custom_cube()
, andanki_vector.world.World.define_custom_wall()
See
CustomObjectMarkers
.import anki_vector from anki_vector.objects import CustomObjectMarkers, CustomObjectTypes with anki_vector.Robot(enable_custom_object_detection=True) as robot: robot.world.define_custom_cube(custom_object_type=CustomObjectTypes.CustomType00, marker=CustomObjectMarkers.Circles2, size_mm=20.0, marker_width_mm=50.0, marker_height_mm=50.0)
-
CustomType00
= _CustomObjectType(name='CustomType00', id=1)¶ CustomType00 - the first custom object type
-
CustomType01
= _CustomObjectType(name='CustomType01', id=2)¶
-
CustomType02
= _CustomObjectType(name='CustomType02', id=3)¶
-
CustomType03
= _CustomObjectType(name='CustomType03', id=4)¶
-
CustomType04
= _CustomObjectType(name='CustomType04', id=5)¶
-
CustomType05
= _CustomObjectType(name='CustomType05', id=6)¶
-
CustomType06
= _CustomObjectType(name='CustomType06', id=7)¶
-
CustomType07
= _CustomObjectType(name='CustomType07', id=8)¶
-
CustomType08
= _CustomObjectType(name='CustomType08', id=9)¶
-
CustomType09
= _CustomObjectType(name='CustomType09', id=10)¶
-
CustomType10
= _CustomObjectType(name='CustomType10', id=11)¶
-
CustomType11
= _CustomObjectType(name='CustomType11', id=12)¶
-
CustomType12
= _CustomObjectType(name='CustomType12', id=13)¶
-
CustomType13
= _CustomObjectType(name='CustomType13', id=14)¶
-
CustomType14
= _CustomObjectType(name='CustomType14', id=15)¶
-
CustomType15
= _CustomObjectType(name='CustomType15', id=16)¶
-
CustomType16
= _CustomObjectType(name='CustomType16', id=17)¶
-
CustomType17
= _CustomObjectType(name='CustomType17', id=18)¶
-
CustomType18
= _CustomObjectType(name='CustomType18', id=19)¶
-
CustomType19
= _CustomObjectType(name='CustomType19', id=20)¶ CustomType19 - the last custom object type
-
-
class
anki_vector.objects.
FixedCustomObject
(robot, pose, x_size_mm, y_size_mm, z_size_mm, object_id, **kw)¶ A fixed object defined by the SDK. It is given a pose and x,y,z sizes.
This object cannot be observed by the robot so its pose never changes. The position is static in Vector’s world view; once instantiated, these objects never move. This could be used to make Vector aware of objects and know to plot a path around them even when they don’t have any markers.
To create these use
create_custom_fixed_object()
import anki_vector from anki_vector.util import degrees, Pose import time with anki_vector.Robot(enable_custom_object_detection=True) as robot: robot.world.create_custom_fixed_object(Pose(100, 0, 0, angle_z=degrees(0)), 10, 100, 100, relative_to_robot=True)
-
property
object_id
¶ The internal ID assigned to the object.
This value can only be assigned once as it is static in the engine.
import anki_vector from anki_vector.util import degrees, Pose import time with anki_vector.Robot(enable_custom_object_detection=True) as robot: obj = robot.world.create_custom_fixed_object(Pose(100, 0, 0, angle_z=degrees(0)), 10, 100, 100, relative_to_robot=True) print('fixed custom object id: {0}'.format(obj.object_id))
- Return type
-
property
pose
¶ The pose of the object in the world.
import anki_vector from anki_vector.util import degrees, Pose import time with anki_vector.Robot(enable_custom_object_detection=True) as robot: obj = robot.world.create_custom_fixed_object(Pose(100, 0, 0, angle_z=degrees(0)), 10, 100, 100, relative_to_robot=True) print('fixed custom object id: {0}'.format(obj.pose))
- Return type
-
property
x_size_mm
¶ The length of the object in its X axis, in millimeters.
import anki_vector from anki_vector.util import degrees, Pose import time with anki_vector.Robot(enable_custom_object_detection=True) as robot: obj = robot.world.create_custom_fixed_object(Pose(100, 0, 0, angle_z=degrees(0)), 10, 100, 100, relative_to_robot=True) print('fixed custom object size: {0}mm x {1}mm x {2}mm'.format(obj.x_size_mm, obj.y_size_mm, obj.z_size_mm))
- Return type
-
property
y_size_mm
¶ The length of the object in its Y axis, in millimeters.
import anki_vector from anki_vector.util import degrees, Pose import time with anki_vector.Robot(enable_custom_object_detection=True) as robot: obj = robot.world.create_custom_fixed_object(Pose(100, 0, 0, angle_z=degrees(0)), 10, 100, 100, relative_to_robot=True) print('fixed custom object size: {0}mm x {1}mm x {2}mm'.format(obj.x_size_mm, obj.y_size_mm, obj.z_size_mm))
- Return type
-
property
z_size_mm
¶ The length of the object in its Z axis, in millimeters.
import anki_vector from anki_vector.util import degrees, Pose import time with anki_vector.Robot(enable_custom_object_detection=True) as robot: obj = robot.world.create_custom_fixed_object(Pose(100, 0, 0, angle_z=degrees(0)), 10, 100, 100, relative_to_robot=True) print('fixed custom object size: {0}mm x {1}mm x {2}mm'.format(obj.x_size_mm, obj.y_size_mm, obj.z_size_mm))
- Return type
-
property
-
class
anki_vector.objects.
LightCube
(robot, **kw)¶ Represents Vector’s Cube.
The LightCube object has four LEDs that Vector can actively manipulate and communicate with.
As Vector drives around, he uses the position of objects that he recognizes, including his cube, to localize himself, taking note of the
anki_vector.util.Pose
of the objects.You can subscribe to cube events including
anki_vector.events.Events.object_tapped
,anki_vector.events.Events.object_appeared
, andanki_vector.events.Events.object_disappeared
.Vector supports 1 LightCube.
See parent class
ObservableObject
for additional properties and methods.-
property
descriptive_name
¶ A descriptive name for this ObservableObject instance.
Note: Sub-classes should override this to add any other relevant info for that object type.
import anki_vector with anki_vector.Robot() as robot: robot.world.connect_cube() if robot.world.connected_light_cube: cube = robot.world.connected_light_cube print(f"{cube.descriptive_name}")
- Return type
-
property
factory_id
¶ The unique hardware id of the physical cube.
import anki_vector with anki_vector.Robot() as robot: robot.world.connect_cube() if robot.world.connected_light_cube: cube = robot.world.connected_light_cube print(f"{cube.factory_id}")
- Return type
-
property
is_connected
¶ True if the cube is currently connected to the robot.
import anki_vector with anki_vector.Robot() as robot: robot.world.connect_cube() if robot.world.connected_light_cube: cube = robot.world.connected_light_cube print(f"{cube.is_connected}")
- Return type
-
property
is_moving
¶ True if the cube’s accelerometer indicates that the cube is moving.
import time import anki_vector with anki_vector.Robot() as robot: print("disconnecting from any connected cube...") robot.world.disconnect_cube() time.sleep(2) print("connect to a cube...") connectionResult = robot.world.connect_cube() print("For the next 8 seconds, please tap and move the cube. Cube properties will be logged to console.") for _ in range(16): connected_cube = robot.world.connected_light_cube if connected_cube: print(f'is_moving: {connected_cube.is_moving}') time.sleep(0.5)
- Return type
-
property
last_moved_robot_timestamp
¶ The time the object was last moved in robot time.
import time import anki_vector with anki_vector.Robot() as robot: print("disconnecting from any connected cube...") robot.world.disconnect_cube() time.sleep(2) print("connect to a cube...") connectionResult = robot.world.connect_cube() print("For the next 8 seconds, please tap and move the cube. Cube properties will be logged to console.") for _ in range(16): connected_cube = robot.world.connected_light_cube if connected_cube: print(f'last_moved_robot_timestamp: {connected_cube.last_moved_robot_timestamp}') time.sleep(0.5)
- Return type
-
property
last_moved_start_robot_timestamp
¶ The time the object more recently started moving in robot time.
import time import anki_vector with anki_vector.Robot() as robot: print("disconnecting from any connected cube...") robot.world.disconnect_cube() time.sleep(2) print("connect to a cube...") connectionResult = robot.world.connect_cube() print("For the next 8 seconds, please tap and move the cube. Cube properties will be logged to console.") for _ in range(16): connected_cube = robot.world.connected_light_cube if connected_cube: print(f'last_moved_start_robot_timestamp: {connected_cube.last_moved_start_robot_timestamp}') time.sleep(0.5)
- Return type
-
property
last_moved_start_time
¶ The time the object most recently started moving in SDK time.
import time import anki_vector with anki_vector.Robot() as robot: print("disconnecting from any connected cube...") robot.world.disconnect_cube() time.sleep(2) print("connect to a cube...") connectionResult = robot.world.connect_cube() print("For the next 8 seconds, please tap and move the cube. Cube properties will be logged to console.") for _ in range(16): connected_cube = robot.world.connected_light_cube if connected_cube: print(f'last_moved_start_time: {connected_cube.last_moved_start_time}') time.sleep(0.5)
- Return type
-
property
last_moved_time
¶ The time the object was last moved in SDK time.
import time import anki_vector with anki_vector.Robot() as robot: print("disconnecting from any connected cube...") robot.world.disconnect_cube() time.sleep(2) print("connect to a cube...") connectionResult = robot.world.connect_cube() print("For the next 8 seconds, please tap and move the cube. Cube properties will be logged to console.") for _ in range(16): connected_cube = robot.world.connected_light_cube if connected_cube: print(f'last_moved_time: {connected_cube.last_moved_time}') time.sleep(0.5)
- Return type
-
property
last_tapped_robot_timestamp
¶ The time the object was last tapped in robot time.
import time import anki_vector with anki_vector.Robot() as robot: print("disconnecting from any connected cube...") robot.world.disconnect_cube() time.sleep(2) print("connect to a cube...") connectionResult = robot.world.connect_cube() print("For the next 8 seconds, please tap and move the cube. Cube properties will be logged to console.") for _ in range(16): connected_cube = robot.world.connected_light_cube if connected_cube: print(f'last_tapped_robot_timestamp: {connected_cube.last_tapped_robot_timestamp}') time.sleep(0.5)
- Return type
-
property
last_tapped_time
¶ The time the object was last tapped in SDK time.
import time import anki_vector with anki_vector.Robot() as robot: print("disconnecting from any connected cube...") robot.world.disconnect_cube() time.sleep(2) print("connect to a cube...") connectionResult = robot.world.connect_cube() print("For the next 8 seconds, please tap and move the cube. Cube properties will be logged to console.") for _ in range(16): connected_cube = robot.world.connected_light_cube if connected_cube: print(f'last_tapped_time: {connected_cube.last_tapped_time}') time.sleep(0.5)
- Return type
-
property
last_up_axis_changed_robot_timestamp
¶ Time the object’s orientation last changed in robot time.
import time import anki_vector with anki_vector.Robot() as robot: print("disconnecting from any connected cube...") robot.world.disconnect_cube() time.sleep(2) print("connect to a cube...") connectionResult = robot.world.connect_cube() print("For the next 8 seconds, please tap and move the cube. Cube properties will be logged to console.") for _ in range(16): connected_cube = robot.world.connected_light_cube if connected_cube: print(f'last_up_axis_changed_robot_timestamp: {connected_cube.last_up_axis_changed_robot_timestamp}') time.sleep(0.5)
- Return type
-
property
last_up_axis_changed_time
¶ The time the object’s orientation last changed in SDK time.
import time import anki_vector with anki_vector.Robot() as robot: print("disconnecting from any connected cube...") robot.world.disconnect_cube() time.sleep(2) print("connect to a cube...") connectionResult = robot.world.connect_cube() print("For the next 8 seconds, please tap and move the cube. Cube properties will be logged to console.") for _ in range(16): connected_cube = robot.world.connected_light_cube if connected_cube: print(f'last_up_axis_changed_time: {connected_cube.last_up_axis_changed_time}') time.sleep(0.5)
- Return type
-
property
object_id
¶ The internal ID assigned to the object.
This value can only be assigned once as it is static on the robot.
import anki_vector with anki_vector.Robot() as robot: robot.world.connect_cube() if robot.world.connected_light_cube: cube = robot.world.connected_light_cube print(f"{cube.object_id}")
- Return type
-
set_light_corners
(light1, light2, light3, light4, color_profile=<anki_vector.lights.ColorProfile object>)¶ Set the light for each corner.
import anki_vector import time with anki_vector.Robot() as robot: robot.world.connect_cube() if robot.world.connected_light_cube: cube = robot.world.connected_light_cube cube.set_light_corners(anki_vector.lights.blue_light, anki_vector.lights.green_light, anki_vector.lights.red_light, anki_vector.lights.white_light) time.sleep(3) cube.set_lights_off()
- Parameters
light1 (
Light
) – The settings for the first light.light2 (
Light
) – The settings for the second light.light3 (
Light
) – The settings for the third light.light4 (
Light
) – The settings for the fourth light.color_profile (
ColorProfile
) – The profile to be used for the cube lights
-
set_lights
(light, color_profile=<anki_vector.lights.ColorProfile object>)¶ Set all lights on the cube
import anki_vector import time with anki_vector.Robot() as robot: robot.world.connect_cube() if robot.world.connected_light_cube: cube = robot.world.connected_light_cube # Set cube lights to yellow cube.set_lights(anki_vector.lights.yellow_light) time.sleep(3) cube.set_lights_off()
- Parameters
light (
Light
) – The settings for the lightscolor_profile (
ColorProfile
) – The profile to be used for the cube lights
-
set_lights_off
(color_profile=<anki_vector.lights.ColorProfile object>)¶ Set all lights off on the cube
import anki_vector import time with anki_vector.Robot() as robot: robot.world.connect_cube() if robot.world.connected_light_cube: cube = robot.world.connected_light_cube # Set cube lights to yellow cube.set_lights(anki_vector.lights.yellow_light) time.sleep(3) # Turn off cube lights cube.set_lights_off()
- Parameters
color_profile (
ColorProfile
) – The profile to be used for the cube lights
-
teardown
()¶ All faces will be torn down by the world when no longer needed.
-
property
top_face_orientation_rad
¶ Angular distance from the current reported up axis.
import time import anki_vector with anki_vector.Robot() as robot: print("disconnecting from any connected cube...") robot.world.disconnect_cube() time.sleep(2) print("connect to a cube...") connectionResult = robot.world.connect_cube() print("For the next 8 seconds, please tap and move the cube. Cube properties will be logged to console.") for _ in range(16): connected_cube = robot.world.connected_light_cube if connected_cube: print(f'top_face_orientation_rad: {connected_cube.top_face_orientation_rad}') time.sleep(0.5)
- Return type
-
property
up_axis
¶ The object’s up_axis value from the last time it changed.
import time import anki_vector with anki_vector.Robot() as robot: print("disconnecting from any connected cube...") robot.world.disconnect_cube() time.sleep(2) print("connect to a cube...") connectionResult = robot.world.connect_cube() print("For the next 8 seconds, please tap and move the cube. Cube properties will be logged to console.") for _ in range(16): connected_cube = robot.world.connected_light_cube if connected_cube: print(f'up_axis: {connected_cube.up_axis}') time.sleep(0.5)
- Return type
EnumTypeWrapper
-
visibility_timeout
= 0.8¶ Length of time in seconds to go without receiving an observed event before assuming that Vector can no longer see an object. Can be overridden in subclasses.
-
property
-
class
anki_vector.objects.
ObservableObject
(robot, **kw)¶ Represents any object Vector can see in the world.
-
property
is_visible
¶ True if the element has been observed recently, False otherwise.
“recently” is defined as
visibility_timeout
seconds.- Return type
-
property
last_observed_image_rect
¶ The location in 2d camera space where this object was last seen.
- Return type
-
property
last_observed_robot_timestamp
¶ Time this object was last seen according to Vector’s time.
- Return type
-
property
pose
¶ The pose of this object in the world.
Is
None
for elements that don’t have pose information.import anki_vector import time # First, place a cube directly in front of Vector so he can observe it. with anki_vector.Robot() as robot: connectionResult = robot.world.connect_cube() connected_cube = robot.world.connected_light_cube for _ in range(16): connected_cube = robot.world.connected_light_cube if connected_cube: print(connected_cube) print("last observed timestamp: " + str(connected_cube.last_observed_time) + ", robot timestamp: " + str(connected_cube.last_observed_robot_timestamp)) print(robot.world.connected_light_cube.pose) time.sleep(0.5)
- Return type
-
property