pamoja.sim

Idiomatic simulated-device facade.

Drive a whole node with no hardware attached: a sensor that drifts, a replay of a real capture, an actuator that records what it was told, and a robot that moves only in arithmetic. A lossy link is Transport.degraded, since it wraps a transport rather than standing alone.

 1"""Idiomatic simulated-device facade.
 2
 3Drive a whole node with no hardware attached: a sensor that drifts, a replay of a
 4real capture, an actuator that records what it was told, and a robot that moves
 5only in arithmetic. A lossy link is `Transport.degraded`, since it wraps a
 6transport rather than standing alone.
 7"""
 8
 9from __future__ import annotations
10
11from pamoja._native import Pose, RecordingActuatorHandle, Replay, SimulatedRobot, SimulatedSensor
12
13__all__ = [
14    "Pose",
15    "RecordingActuator",
16    "Replay",
17    "SimulatedRobot",
18    "SimulatedSensor",
19]
20
21#: An actuator that records every command instead of acting on one.
22RecordingActuator = RecordingActuatorHandle
class Pose:

Where a robot is and which way it faces.

theta

Heading from the world x axis, in radians, positive counter-clockwise.

x

Position along the world x axis, in metres.

y

Position along the world y axis, in metres.

RecordingActuator = <class 'builtins.RecordingActuatorHandle'>
class Replay:

A sensor that reads back a recorded series.

This is how a caller replays a real capture, so a test asks what the code does with readings that actually happened rather than ones it invented.

def read(self, /):

Takes the next reading.

class SimulatedRobot:

A robot that moves only in arithmetic.

def apply(self, /, *, vx=0.0, vy=0.0, omega=0.0):

Drives the robot for one time step.

def pose(self, /):

Where the robot has got to.

class SimulatedSensor:

A sensor that invents plausible readings.

def read(self, /):

Takes the next reading.