Monty.Runtime.SensorModuleServer (ExTbpMonty.Core v0.1.0)

Copy Markdown View Source

One sensor module, one process.

The process holds the module's state and nothing else: every decision is a callback on the pure module (Monty.Frameworks.Models.AbstractMontyClasses.SensorModule). That split is what lets a sensor module be tested with a plain function call and still be supervised, restarted and inspected at runtime.

The client API below is the only way in. It is deliberately separate from the callbacks, so call sites read as SensorModuleServer.step(server, ...) rather than as raw GenServer messages, and every entry point carries a typespec. The server registers itself in Monty.Runtime.Registry under {:sensor_module, model_id, id}: after a restart the name points at the new process and no stored pid goes stale.

Summary

Functions

Returns a specification to start this module under a supervisor.

Drops the observations this sensor kept, keeping what it has learnt.

The module's own state, for tests and the run inspector.

Records the sensor's pose and turns one observation into a percept.

Types

id()

@type id() :: atom() | String.t()

server()

@type server() :: GenServer.server()

spec()

@type spec() :: %{id: id(), model_id: id(), module: module(), state: term()}

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

clear_buffers(server)

@spec clear_buffers(server()) :: :ok

Drops the observations this sensor kept, keeping what it has learnt.

What a run without episode boundaries asks when the object under the sensor changes: Monty's _reset_modules_buffers.

propose_goals(server)

@spec propose_goals(server()) :: [Monty.Cmp.Goal.t()]

propose_region(server)

@spec propose_region(server()) :: Monty.Cmp.AttentionRegion.t()

reset(server)

@spec reset(server()) :: :ok

start_link(spec)

@spec start_link(spec()) :: GenServer.on_start()

state(server)

@spec state(server()) :: term()

The module's own state, for tests and the run inspector.

step(server, observation, agent_state, ctx, motor_only? \\ false)

@spec step(server(), map(), map(), Monty.Context.t(), boolean()) ::
  Monty.Cmp.Message.t() | nil

Records the sensor's pose and turns one observation into a percept.

One round trip rather than two: update_state exists for the module's sake, not for the caller's.