Thymio#
- class pyenki.Thymio2.IRCommEvent#
This event is created each time a message is received by at least one proximity sensor. The sensors that do not receive the message, have the corresponding payloads and intensities set to zero.
- payloads#
An array of 7 integer payloads, one for each sensors (readonly). The first 5 entries are from frontal sensors ordered from left to right. The last two entries are from rear sensors ordered from left to right.
- Type:
- intensities#
An array of 7 integer intensities, one for each sensors (readonly). The first 5 entries are from frontal sensors ordered from left to right. The last two entries are from rear sensors ordered from left to right.
- Type:
- enum pyenki.Thymio2.Button(value)#
Identify one of the five touch button of the Thymio2.
Valid values are as follows:
- CENTER = <Button.CENTER: 0>#
- FORWARD = <Button.FORWARD: 1>#
- BACKWARD = <Button.BACKWARD: 2>#
- LEFT = <Button.LEFT: 3>#
- RIGHT = <Button.RIGHT: 4>#
- class pyenki.Thymio2#
Bases:
DifferentialWheeled,PhysicalObjectA
DifferentialWheeledThymio2 robot.Example:
>>> import pyenki >>> thymio = pyenki.Thymio2() >>> thymio.position = (3.2, 5.6) >>> thymio.angle = 1.3 >>> # Spin the robot on itself >>> thymio.motor_left_target = 10.2 >>> thymio.motor_right_target = -10.2 >>> # Switch the top LED yellow >>> thymio.set_led_top(0.5, 0.5, 0.0) >>> thymio.prox_values array([ 0. , 0., ...
- prox_values#
An array of 7 proximity sensor readings, one for each sensors (readonly). The first 5 entries are from frontal sensors ordered from left to right. The last two entries are from rear sensors ordered from left to right.
- Type:
- prox_distances#
A list of 7 distances between proximity sensor and nearest obstancle, one for each sensors; please note that this value would not directly be accessible by a real robot (readonly). The first 5 entries are from frontal sensors ordered from left to right. The last two entries are from rear sensors ordered from left to right.
- Type:
- prox_comm_tx#
The integer payload to be sent. The real robot can only send 11 bits, therefore to be compliant we should limit the value between 0 and 2047.
- Type:
- prox_comm_events#
A list of events, one for every received message during the last control step (readonly).
- Type:
- button_touch_callback#
An optional function called when button touch events happen with the same arguments as
pyenki.Thymio2.on_button_touch().- Type:
Callable[[Thymio2, Thymio2.Button], None] | None
- leds_buttons#
list[float]: The intensities of the 4 buttons LEDs.
- leds_circle#
list[float]: The intensities of the 8 circle LEDs.
- leds_prox#
list[float]: The intensities of the 8 proximity LEDs.
- led_left_red#
float: The intensity of the left red LED.
- led_left_blue#
float: The intensity of the left blue LED.
- led_right_red#
float: The intensity of the right red LED.
- led_right_blue#
float: The intensity of the right blue LED.
- buttons#
list[bool]: Whether the buttons are being pressed.
- get_led_buttons(index: SupportsInt) float#
Reads one of four button LEDs
- get_led_circle(index: SupportsInt) float#
Reads one of 8 circle LEDs
- get_led_prox(index: SupportsInt) float#
Reads one of 8 proximity LEDs
- on_button_touch(index: pyenki.Thymio2.Button) None#
Called after a button is touched.
Can be overridden by sub-classes to react to button touch events. Alternatively, users can assign a callback as
button_touch_callback.- Parameters:
index (int) – The button being touched.
- set_led_bottom_left(red: SupportsFloat = 0, green: SupportsFloat = 0, blue: SupportsFloat = 0) None#
Control the bottom left RGB LED color
- set_led_bottom_right(red: SupportsFloat = 0, green: SupportsFloat = 0, blue: SupportsFloat = 0) None#
Control the bottom right RGB LED color
- set_led_buttons(index: SupportsInt, value: SupportsFloat) None#
Control the four button LEDs
- set_led_circle(index: SupportsInt, value: SupportsFloat) None#
Control the 8 circle LEDs
- set_led_prox(index: SupportsInt, value: SupportsFloat) None#
Control the 8 proximity LEDs
- set_led_top(red: SupportsFloat = 0, green: SupportsFloat = 0, blue: SupportsFloat = 0) None#
Control the top RGB LED color
- touch_button(button: pyenki.Thymio2.Button) None#
Touches one of the buttons on top of the robot.
- Parameters:
index (int) – the index of the button