Package roslib_electric :: Module msgs
[frames] | no frames]

Module msgs

source code

Classes
  MsgSpecException
  Constant
Container class for holding a Constant declaration
  Field
Container class for storing information about a single field in a MsgSpec
  MsgSpec
Container class for storing loaded msg description files.
Functions
 
is_verbose() source code
 
set_verbose(v) source code
str
base_msg_type(type_)
Compute the base data type, e.g.
source code
 
resolve_type(type_, package_context)
Resolve type name based on current package context.
source code
str, bool, int
parse_type(type_)
Parse ROS message field type
source code
bool
is_valid_msg_type(x)
Returns: True if the name is a syntatically legal message type name
source code
bool
is_valid_constant_type(x)
Returns: True if the name is a legal constant type.
source code
bool
is_valid_msg_field_name(x)
Returns: True if the name is a syntatically legal message field name
source code
 
reinit()
Reinitialize roslib_electric.msgs.
source code
 
list_msg_types(package, include_depends)
List all messages in the specified package
source code
str
msg_file(package, type_)
Determine the file system path for the specified .msg resource.
source code
[(str, MsgSpec), [str]]
get_pkg_msg_specs(package)
List all messages that a package contains.
source code
 
load_package_dependencies(package, load_recursive=False)
Register all messages that the specified package depends on.
source code
 
load_package(package)
Load package into the local registered namespace.
source code
(str, MsgSpec)
load_by_type(msgtype, package_context='')
Load message specification for specified type
source code
MsgSpec
load_from_string(text, package_context='', full_name='', short_name='')
Load message specification from a string.
source code
(str, MsgSpec)
load_from_file(file_path, package_context='')
Convert the .msg representation in the file to a MsgSpec instance.
source code
bool
is_header_type(type_)
Returns: True if  type_ refers to the ROS Header type
source code
bool
is_builtin(msg_type_name)
Returns: True if msg_type_name is a builtin/primitive type
source code
bool
is_registered(msg_type_name)
Returns: True if msg spec for specified msg type name is registered.
source code
MsgSpec
get_registered(msg_type_name, default_package=None)
Returns: msg spec for msg type name
source code
 
