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) aseba.update() # 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 aseba.actuate()
Like Aseba, it keeps the most-recent received proximity communication message in
prox.comm.rx._payloads,prox.comm.rx._intensities, andprox.comm.rx. In addition, it records inprox_comm_bufferthe list of messages received in the last update step.- actuate() None#
Forwards the commands to the robots. Should be called after setting Aseba variables in a control step.
- apply(control: Callback[P], *args: P.args, **kwargs: P.kwargs) None#
Applies a control, preceding with
update()and postponing withactuate().- Parameters:
control – The control
args – The control arguments
kwargs – The control keywords arguments
- make_controller(behavior: Behavior) Controller#
Creates a controller that applies a behavior using
apply().- Parameters:
behavior – The behavior
- Returns:
The controller
- set_behavior(behavior: Behavior) None#
Creates a controller with
make_controller()and sets the robot’spyenki.PhysicalObject.control_step_callbackto it.- Parameters:
behavior (Behavior) – The behavior