dotbot.dotbot_simulator module#

Dotbot simulator for the DotBot project.

class dotbot.dotbot_simulator.ControlLoopWaypoint[source]#

Bases: Structure

Mirrors coordinate_t from control_loop.h — used when calling control_loop_set_waypoints.

x#

Structure/Union member

y#

Structure/Union member

class dotbot.dotbot_simulator.DotBotSimulator(settings, tx_queue)[source]#

Bases: object

Simulator class for the dotbot.

Parameters:
advertise()[source]#

Send an advertisement message to the gateway.

control_thread()[source]#

Control thread to update the state of the dotbot simulator.

diff_drive_model_update(dt=0.01)[source]#

State space model update.

rx_frame()[source]#

Decode the serial input received from the gateway.

start()[source]#
stop()[source]#
update_state()[source]#

Update the state of the dotbot simulator.

property header#
class dotbot.dotbot_simulator.DotBotSimulatorCommunicationInterface(on_frame_received, simulator_init_state)[source]#

Bases: object

Bidirectional serial interface to control simulated robots

Parameters:
  • on_frame_received (Callable)

  • simulator_init_state (str)

flush()[source]#

Flush fake serial output.

handle_dotbot_frame(frame)[source]#

Send bytes to the fake serial, similar to the real gateway.

run()[source]#

Listen continuously at each byte received on the fake serial interface.

start()[source]#
stop()[source]#
write(bytes_)[source]#

Write bytes on the fake serial.

class dotbot.dotbot_simulator.InitStateToml(*, dotbots, network=SimulatedNetworkSettings(pdr=100, uplink_pdr=100, downlink_pdr=100, slot_duration_ms=1.236, mqtt_latency_ms=0.0))[source]#

Bases: BaseModel

Parameters:
dotbots: List[SimulatedDotBotSettings]#
model_config: ClassVar[ConfigDict] = {}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

network: SimulatedNetworkSettings#
class dotbot.dotbot_simulator.MariNetworkSimulator(settings, on_frame_received)[source]#

Bases: object

TSCH slot-based network simulator modelling the Mari link layer.

Parameters:
Parameters:
Parameters:

dotbot_index (int)

start()[source]#
stop()[source]#
class dotbot.dotbot_simulator.RobotControl[source]#

Bases: Structure

Mirrors robot_control_t from control_loop.h.

Only the stable external I/O boundary is represented here. All internal algorithm state lives in the opaque context managed by the C library. Layout must stay in sync with the C struct (no internal padding gaps).

all_done#

Structure/Union member

direction#

Structure/Union member

encoder_left#

Structure/Union member

encoder_right#

Structure/Union member

pos_x#

Structure/Union member

pos_y#

Structure/Union member

pwm_left#

Structure/Union member

pwm_right#

Structure/Union member

waypoint_idx#

Structure/Union member

waypoint_reached#

Structure/Union member

waypoint_x#

Structure/Union member

waypoint_y#

Structure/Union member

class dotbot.dotbot_simulator.SimulatedDotBotSettings(*, address=<factory>, pos_x, pos_y, direction=-1000, calibrated=255, motor_left_error=0, motor_right_error=0, custom_control_loop_library=None, gru_model_path=None, battery_model_path=None, network_mode=SimulatedNetworkMode.DEFAULT)[source]#

Bases: BaseModel

Parameters:
  • address (str)

  • pos_x (int)

  • pos_y (int)

  • direction (int)

  • calibrated (int)

  • motor_left_error (float)

  • motor_right_error (float)

  • custom_control_loop_library (Path)

  • gru_model_path (Path)

  • battery_model_path (Path)

  • network_mode (SimulatedNetworkMode)

address: str#
battery_model_path: Path#
calibrated: int#
custom_control_loop_library: Path#
direction: int#
gru_model_path: Path#
model_config: ClassVar[ConfigDict] = {}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

motor_left_error: float#
motor_right_error: float#
network_mode: SimulatedNetworkMode#
pos_x: int#
pos_y: int#
class dotbot.dotbot_simulator.SimulatedNetworkMode(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]#

Bases: str, Enum

DEFAULT = 'default'#
MARI = 'mari'#
class dotbot.dotbot_simulator.SimulatedNetworkSettings(*, pdr=100, uplink_pdr=None, downlink_pdr=None, slot_duration_ms=1.236, mqtt_latency_ms=0.0)[source]#

Bases: BaseModel

Parameters:
  • pdr (int)

  • uplink_pdr (int | None)

  • downlink_pdr (int | None)

  • slot_duration_ms (float)

  • mqtt_latency_ms (float)

model_config: ClassVar[ConfigDict] = {}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

mqtt_latency_ms: float#
pdr: int#
slot_duration_ms: float#
class dotbot.dotbot_simulator.Waypoint(x, y)[source]#

Bases: object

Waypoint class for the dotbot simulator.

Parameters:
  • x (int)

  • y (int)

x: int#
y: int#
dotbot.dotbot_simulator.battery_discharge_model(time_elapsed_s)[source]#

Linear discharge over MAX_BATTERY_DURATION (supercapacitor idle model).

Parameters:

time_elapsed_s (float)

Return type:

int

dotbot.dotbot_simulator.packaged_init_state_path()[source]#

Absolute path to the default simulator world shipped in the package.

Return type:

Path

dotbot.dotbot_simulator.resolve_init_state_path(path)[source]#

Resolve the simulator init-state .toml to load.

An existing file — an explicit --simulator-init-state path, or a simulator_init_state.toml in the working directory — is used as given. When the default is requested and no such file is present, fall back to the world shipped inside the package, so the no-hardware path (dotbot run simulator / --conn simulator) works from any directory and from a pip-installed wheel. An explicit path that does not exist is returned unchanged so the caller gets a clear FileNotFoundError.

Parameters:

path (str)

Return type:

str

dotbot.dotbot_simulator.wheel_speed_from_pwm(pwm)[source]#

Convert a PWM value to a wheel speed in mm/s.

Parameters:

pwm (float)

Return type:

float