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
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
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.