Monty.Frameworks.Utils.CommunicationUtils (ExTbpMonty.Core v0.1.0)

Copy Markdown View Source

Reading what came in over one channel.

Mirrors tbp/monty/frameworks/utils/communication_utils.py. A module given a step's percepts gets them as a list, because a step can carry several — a motor-only step carries none, a step where two sensors saw the object carries two — and what a caller usually wants is the one from a particular channel.

Naming a channel that is not in the percepts is an error rather than a nil: a caller asking for a channel it expected and not finding it has a bug, and the error says which channel and what was there instead.

Summary

Functions

The percept from channel_name, or an error naming the channels that did arrive.

Functions

get_percept_from_channel(percepts, channel_name)

@spec get_percept_from_channel([Monty.Cmp.Message.t()], String.t()) ::
  {:ok, Monty.Cmp.Message.t()}
  | {:error, {:channel_not_found, String.t(), [String.t()]}}

The percept from channel_name, or an error naming the channels that did arrive.