ROS v0.1.0 ROS.Message View Source

Functions for serializing and deserializing ROS Messages sent over the wire.

Link to this section Summary

Functions

Deserialize a binary message from a publisher into an Elixir struct

Serialize an Elixir struct to a binary transmittable over the wire

Link to this section Functions

Link to this function deserialize(binary, type_module) View Source
deserialize(binary(), module() | String.t()) :: struct()

Deserialize a binary message from a publisher into an Elixir struct.

Examples

iex> data = <<0, 0, 176, 65, 0, 0, 4, 66, 0, 0, 48, 66, 0, 0, 0, 0>>
iex> ROS.Message.deserialize(data, "std_msgs/ColorRGBA")
%StdMsgs.ColorRGBA{r: 22.0, g: 33.0, b: 44.0, a: 0.0}
iex> ROS.Message.deserialize(data, StdMsgs.ColorRGBA)
%StdMsgs.ColorRGBA{r: 22.0, g: 33.0, b: 44.0, a: 0.0}
Link to this function serialize(msg) View Source
serialize(struct()) :: binary()

Serialize an Elixir struct to a binary transmittable over the wire.

Examples

iex> data = %StdMsgs.ColorRGBA{r: 22.0, g: 33.0, b: 44.0, a: 0.0}
iex> ROS.Message.serialize(data)
<<16, 0, 0, 0, 0, 0, 176, 65, 0, 0, 4, 66, 0, 0, 48, 66, 0, 0, 0, 0>>