roslib/Header -> std_msgs/Header

This commit is contained in:
Ken Conley 2010-11-09 20:31:14 +00:00
parent db3ca72eef
commit 56bf5d9ce7
4 changed files with 16 additions and 10 deletions

View File

@ -164,7 +164,7 @@ class Special:
return None
_SPECIAL_TYPES = {
roslib.msgs.HEADER: Special('roslib.msg._Header.Header()', None, 'import roslib.msg'),
roslib.msgs.HEADER: Special('std_msgs.msg._Header.Header()', None, 'import std_msgs.msg'),
roslib.msgs.TIME: Special('roslib.rostime.Time()', '%s.canon()', 'import roslib.rostime'),
roslib.msgs.DURATION: Special('roslib.rostime.Duration()', '%s.canon()', 'import roslib.rostime'),
}
@ -340,7 +340,7 @@ def compute_import(package, type_):
# important: have to do is_builtin check first. We do this check
# against the unresolved type builtins/specials are never
# relative. This requires some special handling for Header, which has
# two names (Header and roslib/Header).
# two names (Header and std_msgs/Header).
if roslib.msgs.is_builtin(orig_base_type) or \
roslib.msgs.is_header_type(orig_base_type):
# of the builtin types, only special types require import
@ -1128,8 +1128,8 @@ def _gen_dyn_modify_references(py_text, types):
py_text = py_text.replace('class %s('%base_type, 'class %s('%gen_name)
# - super() references for __init__
py_text = py_text.replace('super(%s,'%base_type, 'super(%s,'%gen_name)
# roslib/Header also has to be rewritten to be a local reference
py_text = py_text.replace('roslib.msg._Header.Header', _gen_dyn_name('roslib', 'Header'))
# std_msgs/Header also has to be rewritten to be a local reference
py_text = py_text.replace('std_msgs.msg._Header.Header', _gen_dyn_name('std_msgs', 'Header'))
return py_text
def generate_dynamic(core_type, msg_cat):

View File

@ -52,7 +52,7 @@ import roslib.packages
import roslib.srvs
# name of the Header type as gentools knows it
_header_type_name = 'roslib/Header'
_header_type_name = 'std_msgs/Header'
def _add_msgs_depends(spec, deps, package_context):
"""

View File

@ -264,8 +264,9 @@ def check_type(field_name, field_type, field_val):
check_type(field_name+"[]", base_type, v)
else:
if isinstance(field_val, Message):
if field_val._type == 'roslib/Header':
if field_type not in ['Header', 'roslib/Header']:
# roslib/Header is the old location of Header. We check it for backwards compat
if field_val._type in ['std_msgs/Header', 'roslib/Header']:
if field_type not in ['Header', 'std_msgs/Header', 'roslib/Header']:
raise SerializationError("field %s must be a Header instead of a %s"%(field_name, field_val._type))
elif field_val._type != field_type:
raise SerializationError("field %s must be of type %s instead of %s"%(field_name, field_type, field_val._type))

View File

@ -90,7 +90,9 @@ def resolve_type(type_, package_context):
"""
Resolve type name based on current package context.
NOTE: in ROS, 'Header' always resolves to 'roslib/Header'
NOTE: in ROS Diamondback, 'Header' resolves to
'std_msgs/Header'. In previous releases, it resolves to
'roslib/Header' (REP 100).
e.g.::
resolve_type('String', 'std_msgs') -> 'std_msgs/String'
@ -103,7 +105,7 @@ def resolve_type(type_, package_context):
if bt in BUILTIN_TYPES:
return type_
elif bt == 'Header':
return 'roslib/Header'
return 'std_msgs/Header'
elif SEP in type_:
return type_
else:
@ -377,6 +379,8 @@ def _init():
# register Header under both contexted and de-contexted name
_, spec = load_from_file(header, '')
register(HEADER, spec)
register('std_msgs/'+HEADER, spec)
# backwards compat, REP 100
register('roslib/'+HEADER, spec)
for k, spec in EXTENDED_BUILTINS.iteritems():
register(k, spec)
@ -675,7 +679,8 @@ def is_header_type(type_):
@return: True if \a type_ refers to the ROS Header type
@rtype: bool
"""
return type_ in [HEADER, 'roslib/Header']
# for backwards compatibility, include roslib/Header. REP 100
return type_ in [HEADER, 'std_msgs/Header', 'roslib/Header']
# time and duration types are represented as aggregate data structures
# for the purposes of serialization from the perspective of