anki_vector.proximity

Support for Vector’s distance sensor.

Vector’s time-of-flight distance sensor has a usable range of about 30 mm to 1200 mm (max useful range closer to 300mm for Vector) with a field of view of 25 degrees.

The distance sensor can be used to detect objects in front of the robot.

Classes

ProximityComponent(robot) Maintains the most recent proximity sensor data
ProximitySensorData(proto_data) A distance sample from the time-of-flight sensor with metadata describing reliability of the measurement
class anki_vector.proximity.ProximityComponent(robot)

Maintains the most recent proximity sensor data

This will be updated with every broadcast RobotState, and can be queried at any time. Two sensor readings are made available:
  • the most recent data from the robot
  • the most recent data which was considered valid by the engine for usage

An example of how to extract sensor data:

import anki_vector

with anki_vector.Robot() as robot:
    proximity_data = robot.proximity.last_sensor_reading
    if proximity_data is not None:
        print('Proximity distance: {0}, engine considers useful: {1}'.format(proximity_data.distance, proximity_data.is_valid))
close()

Closing the touch component will unsubscribe from robot state updates.

last_sensor_reading

anki_vector.proximity.ProximitySensorData – The last reported sensor data.

import anki_vector

with anki_vector.Robot() as robot:
    last_sensor_reading = robot.proximity.last_sensor_reading
Return type:ProximitySensorData
last_valid_sensor_reading

anki_vector.proximity.ProximitySensorData – The last reported sensor data which is considered useful for object detection.

..code-block

import anki_vector

with anki_vector.Robot() as robot:
    last_valid_sensor_reading = robot.proximity.last_valid_sensor_reading
Return type:ProximitySensorData
class anki_vector.proximity.ProximitySensorData(proto_data)

A distance sample from the time-of-flight sensor with metadata describing reliability of the measurement

The proximity sensor is located near the bottom of Vector between the two front wheels, facing forward. The reported distance describes how far in front of this sensor the robot feels an obstacle is. The sensor estimates based on time-of-flight information within a field of view which the engine resolves to a certain quality value.

Four additional flags are supplied by the engine to indicate whether this proximity data is considered valid for the robot’s internal pathfinding. Respecting these is optional, but will help python code respect the behavior of the robot’s innate object avoidance.

distance

The distance between the sensor and a detected object

import anki_vector

with anki_vector.Robot() as robot:
    distance = robot.proximity.last_sensor_reading.distance
Return type:float
is_in_valid_range

Whether or not the engine considers the detected signal is close enough to be considered useful. Past a certain threshold, distance readings become unreliable.

import anki_vector

with anki_vector.Robot() as robot:
    is_in_valid_range = robot.proximity.last_sensor_reading.is_in_valid_range
Return type:bool
is_lift_in_fov

Whether Vector’s lift is blocking the time-of-flight sensor. While the lift will send clear proximity signals, it’s not useful for object detection.

import anki_vector

with anki_vector.Robot() as robot:
    is_lift_in_fov = robot.proximity.last_sensor_reading.is_lift_in_fov
Return type:bool
is_too_pitched

Whether the engine considers the robot to be tilted too much up or down for the time-of-flight data to usefully describe obstacles in the driving plane.

import anki_vector

with anki_vector.Robot() as robot:
    is_too_pitched = robot.proximity.last_sensor_reading.is_too_pitched
Return type:bool
is_valid

Comprehensive judgment of whether the reported distance is useful for object proximity detection.

import anki_vector

with anki_vector.Robot() as robot:
    is_valid = robot.proximity.last_sensor_reading.is_valid
Return type:bool
is_valid_signal_quality

Whether the engine considers the detected signal to be reliable enough to be considered an object in proximity.

import anki_vector

with anki_vector.Robot() as robot:
    is_valid_signal_quality = robot.proximity.last_sensor_reading.is_valid_signal_quality
Return type:bool
signal_quality

The quality of the detected object.

The proximity sensor detects obstacles within a given field of view, this value represents the likelihood of the reported distance being a solid surface.

import anki_vector

with anki_vector.Robot() as robot:
    signal_quality = robot.proximity.last_sensor_reading.signal_quality
Return type:float