Behaviors#

class pyenki.behaviors.Chain#

A sequence of controllers.

For example,

>>> robot.control_step_callback = Chain(controller1, controller2, ...)

will call

controller1(robot, dt)
controller2(robot, dt)
...

at each control step.

__call__(obj: PhysicalObject, dt: SupportsFloat) None#

Calls the controllers in sequence

__init__(*controllers: Callable[[PhysicalObject, SupportsFloat], None]) None#
class pyenki.behaviors.ThymioLEDProxBehavior#

Thymio LED prox behavior ported from the firmware, see static void behavior_leds_prox(void).

The original behavior ticks at 50Hz. It should be assigned to a Thymio, like in

>>> thymio.control_step_callback = ThymioLEDProxBehavior()
__call__(thymio: PhysicalObject, dt: SupportsFloat) None#

Executes the behavior

__init__() None#
class pyenki.behaviors.ThymioLEDButtonsBehavior#

Thymio LED prox behavior ported from the firmware, see static void behavior_leds_buttons(void).

The original behavior ticks at 50Hz. It should be assigned to a Thymio, like in

>>> thymio.control_step_callback = ThymioLEDButtonsBehavior()
__call__(thymio: PhysicalObject, dt: SupportsFloat) None#

Executes the behavior

__init__() None#
class pyenki.behaviors.ThymioAccBehavior#

Thymio Acc behavior ported from the firmware, see static void tick_acc(void).

The original behavior ticks at 50Hz. It should be assigned to a Thymio, like in

>>> thymio.control_step_callback = ThymioAccBehavior()
__call__(thymio: PhysicalObject, dt: SupportsFloat) None#

Executes the behavior

__init__() None#
class pyenki.behaviors.ThymioExplorerBehavior#

Thymio Explorer behavior ported from the firmware, see static void tick_explorer(void).

It is also very similar to the aseba implementation.

The original behavior ticks at 50Hz. It should be assigned to a Thymio, like in

>>> thymio.control_step_callback = ThymioExplorerController()
__call__(thymio: PhysicalObject, dt: SupportsFloat) None#

Executes the behavior

__init__(prox_value: int = 1000)#

Constructs a new instance.

Parameters:

prox_value – the threshold to move back. The original implementation uses a (very low) 222, which is too reactive in simulation.

class pyenki.behaviors.ThymioFollowerBehavior#

Thymio Follower behavior ported from the firmware, see static void tick_follow(void).

The original behavior ticks at 50Hz. It assumes that other “friendly” robots have enabled proximity communication. It should be assigned to a Thymio, like in

>>> thymio.prox_comm_enabled = True
>>> thymio.control_step_callback = ThymioExplorerController()
__call__(thymio: PhysicalObject, dt: SupportsFloat) None#

Executes the behavior

__init__() None#
class pyenki.behaviors.ThymioLineFollowingBehavior#

Thymio line following behavior ported from the firmware, see static void tick_line(void).

The original behavior ticks at 50Hz. It should be assigned to a Thymio, like in

>>> thymio.control_step_callback = ThymioLineBehavior()
__call__(thymio: PhysicalObject, dt: SupportsFloat) None#

Executes the behavior

__init__(black: int = 300, white: int = 600) None#

Constructs a new instance.

Parameters:
  • black – The ground sensors black threshold

  • white – The ground sensors white threshold