roslua: ROS client library for Lua

Module roslua.msg_spec

Message specification. This module contains the MsgSpec class to read and represent ROS message specification (YAML files). Message specifications should be obtained by using the get_msgspec() function, which is aliased for convenience as roslua.get_msgspec().

The message files are read on the fly, no offline code generation is necessary. This avoids the need to write yet another code generator. After reading the table field fields contains key value pairs, where the keys are the names of the data fields and the value is the type of the data field.

Copyright© Tim Niemueller, Carnegie Mellon University, Intel Research Pittsburgh

Release: Released under BSD license

Functions

MsgSpec:instantiate (no_prefill) Instantiate this message.
MsgSpec:is_instance (message) Check if given message is an instance of this spec.
MsgSpec:load () Load message specification from file.
MsgSpec:load_from_string (s) Load specification from string.
MsgSpec:md5 () Get MD5 sum of type specification.
MsgSpec:new (o) Contstructor.
MsgSpec:print (indent) Print specification.
MsgSpec:resolve_type (type) Resolve a type relative to this message spec.
base_type (type) Get the base version of type, i.e.
get_msgspec (msg_type, specstr) Get message specification.
is_array_type (type) Check if type is an array type.
is_builtin_type (type) Check if given type is a built-in type.
is_msgspec (testobj) Check if the given object is a message spec.
resolve_type (type, package) Resolve the given type.


Functions

MsgSpec:instantiate (no_prefill)
Instantiate this message.

Parameters

  • no_prefill:

Return value:

a Message instance of the specified message type.

See also:

MsgSpec:is_instance (message)
Check if given message is an instance of this spec.

Parameters

  • message: message instance to check

Return value:

true if the message is an instantiation of this spec, false otherwise
MsgSpec:load ()
Load message specification from file. Will search for the appropriate message specification file (using rospack) and will then read and parse the file.
MsgSpec:load_from_string (s)
Load specification from string.

Parameters

  • s: string containing the message specification
MsgSpec:md5 ()
Get MD5 sum of type specification. This will create a text representation of the message specification and generate the MD5 sum for it. The value is cached so concurrent calls will cause the cached value to be returned

Return value:

MD5 sum of message specification
MsgSpec:new (o)
Contstructor.

Parameters

  • o: Object initializer, must contain a field type with the string representation of the type name. Optionally can contain a specstr field, in which case the string will be parsed as message specification and no attempt will be made to read the message specification file.
MsgSpec:print (indent)
Print specification.

Parameters

  • indent: string (normally spaces) to put before every line of output
MsgSpec:resolve_type (type)
Resolve a type relative to this message spec. This is similar to the global resolve_type function, but the package parameter can be omitted as it is taken from the message spec instance.

Parameters

  • type: type to resolve

Return value:

resolved type

See also:

base_type (type)
Get the base version of type, i.e. the non-array type.

Parameters

  • type: type to get base type for

Return value:

base type, for array types returns the non-array type, for non-array type returns the given value.
get_msgspec (msg_type, specstr)
Get message specification. It is recommended to use the aliased version roslua.get_msgspec().

Parameters

  • msg_type: message type (e.g. std_msgs/String). The name must include the package.
  • specstr:
is_array_type (type)
Check if type is an array type.

Parameters

  • type: type to check

Return value:

true if given type is an array type, false otherwise
is_builtin_type (type)
Check if given type is a built-in type.

Parameters

  • type: type to check

Return value:

true if type is a built-in type, false otherwise
is_msgspec (testobj)
Check if the given object is a message spec.

Parameters

  • testobj: object to test

Return value:

true if testobj is a message spec, false otherwise
resolve_type (type, package)
Resolve the given type.

Parameters

  • type: to resolve
  • package: to which the type should be resolve relatively

Return value:

the given value if it is either a base type or contains a slash, otherwise returns package/type.

Valid XHTML 1.0!