Aseba Adapters

Contents

Aseba Adapters#

class pyenki.adapters.Thymio2AsebaAdapter#

Exposes an interface that mimics the Aseba interface of the Thymio, where

  • Aseba variables x.y.z are exposed as Python properties x_y_z

  • Aseba functions x.y.z are exposed as Python methods call_x_y_z with the same number of integer arguments.

Note

This adapter does not implement Aseba events, which is the primary interface of Aseba controllers. Instead, it allows to write procedural controllers, which, although structurally different, can be functionally equivalent.

For example, we can mimic the following Aseba piece of code

call leds.top(32, 0, 0)
if prox.horizontal[2] > 2000 then
    motor.left.target = 123
else
    motor.left.target = 0
end

with

# Create a Thymio
thymio = pyenki.Thymio2()
# Wrap it in the Aseba-like interface
aseba = Thymio2AsebaAdapter(thymio)
# Use a similar API

aseba.call_leds_top(32, 0, 0)
if aseba.prox_horizontal[2] > 2000:
    aseba.motor_left_target = 123
else
    aseba.motor_left_target = 0
end

The exception are variables related to proximity communication. While aseba keeps only the most-recent received message in prox.comm.rx._payloads, prox.comm.rx._intensities and prox.comm.rx and generate an event each time a message is received, this adapter returns a list of messages received in the last update steps, in prox_comm_rx__payloads, prox_comm_rx__intensities, and prox_comm_rx.

__init__(thymio: Thymio2) None#
call_comm_enable(value: int) None#
call_led_sound(value: int) None#
call_led_temperature(*values: int) None#
call_leds_bottom_left(*values: int) None#
call_leds_bottom_right(*values: int) None#
call_leds_buttons(*values: int) None#
call_leds_circle(*values: int) None#
call_leds_prox_h(*values: int) None#
call_leds_prox_v(*values: int) None#
call_leds_rc(value: int) None#
call_leds_top(*values: int) None#
property acc: list[int]#
property acc__tap: int#
property button_backward: int#
property button_center: int#
property button_forward: int#
property button_left: int#
property button_right: int#
property leds_bottom_left: list[int]#
property leds_bottom_right: list[int]#
property leds_circle: list[int]#
property leds_top: list[int]#
property mic__mean: int#
property mic_intensity: int#
property motor_left_pwm: int#
property motor_left_speed: int#
property motor_left_target: int#
property motor_right_pwm: int#
property motor_right_speed: int#
property motor_right_target: int#
property prox_comm_rx: list[int]#
property prox_comm_rx__intensities: list[list[int]]#
property prox_comm_rx__payloads: list[list[int]]#
property prox_comm_tx: int#
property prox_ground_ambiant: list[int]#
property prox_ground_delta: list[int]#
property prox_ground_reflected: list[int]#
property prox_horizontal: list[int]#
property r5_address: int#
property r5_command: int#
property temperature: int#