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

Module names

source code

Warning: do not use this library. It is unstable and most of the routines here have been superceded by other libraries (e.g. genmsg). These routines will likely be *deleted* in future releases.

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
str
resource_name(res_pkg_name, name, my_pkg=None)
Convert package name + resource into a fully qualified resource name
source code
str
resource_name_base(name)
pkg/typeName -> typeName, typeName -> typeName
source code
str
resource_name_package(name)
pkg/typeName -> pkg, typeName -> None
source code
str
package_resource_name(name)
Split a name into its package and resource name parts, e.g.
source code
 
is_legal_resource_name(name)
Check if name is a legal ROS name for filesystem resources (alphabetical character followed by alphanumeric, underscore, or forward slashes).
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
 
is_legal_resource_base_name(name)
Validates that name is a legal resource base name.
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
 
anonymous_name(id)
Generate a ROS-legal 'anonymous' name
source code
Variables
  PRN_SEPARATOR = '/'
  TYPE_SEPARATOR = '/'
  SEP = '/'
  GLOBALNS = '/'
  PRIV_NAME = '~'
  REMAP = ':='
  ANYTYPE = '*'
  RESOURCE_NAME_LEGAL_CHARS_P = re.compile(r'^[A-Za-z][\w_/]*$')
  NAME_LEGAL_CHARS_P = re.compile(r'^[~/A-Za-z][\w_/]*$')
  BASE_NAME_LEGAL_CHARS_P = re.compile(r'^[A-Za-z][\w_]*$')
  BASE_RESOURCE_NAME_LEGAL_CHARS_P = re.compile(r'^[A-Za-z][\w_]...
  __package__ = 'roslib'
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 (see roslib.param.load_param_mappings()).

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

resource_name(res_pkg_name, name, my_pkg=None)

source code 

Convert package name + resource into a fully qualified resource name

Parameters:
  • res_pkg_name (str) - name of package resource is located in
  • name (str) - resource base name
  • my_pkg (str) - name of package resource is being referred to in. If specified, name will be returned in local form if res_pkg_name is my_pkg
Returns: str
name for resource

resource_name_base(name)

source code 

pkg/typeName -> typeName, typeName -> typeName

Convert fully qualified resource name into the package-less resource name

Parameters:
  • name (str) - package resource name, e.g. 'std_msgs/String'
Returns: str
resource name sans package-name scope

resource_name_package(name)

source code 

pkg/typeName -> pkg, typeName -> None

Parameters:
  • name (str) - package resource name, e.g. 'std_msgs/String'
Returns: str
package name of resource

package_resource_name(name)

source code 

Split a name into its package and resource name parts, e.g. 'std_msgs/String -> std_msgs, String'

Parameters:
  • name (str) - package resource name, e.g. 'std_msgs/String'
Returns: str
package name, resource name
Raises:
  • ValueError - if name is invalid

is_legal_resource_name(name)

source code 

Check if name is a legal ROS name for filesystem 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_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".

is_legal_resource_base_name(name)

source code 

Validates that name is a legal resource base name. A base name has no package context, e.g. "String".

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,

anonymous_name(id)

source code 

Generate a ROS-legal 'anonymous' name

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

Variables Details

BASE_RESOURCE_NAME_LEGAL_CHARS_P

Value:
re.compile(r'^[A-Za-z][\w_]*$')