rospy: adding in get_name() to supercede get_caller_id()
This commit is contained in:
parent
5d6d560d4b
commit
f16587c94d
|
@ -64,7 +64,7 @@ from rospy.core import is_shutdown, signal_shutdown, \
|
|||
from rospy.exceptions import *
|
||||
from rospy.init import get_node_proxy
|
||||
from rospy.msg import AnyMsg, Message
|
||||
from rospy.names import get_caller_id, get_namespace, resolve_name, remap_name
|
||||
from rospy.names import get_name, get_caller_id, get_namespace, resolve_name, remap_name
|
||||
from rospy.rostime import Time, Duration, get_rostime, get_time
|
||||
from rospy.service import ServiceException, ServiceDefinition
|
||||
# - use tcp ros implementation of services
|
||||
|
@ -114,7 +114,11 @@ __all__ = [
|
|||
'TransportInitError',
|
||||
'get_node_proxy',
|
||||
'AnyMsg', 'Message',
|
||||
'get_caller_id', 'get_namespace', 'resolve_name', 'remap_name',
|
||||
'get_name',
|
||||
'get_caller_id',
|
||||
'get_namespace',
|
||||
'resolve_name',
|
||||
'remap_name',
|
||||
'Time', 'Duration', 'get_rostime', 'get_time',
|
||||
'ServiceException', 'ServiceDefinition',
|
||||
'Service', 'ServiceProxy',
|
||||
|
|
|
@ -256,7 +256,7 @@ def get_namespace():
|
|||
"""
|
||||
return _caller_namespace
|
||||
|
||||
def get_caller_id():
|
||||
def get_name():
|
||||
"""
|
||||
Get fully resolved name of local node. If this is not a node,
|
||||
use empty string
|
||||
|
@ -265,6 +265,9 @@ def get_caller_id():
|
|||
"""
|
||||
return _caller_id
|
||||
|
||||
# backwards compatibility
|
||||
get_caller_id = get_name
|
||||
|
||||
def _set_caller_id(caller_id):
|
||||
"""
|
||||
Internal API.
|
||||
|
|
|
@ -62,6 +62,7 @@ class TestRospyApi(unittest.TestCase):
|
|||
rospy.FATAL
|
||||
|
||||
rospy.get_caller_id
|
||||
rospy.get_name
|
||||
rospy.get_master
|
||||
rospy.get_namespace
|
||||
rospy.get_published_topics
|
||||
|
|
|
@ -250,7 +250,21 @@ class TestRospyNames(unittest.TestCase):
|
|||
except ParameterInvalid: pass
|
||||
|
||||
def test_caller_id(self):
|
||||
from rospy.names import get_caller_id, _set_caller_id, get_namespace
|
||||
from rospy.names import get_caller_id, get_name, _set_caller_id, get_namespace
|
||||
# test get_name, get_caller_id, and _set_caller_id
|
||||
try:
|
||||
self.assertEquals('/unnamed', get_name())
|
||||
self.assertEquals('/', get_namespace())
|
||||
_set_caller_id('/foo')
|
||||
self.assertEquals('/foo', get_name())
|
||||
self.assertEquals('/', get_namespace())
|
||||
_set_caller_id('/foo/bar')
|
||||
self.assertEquals('/foo/bar', get_name())
|
||||
self.assertEquals('/foo/', get_namespace())
|
||||
finally:
|
||||
_set_caller_id('/unnamed')
|
||||
|
||||
# older get_caller_id usage
|
||||
try:
|
||||
self.assertEquals('/unnamed', get_caller_id())
|
||||
self.assertEquals('/', get_namespace())
|
||||
|
|
Loading…
Reference in New Issue