anki_vector.touch

Support for Vector’s touch sensor.

The robot will forward a raw sensor reading representing the capacitance detected on its back sensor. Accompanied with this value is a true/false flag that takes into account other aspects of the robot’s state to evaluate whether the robot thinks it is being touched or not. This flag is the same value used internally for petting detection.

Classes

TouchComponent(robot)

Maintains the most recent touch sensor data

TouchSensorData(proto_data)

A touch sample from the capacitive touch sensor, accompanied with the robot’s conclusion on whether this is considered a valid touch.

class anki_vector.touch.TouchComponent(robot)

Maintains the most recent touch sensor data

This will be updated with every broadcast RobotState, and can be queried at any time.

import anki_vector

with anki_vector.Robot() as robot:
    touch_data = robot.touch.last_sensor_reading
    if touch_data is not None:
        print('Touch sensor value: {0}, is being touched: {1}'.format(touch_data.raw_touch_value, touch_data.is_being_touched))
close()

Closing the touch component will unsubscribe from robot state updates.

last_sensor_reading

The last reported sensor data.

import anki_vector

with anki_vector.Robot() as robot:
    touch_data = robot.touch.last_sensor_reading
Return type

TouchSensorData

Type

anki_vector.touch.TouchSensorData

class anki_vector.touch.TouchSensorData(proto_data)

A touch sample from the capacitive touch sensor, accompanied with the robot’s conclusion on whether this is considered a valid touch.

is_being_touched

The robot’s conclusion on whether the current value is considered a valid touch.

import anki_vector

with anki_vector.Robot() as robot:
    touch_data = robot.touch.last_sensor_reading
    if touch_data is not None:
        is_being_touched = touch_data.is_being_touched
Return type

bool

raw_touch_value

The detected sensitivity from the touch sensor.

This will not map to a constant raw value, as it may be impacted by various environmental factors such as whether the robot is on its charger, being held, humidity, etc.

import anki_vector

with anki_vector.Robot() as robot:
    touch_data = robot.touch.last_sensor_reading
    if touch_data is not None:
        raw_touch_value = touch_data.raw_touch_value
Return type

int