Skip to content

Simulator Reference

kevinbotlib.simulator

kevinbotlib.simulator.SimulationFramework

Robot Simulation Framework

robot = robot instance-attribute

sim_process = None instance-attribute

event_watcher = None instance-attribute

sim_in_queue = multiprocessing.Queue() instance-attribute

sim_out_queue = multiprocessing.Queue() instance-attribute

windows property

Get the currently activated WindowView IDs.

Returns:

Type Description
list[str]

WindowView IDs.

__init__(robot)

Initialize the simulation framework.

Parameters:

Name Type Description Default
robot BaseRobot

Robot to simulate

required

launch_simulator(comm_client, ready_callback=None)

Start the simulator.

Parameters:

Name Type Description Default
comm_client SetGetClientWithPubSub | None

Communication client used in simulations.

required
ready_callback Callable[[], None] | None

Callback for when the simulator window is ready.

None

exit_simulator()

Gracefully exit the simulator.

send_to_window(winid, payload)

Send a payload to a WindowView

Parameters:

Name Type Description Default
winid str

WindowView ID

required
payload Any

Payload to send.

required

add_window(winid, window)

Add a new pre-registered WindowView to the simulator.

Parameters:

Name Type Description Default
winid str

WindowView ID. ID must be registered by the @register_window_view decorator.

required
window type[WindowView]

WindowView to add.

required

add_payload_callback(payload_type, callback)

Add a new callback for a payload exiting a WindowView.

Parameters:

Name Type Description Default
payload_type type[T]

Customized subclass type of WindowViewOutputPayload.

required
callback Callable[[T], None]

Callback function.

required

kevinbotlib.simulator.freeze_support()

kevinbotlib.simulator.windowview

kevinbotlib.simulator.windowview.WINDOW_VIEW_REGISTRY = {} module-attribute

kevinbotlib.simulator.windowview.WindowView

Bases: QObject

Simulator Subwindow using PySide6 widgets.

title property

Title for the WindowView.

Returns:

Type Description
str

Title.

generate()

Widget to display in the WindowView.

Returns:

Type Description
QWidget

PySide6 QWidget.

update(payload)

Update the widget with the given payload. To be manually implemented by the subclass.

Parameters:

Name Type Description Default
payload Any

Payload from the main process.

required

send_payload(payload)

Function to send a custom payload into the main process.

Implemented at runtime. Do not override.

Parameters:

Name Type Description Default
payload WindowViewOutputPayload

Customized subclass of WindowViewOutputPayload.

required

kevinbotlib.simulator.windowview.WindowViewOutputPayload

Bases: ABC

A payload from the WindowView to the main process.

payload() abstractmethod

Payload content.

Returns:

Type Description
Any

Payload.

kevinbotlib.simulator.windowview.register_window_view(winid)

Register a WindowView subclass into the Simulation Framework.

Parameters:

Name Type Description Default
winid str

WindowView ID.

required