Module API

rocon_uri

This is the top-level namespace of the rocon_uri ROS package. It provides parsing and formatting rules for uri’s that describe rocon devices and robots as resources in the rocon framework.

rocon_uri.exceptions

This module defines exceptions raised by the rocon_uri package. These exception names are all included in the main rocon_uri namespace. To catch one, import it this way:

from rocon_uri import RoconURIValueError

exception rocon_uri.exceptions.RoconURIValueError[source]

Bases: exceptions.Exception

Raised when an error occurs in parsing or manipulating rocon uri strings

rocon_uri.rules

This module defines ebnf rules used in parsing rocon_uri strings. It should never be used directly, it is the engine for the core parsing and manipulation module.


rocon_uri.rules.load_ebnf_rules()[source]

Load our rules from yaml and construct an ebnf rules dictionary for parsing rocon uri strings.

Returns:python dictionary of rules loaded from yaml.
Return type:str
rocon_uri.rules.load_rules_into_dictionary()[source]

Load the rules in rocon_uri/src/rocon_uri/rules/rules.yaml into a python dictionary object.

Returns:python dictionary of rules loaded from yaml.
Return type:str
rocon_uri.rules.walk_yaml_rules(name, root=None)[source]

A generator which walks through the yaml list of rules. Works in almost exactly the same way as os.path.walk. If a root for a ebnf rules dictionary is not specified, it will load the default rules dictionary, see load_rules_into_dictionary().

Usage::

for name, group, elements in walk_yaml('hardware_platform', yaml_rules['hardware_platform']):
    print("Name: %s" % name)
    print("  Group: %s" % group)
    print("  Elements: %s" % elements)
Parameters:
  • name (str) – a name to attach to the current 3-tuple that gets yielded by the generator.
  • root (dict) – a python dictionary representing the root of an object loaded from a yaml rules file

rocon_uri.uri

This module contains the public api and classes used to parse and compare rocon uri strings.

class rocon_uri.uri.RoconURI(rocon_uri_string='rocon:/')[source]

Bases: object

Initialises from a rocon uri string parsing the relevant information into fields internally. This class uses python decorators to establish the parsed fields into the following variables:

  • hardware_platform
  • name
  • application_framework
  • operating_system

Since each field can contain one or more values, each of these variables can return either a string representation of the original field, or a list of the parsed field. e.g.

>>> rocon_uri_object = rocon_uri.parse('rocon:/turtlebot2|pr2/dude/hydro/precise#rocon_apps/chirp')
>>> print rocon_uri_object.hardware_platform.list
['turtlebot2', 'pr2']
>>> print rocon_uri_object.hardware_platform.string
turtlebot2|pr2
__init__(rocon_uri_string='rocon:/')[source]

Initialise the rocon uri object from a rocon uri string.

Parameters:rocon_uri_string (str) – a rocon uri in string format.
Raises:rocon_uri.exceptions.RoconURIValueError if either rocon_uri string is not valid
__weakref__

list of weak references to the object (if defined)

rocon_uri.uri.is_compatible(rocon_uri_a, rocon_uri_b)[source]

Checks if two rocon uri’s are compatible.

Parameters:
  • rocon_uri_a (str or RoconURI) – a rocon uri in either string or RoconURI object format.
  • rocon_uri_b (str or RoconURI) – a rocon uri in either string or RoconURI object format.
Returns:

true if compatible, i.e. wildcards or intersections of fields are nonempty

Return type:

bool

Raises:

rocon_uri.exceptions.RoconURIValueError if either rocon_uri string is not valid

Todo

tighten up the name pattern matching

rocon_uri.uri.parse(rocon_uri_string)[source]

Convenience method for creating RoconURI objects.

Parameters:rocon_uri_string (str) – a rocon uri in string format.
Returns:a validated rocon uri object
Return type:RoconURI.
Raises:rocon_uri.exceptions.RoconURIValueError