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.exceptions import *
|
||||||
from rospy.init import get_node_proxy
|
from rospy.init import get_node_proxy
|
||||||
from rospy.msg import AnyMsg, Message
|
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.rostime import Time, Duration, get_rostime, get_time
|
||||||
from rospy.service import ServiceException, ServiceDefinition
|
from rospy.service import ServiceException, ServiceDefinition
|
||||||
# - use tcp ros implementation of services
|
# - use tcp ros implementation of services
|
||||||
|
@ -114,7 +114,11 @@ __all__ = [
|
||||||
'TransportInitError',
|
'TransportInitError',
|
||||||
'get_node_proxy',
|
'get_node_proxy',
|
||||||
'AnyMsg', 'Message',
|
'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',
|
'Time', 'Duration', 'get_rostime', 'get_time',
|
||||||
'ServiceException', 'ServiceDefinition',
|
'ServiceException', 'ServiceDefinition',
|
||||||
'Service', 'ServiceProxy',
|
'Service', 'ServiceProxy',
|
||||||
|
|
|
@ -256,7 +256,7 @@ def get_namespace():
|
||||||
"""
|
"""
|
||||||
return _caller_namespace
|
return _caller_namespace
|
||||||
|
|
||||||
def get_caller_id():
|
def get_name():
|
||||||
"""
|
"""
|
||||||
Get fully resolved name of local node. If this is not a node,
|
Get fully resolved name of local node. If this is not a node,
|
||||||
use empty string
|
use empty string
|
||||||
|
@ -265,6 +265,9 @@ def get_caller_id():
|
||||||
"""
|
"""
|
||||||
return _caller_id
|
return _caller_id
|
||||||
|
|
||||||
|
# backwards compatibility
|
||||||
|
get_caller_id = get_name
|
||||||
|
|
||||||
def _set_caller_id(caller_id):
|
def _set_caller_id(caller_id):
|
||||||
"""
|
"""
|
||||||
Internal API.
|
Internal API.
|
||||||
|
|
|
@ -62,6 +62,7 @@ class TestRospyApi(unittest.TestCase):
|
||||||
rospy.FATAL
|
rospy.FATAL
|
||||||
|
|
||||||
rospy.get_caller_id
|
rospy.get_caller_id
|
||||||
|
rospy.get_name
|
||||||
rospy.get_master
|
rospy.get_master
|
||||||
rospy.get_namespace
|
rospy.get_namespace
|
||||||
rospy.get_published_topics
|
rospy.get_published_topics
|
||||||
|
|
|
@ -250,7 +250,21 @@ class TestRospyNames(unittest.TestCase):
|
||||||
except ParameterInvalid: pass
|
except ParameterInvalid: pass
|
||||||
|
|
||||||
def test_caller_id(self):
|
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:
|
try:
|
||||||
self.assertEquals('/unnamed', get_caller_id())
|
self.assertEquals('/unnamed', get_caller_id())
|
||||||
self.assertEquals('/', get_namespace())
|
self.assertEquals('/', get_namespace())
|
||||||
|
@ -262,7 +276,7 @@ class TestRospyNames(unittest.TestCase):
|
||||||
self.assertEquals('/foo/', get_namespace())
|
self.assertEquals('/foo/', get_namespace())
|
||||||
finally:
|
finally:
|
||||||
_set_caller_id('/unnamed')
|
_set_caller_id('/unnamed')
|
||||||
|
|
||||||
def test_valid_type_name(self):
|
def test_valid_type_name(self):
|
||||||
from rospy.names import valid_type_name, ParameterInvalid
|
from rospy.names import valid_type_name, ParameterInvalid
|
||||||
validator = valid_type_name('param_name')
|
validator = valid_type_name('param_name')
|
||||||
|
|
Loading…
Reference in New Issue