rosros 0.2.5
Simple unified interface to ROS1 / ROS2 Python API
Loading...
Searching...
No Matches
names.py
Go to the documentation of this file.
1"""
2Stand-ins for `rospy.names` in ROS2.
3
4------------------------------------------------------------------------------
5This file is part of rosros - simple unified interface to ROS1 / ROS2.
6Released under the BSD License.
7
8@author Erki Suurjaak
9@created 30.05.2022
10@modified 30.05.2022
11------------------------------------------------------------------------------
12"""
13## @namespace rosros.rospify.names
14from .. import ros2
15
16
17def get_name():
18 """Returns fully resolved name of local node."""
19 return ros2.get_node_name() if ros2.NODE else "/unnamed"
20
21
22
23get_caller_id = get_name
24
25
27 """Returns namespace of local node."""
28 return ros2.NODE.get_namespace() if ros2.NODE else "/"
29
30
31def remap_name(name, caller_id=None, resolved=True):
32 """
33 Returns a remapped topic/service name.
34
35 @param name name to remap
36 @param caller_id namespace to resolve a relative or private name under,
37 by default current node namespace
38 @param resolved ignored (does nothing in ROS1 also)
39 @return remapped name resolved to namespace, or original if not mapped
40 """
41 return ros2.remap_name(name, caller_id)
42
43
44def resolve_name(name, caller_id=None):
45 """
46 Resolve a ROS name to its global, canonical form.
47
48 Private ~names are resolved relative to the node name.
49
50 @param name name to resolve.
51 @param caller_id node name to resolve relative to.
52 To resolve to local namespace, omit this parameter (or use None)
53 @return Resolved name. If name is empty/None, resolve_name
54 returns parent namespace.
55
56 """
57 return ros2.resolve_name(name, caller_id)
58
59
60__all__ = [
61 "get_caller_id", "get_name", "get_namespace", "remap_name", "resolve_name"
62]
get_namespace()
Returns namespace of local node.
Definition names.py:26