Package rosgraph :: Module names
[frames] | no frames]

Module names

source code

Library for manipulating ROS Names. See http://ros.org/wiki/Names.

Functions
 
isstring(s)
Small helper version to check an object is a string in a way that works for both Python 2 and 3
source code
str
get_ros_namespace(env=None, argv=None)
Returns: ROS namespace of current program
source code
str
make_caller_id(name)
Resolve a local name to the caller ID based on ROS environment settings (i.e.
source code
str
make_global_ns(name)
Convert name to a global name with a trailing namespace separator.
source code
bool
is_global(name)
Test if name is a global graph resource name.
source code
 
is_private(name)
Test if name is a private graph resource name.
source code
str
namespace(name)
Get the namespace of name.
source code
str
ns_join(ns, name)
Join a namespace and name.
source code
dict {str: str}
load_mappings(argv)
Load name mappings encoded in command-line arguments.
source code
 
is_legal_name(name)
Check if name is a legal ROS name for graph resources (alphabetical character followed by alphanumeric, underscore, or forward slashes).
source code
 
is_legal_base_name(name)
Validates that name is a legal base name for a graph resource.
source code
 
canonicalize_name(name)
Put name in canonical form.
source code
str
resolve_name(name, namespace_, remappings=None)
Resolve a ROS name to its global, canonical form.
source code
 
script_resolve_name(script_name, name)
Name resolver for scripts.
source code
 
anonymous_name(id)
Generate a ROS-legal 'anonymous' name
source code
Variables
  MSG_EXT = '.msg'
  SRV_EXT = '.srv'
  SEP = '/'
  GLOBALNS = '/'
  PRIV_NAME = '~'
  REMAP = ':='
  ANYTYPE = '*'
  NAME_LEGAL_CHARS_P = re.compile(r'^[~/A-Za-z][\w/]*$')
  BASE_NAME_LEGAL_CHARS_P = re.compile(r'^[A-Za-z]\w*$')
  __package__ = 'rosgraph'
Function Details

get_ros_namespace(env=None, argv=None)

source code 
Parameters:
  • env (dict) - environment dictionary (defaults to os.environ)
  • argv ([str]) - command-line arguments (defaults to sys.argv)
Returns: str
ROS namespace of current program

make_caller_id(name)

source code 

Resolve a local name to the caller ID based on ROS environment settings (i.e. ROS_NAMESPACE)

Parameters:
  • name (str) - local name to calculate caller ID from, e.g. 'camera', 'node'
Returns: str
caller ID based on supplied local name

make_global_ns(name)

source code 

Convert name to a global name with a trailing namespace separator.

Parameters:
  • name (str) - ROS resource name. Cannot be a ~name.
Returns: str
Raises:
  • ValueError - if name is a ~name

is_global(name)

source code 

Test if name is a global graph resource name.

Parameters:
  • name (str) - must be a legal name in canonical form
Returns: bool
True if name is a globally referenced name (i.e. /ns/name)

is_private(name)

source code 

Test if name is a private graph resource name.

Parameters:
  • name (str) - must be a legal name in canonical form

namespace(name)

source code 

Get the namespace of name. The namespace is returned with a trailing slash in order to favor easy concatenation and easier use within the global context.

Parameters:
  • name (str) - name to return the namespace of. Must be a legal name. NOTE: an empty name will return the global namespace.
Returns: str
Raises:
  • ValueError - if name is invalid

ns_join(ns, name)

source code 

Join a namespace and name. If name is unjoinable (i.e. ~private or /global) it will be returned without joining

Parameters:
  • ns (str) - namespace ('/' and '~' are both legal). If ns is the empty string, name will be returned.
  • name, str - a legal name
Returns: str

load_mappings(argv)

source code 

Load name mappings encoded in command-line arguments. This will filter out any parameter assignment mappings.

Parameters:
  • argv ([str]) - command-line arguments
Returns: dict {str: str}
name->name remappings.

is_legal_name(name)

source code 

Check if name is a legal ROS name for graph resources (alphabetical character followed by alphanumeric, underscore, or forward slashes). This constraint is currently not being enforced, but may start getting enforced in later versions of ROS.

Parameters:
  • name (str) - Name

is_legal_base_name(name)

source code 

Validates that name is a legal base name for a graph resource. A base name has no namespace context, e.g. "node_name".

canonicalize_name(name)

source code 

Put name in canonical form. Extra slashes '//' are removed and name is returned without any trailing slash, e.g. /foo/bar

Parameters:
  • name (str) - ROS name

resolve_name(name, namespace_, remappings=None)

source code 

Resolve a ROS name to its global, canonical form. Private ~names are resolved relative to the node name.

Parameters:
  • name (str) - name to resolve.
  • namespace_ (str) - node name to resolve relative to.
  • remappings - Map of resolved remappings. Use None to indicate no remapping.
Returns: str
Resolved name. If name is empty/None, resolve_name returns parent namespace_. If namespace_ is empty/None,

script_resolve_name(script_name, name)

source code 

Name resolver for scripts. Supports :envvar:`ROS_NAMESPACE`.  Does not
support remapping arguments.

:param name: name to resolve, ``str``
:param script_name: name of script. script_name must not
  contain a namespace., ``str``
:returns: resolved name, ``str``

anonymous_name(id)

source code 

Generate a ROS-legal 'anonymous' name

Parameters:
  • id (str) - prefix for anonymous name