register(msg_type_name, msg_spec)
Load MsgSpec into the type dictionary
source code
Variables
  VERBOSE = False
  EXT = '.msg'
  SEP = '/'
  CONSTCHAR = '='
  COMMENTCHAR = '#'
  HEADER = 'Header'
  TIME = 'time'
  DURATION = 'duration'
  TIME_MSG = 'uint32 secs\nuint32 nsecs'
  DURATION_MSG = 'int32 secs\nint32 nsecs'
  PRIMITIVE_TYPES = ['int8', 'uint8', 'int16', 'uint16', 'int32'...
  BUILTIN_TYPES = ['int8', 'uint8', 'int16', 'uint16', 'int32', ...
  EXTENDED_BUILTINS = {'duration': MsgSpec[['int32', 'int32'], [...
  RESERVED_TYPES = ['int8', 'uint8', 'int16', 'uint16', 'int32',...
  REGISTERED_TYPES = {}
  __package__ = 'roslib_electric'
Function Details

base_msg_type(type_)

source code 

Compute the base data type, e.g. for arrays, get the underlying array item type

Parameters:
  • type_ (str) - ROS msg type (e.g. 'std_msgs/String')
Returns: str
base type

resolve_type(type_, package_context)

source code 

Resolve type name based on current package context.

NOTE: in ROS Diamondback, 'Header' resolves to 'std_msgs/Header'. In previous releases, it resolves to 'roslib/Header' (REP 100).

e.g.:

 resolve_type('String', 'std_msgs') -> 'std_msgs/String'
 resolve_type('String[]', 'std_msgs') -> 'std_msgs/String[]'
 resolve_type('std_msgs/String', 'foo') -> 'std_msgs/String'    
 resolve_type('uint16', 'std_msgs') -> 'uint16'
 resolve_type('uint16[]', 'std_msgs') -> 'uint16[]'

parse_type(type_)

source code 

Parse ROS message field type

Parameters:
  • type_ (str) - ROS field type
Returns: str, bool, int
base_type, is_array, array_length
Raises:

is_valid_msg_type(x)

source code 
Returns: bool
True if the name is a syntatically legal message type name

is_valid_constant_type(x)

source code 
Returns: bool
True if the name is a legal constant type. Only simple types are allowed.

is_valid_msg_field_name(x)

source code 
Returns: bool
True if the name is a syntatically legal message field name

reinit()

source code 

Reinitialize roslib_electric.msgs. This API is for message generators (e.g. genpy) that need to re-initialize the registration table.

list_msg_types(package, include_depends)

source code 

List all messages in the specified package

Parameters:
  • package, str - name of package to search
  • include_depends, bool - if True, will also list messages in package dependencies

msg_file(package, type_)

source code 

Determine the file system path for the specified .msg resource. .msg resource does not have to exist.

Parameters:
  • package (str) - name of package .msg file is in
  • type_ (str) - type name of message, e.g. 'Point2DFloat32'
Returns: str
file path of .msg file in specified package

get_pkg_msg_specs(package)

source code 

List all messages that a package contains.

Parameters:
  • package (str) - package to load messages from
Returns: [(str, MsgSpec), [str]]
list of message type names and specs for package, as well as a list of message names that could not be processed.

load_package_dependencies(package, load_recursive=False)

source code 

Register all messages that the specified package depends on.

Parameters:
  • load_recursive (bool) - (optional) if True, load all dependencies, not just direct dependencies. By default, this is false to prevent packages from incorrectly inheriting dependencies.

load_package(package)

source code 

Load package into the local registered namespace. All messages found in the package will be registered if they are successfully loaded. This should only be done with one package (i.e. the 'main' package) per Python instance.

Parameters:
  • package (str) - package name

load_by_type(msgtype, package_context='')

source code 

Load message specification for specified type

Parameters:
  • package_context (str) - package name to use for the type name or '' to use the local (relative) naming convention.
Returns: (str, MsgSpec)
Message type name and message specification

load_from_string(text, package_context='', full_name='', short_name='')

source code 

Load message specification from a string.

Parameters:
  • text (str) - .msg text
  • package_context (str) - package name to use for the type name or '' to use the local (relative) naming convention.
Returns: MsgSpec
Message specification
Raises:

load_from_file(file_path, package_context='')

source code 

Convert the .msg representation in the file to a MsgSpec instance. This does *not* register the object.

Parameters:
  • file_path (str:) - path of file to load from
  • package_context (str) - package name to prepend to type name or '' to use local (relative) naming convention.
Returns: (str, MsgSpec)
Message type name and message specification
Raises:

is_header_type(type_)

source code 
Parameters:
  • type_ (str) - message type name
Returns: bool
True if  type_ refers to the ROS Header type

is_builtin(msg_type_name)

source code 
Parameters:
  • msg_type_name (str) - name of message type
Returns: bool
True if msg_type_name is a builtin/primitive type

is_registered(msg_type_name)

source code 
Parameters:
  • msg_type_name (str) - name of message type
Returns: bool
True if msg spec for specified msg type name is registered. NOTE: builtin types are not registered.

get_registered(msg_type_name, default_package=None)

source code 
Parameters:
  • msg_type_name (str) - name of message type
Returns: MsgSpec
msg spec for msg type name

register(msg_type_name, msg_spec)

source code 

Load MsgSpec into the type dictionary

Parameters:
  • msg_type_name (str) - name of message type
  • msg_spec (MsgSpec) - spec to load

Variables Details

PRIMITIVE_TYPES

Value:
['int8',
 'uint8',
 'int16',
 'uint16',
 'int32',
 'uint32',
 'int64',
 'uint64',
...

BUILTIN_TYPES

Value:
['int8',
 'uint8',
 'int16',
 'uint16',
 'int32',
 'uint32',
 'int64',
 'uint64',
...

EXTENDED_BUILTINS

Value:
{'duration': MsgSpec[['int32', 'int32'], ['secs', 'nsecs']],
 'time': MsgSpec[['uint32', 'uint32'], ['secs', 'nsecs']]}

RESERVED_TYPES

Value:
['int8',
 'uint8',
 'int16',
 'uint16',
 'int32',
 'uint32',
 'int64',
 'uint64',
...