Add serde

This commit is contained in:
Marko Durkovic
2021-05-02 14:46:31 +02:00
parent a7461c8ae7
commit abd0c1fa73
14 changed files with 1871 additions and 0 deletions
+1
View File
@@ -4,4 +4,5 @@ Rosbags namespace
.. toctree::
:maxdepth: 4
rosbags.serde
rosbags.typesys
+6
View File
@@ -0,0 +1,6 @@
rosbags.serde
=============
.. automodule:: rosbags.serde
:members:
:show-inheritance:
+1
View File
@@ -11,6 +11,7 @@
:hidden:
topics/typesys
topics/serde
.. toctree::
+31
View File
@@ -0,0 +1,31 @@
Serialization and deserialization
=================================
The serialization and deserialization system :py:mod:`rosbags.serde` supports multiple raw message formats. For each format it provides a pair of functions, one for serialization and one for deserialization. In addition to the data to process each function usually only requires the message type name.
Deserialization
---------------
Deserialize a CDR bytes object using :py:func:`deserialize_cdr() <rosbags.serde.deserialize_cdr>`:
.. code-block:: python
from rosbags.serde import deserialize_cdr
# rawdata is of type bytes and contains serialized message
msg = deserialize_cdr(rawdata, 'geometry_msgs/msg/Quaternion')
Serialization
---------------
Serialize a message with CDR using :py:func:`serialize_cdr() <rosbags.serde.serialize_cdr>`:
.. code-block:: python
from rosbags.serde import serialize_cdr
# serialize message with system endianess
serialized = serialize_cdr(msg, 'geometry_msgs/msg/Quaternion')
# serialize message with explicit endianess
serialized = serialize_cdr(msg, 'geometry_msgs/msg/Quaternion', little_endian=False)