Translate parameter values across the MCP boundary.
Most parameter types are JSON scalars already, but a {:unit, _} parameter
holds a Localize.Unit struct, which JSON.encode!/1 cannot encode. Unit
values travel as a tagged object carrying the magnitude and the CLDR unit
name:
%{"value" => -12.5, "unit" => "degree"}The tag makes the value self-describing, so a client can write back exactly
what it read from list_parameters, get_parameter or the parameters
resource without having to interpret the declared type. Writes also accept a
bare number for a unit-typed parameter, which is given the unit declared in
the robot's parameter schema.
Summary
Functions
Describe one BB.Parameter.list/2 entry for the parameter tools and resource.
Rebuild a parameter value from the JSON a client sent, ready for
BB.Parameter.set/3.
Render a parameter value as a term JSON.encode!/1 can carry.
Functions
Describe one BB.Parameter.list/2 entry for the parameter tools and resource.
min and max come from the parameter's declared type, so an agent can see
the range a write has to fall inside before set_parameter rejects it. Keys
the robot didn't declare are left out rather than sent as null.
Rebuild a parameter value from the JSON a client sent, ready for
BB.Parameter.set/3.
Returns {:error, message} when a tagged object names a unit which cannot be
parsed.
Render a parameter value as a term JSON.encode!/1 can carry.