Library for Python message generation.
- The structure of the serialization descends several levels of serializers:
- msg_generator: generator for an individual msg file
serialize_fn_generator: generator for msg.serialize() - serializer_generator
- field-type-specific serializers
- raise MsgGenerationException("unknown file extension: %s"%f)
deserialize_fn_generator: generator for msg.deserialize() - serializer_generator
- field-type-specific serializers
Class |
|
No class docstring; 0/4 instance variable, 1/3 method documented |
Class |
|
Generate Python message code for all messages in a package. |
Class |
|
No class docstring; 0/3 instance variable, 2/2 methods documented |
Class |
|
Undocumented |
Function | array |
Generator for array types. |
Function | complex |
Generator for serializing complex type. |
Function | compute |
Compute python constructor expression for specified message type implementation. |
Function | compute |
Escape the result of genmsg.compute_full_text. |
Function | compute |
Compute python import statement for specified message type implementation. |
Function | compute |
No summary |
Function | compute |
No summary |
Function | compute |
Compute post-deserialization code for type_, if necessary. |
Function | compute |
Convert resource filename to ROS resource name. |
Function | default |
Compute default value for field_type. |
Function | deserialize |
Generator for body of deserialize() function. |
Function | flatten |
Flatten the msg spec so that embedded message fields become direct references. |
Function | get |
Wrap unknown types with a MsgGenerationException. |
Function | get |
No summary |
Function | is |
No summary |
Function | len |
Generator for array-length serialization (32-bit, little-endian unsigned integer). |
Function | make |
Remap field/constant names in spec to avoid collision with Python reserved words. |
Function | msg |
Python code generator for .msg files. |
Function | next |
Undocumented |
Function | pop |
Pop variable context from context stack. |
Function | push |
Push new variable context onto context stack. |
Function | reset |
Undocumented |
Function | serialize |
Generator for body of serialize() function. |
Function | serializer |
Generator that yields un-indented python code for (de)serializing MsgSpec. |
Function | simple |
Generator (de)serialization code for multiple fields from spec. |
Function | srv |
Undocumented |
Function | string |
Generator for string types. |
Constant | INDENT |
Undocumented |
Function | _module |
No summary |
Function | _remap |
Map field_name to a python-safe representation, if necessary. |
Constant | _SPECIAL |
Undocumented |
Variable | _context |
Undocumented |
Variable | _counter |
Undocumented |
Variable | _serial |
Undocumented |
Generator for serializing complex type.
Parameters | |
msg | Undocumented |
package | Undocumented |
type_ | Undocumented |
name | Undocumented |
serialize | if True, generate serialization code. Otherwise, deserialization code. bool |
is | if True, generate serializer code for numpy datatypes instead of Python lists, bool |
Raises | |
Unknown exception | MsgGenerationException If type is not a valid |
Compute python constructor expression for specified message type implementation.
Parameters | |
msg | Undocumented |
package | Undocumented |
type_ | message type, str |
package str | package that type is being imported into. Used to resolve type_ if package is not specified. str |
Escape the result of genmsg.compute_full_text.
The resulting text is escaped to be safe for Python's triple-quote string quoting.
Parameters | |
msg | Undocumented |
spec | Undocumented |
get | dictionary returned by load_dependencies call, dict |
Returns | |
concatenated text for msg/srv file and embedded msg/srv types. Text will be escaped for triple-quote, str |
Compute python import statement for specified message type implementation.
Parameters | |
msg | Undocumented |
package | package that type is being imported into, str |
type_ | message type (package resource name), str |
Returns | |
list of import statements (no newline) required to use type_ from package, [str] |
Parameters | |
outdir | Undocumented |
infile | Undocumented |
ext | Undocumented |
outdir str | path to directory that files are generated to |
Returns | |
output file path based on input file name and output directory |
Parameters | |
package | package that type is being imported into, str |
type_ | Undocumented |
type | message type (package resource name), str |
Returns | |
python package and type name, (str, str) |
Compute post-deserialization code for type_, if necessary.
Returns | |
code to execute post-deserialization (unindented), or None if not necessary. str |
Convert resource filename to ROS resource name.
Parameters | |
filename | Undocumented |
ext | Undocumented |
filename str | path to .msg/.srv file |
Returns | |
name of ROS resource |
Compute default value for field_type.
Parameters | |
msg | Undocumented |
field | ROS .msg field type, str |
default | default package, str |
Returns | |
default value encoded in Python string representation, str |
Generator for body of deserialize() function.
Parameters | |
msg | Undocumented |
spec | Undocumented |
is | if True, generate serializer code for numpy datatypes instead of Python lists, bool |
Flatten the msg spec so that embedded message fields become direct references.
The resulting MsgSpec isn't a true/legal.
MsgSpec
and should only be used for serializer generation.
:param msg: MsgSpec to flatten
:returns: flattened MsgSpec message
Wrap unknown types with a MsgGenerationException.
Wrapper for get_registered.
Parameters | |
msg | Undocumented |
type_ | ROS message type, str |
Returns | |
True` if *type_* is a special type (i.e. builtin represented as a class instead of a primitive), ``bool |
Generator for array-length serialization (32-bit, little-endian unsigned integer).
Parameters | |
var | variable name, str |
is | if True, variable is a string type, bool |
serialize | Undocumented |
serialize bool | if True, generate code for serialization. Other, generate code for deserialization, bool |
Remap field/constant names in spec to avoid collision with Python reserved words.
Parameters | |
spec | msg spec to map to new, python-safe field names, MsgSpec |
Returns | |
python-safe message specification, MsgSpec |
Python code generator for .msg files.
Generates a Python from a genmsg.MsgSpec
.
Parameters | |
msg | Undocumented |
spec | parsed .msg genmsg.MsgSpec instance |
search | dictionary mapping message namespaces to a directory locations |
Pop variable context from context stack.
The context stack manages field-reference context for serialization, e.g. 'self.foo' vs. 'self.bar.foo' vs. 'var.foo'
Push new variable context onto context stack.
The context stack manages field-reference context for serialization, e.g. 'self.foo' vs. 'self.bar.foo' vs. 'var.foo'
Generator for body of serialize() function.
Parameters | |
msg | Undocumented |
spec | Undocumented |
is | if True, generate serializer code for numpy datatypes instead of Python lists, bool |
Generator that yields un-indented python code for (de)serializing MsgSpec.
The code this yields is meant to be included in a class method and cannot be used standalone. serialize_fn_generator and deserialize_fn_generator wrap method to provide appropriate class field initializations.
Parameters | |
msg | Undocumented |
spec | Undocumented |
serialize | if True, yield serialization code. Otherwise, yield deserialization code. bool |
is | if True, generate serializer code for numpy datatypes instead of Python lists. bool |
Generator (de)serialization code for multiple fields from spec.
Parameters | |
msg | Undocumented |
spec | genmsg.MsgSpec |
start | first field to serialize, int |
end | last field to serialize, int |
serialize | Undocumented |
Generator for string types.
Similar to arrays, but with more efficient call to struct.pack.
Parameters | |
package | Undocumented |
type_ | Undocumented |
name | spec field name, str |
serialize | if True, generate code for serialization. Other, generate code for deserialization, bool |
Parameters | |
type | Undocumented |
type | Name of message type sans package, e.g. 'String' |
Returns | |
name of python module for auto-generated code |
Map field_name to a python-safe representation, if necessary.
Parameters | |
field | msg field name, str |
Returns | |
remapped name, str |