Aseba Adapters#
- class pyenki.adapters.Thymio2AsebaAdapter#
Exposes an interface that mimics the Aseba interface of the Thymio, where
Aseba variables
x.y.zare exposed as Python propertiesx_y_zAseba functions
x.y.zare exposed as Python methodscall_x_y_zwith 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._intensitiesandprox.comm.rxand generate an event each time a message is received, this adapter returns a list of messages received in the last update steps, inprox_comm_rx__payloads,prox_comm_rx__intensities, andprox_comm_rx.