37 atomics = [
'bool',
'byte',
'int8',
'uint8',
'int16',
'uint16',
'int32',
'uint32',
'int64',
'uint64',
'float32',
'float64',
'string']
38 specials = [
'time',
'duration']
42 """ A typedef is a dict containing the following fields: 48 get_typedef will return a typedef dict for the specified message type """ 58 instance = ros_loader.get_message_instance(type)
62 """ Returns a typedef dict for the service request class for the specified service type """ 64 instance = ros_loader.get_service_request_instance(servicetype)
68 """ Returns a typedef dict for the service response class for the specified service type """ 70 instance = ros_loader.get_service_response_instance(servicetype)
74 """ Returns a list of typedef dicts for this type and all contained type fields """ 79 """ Returns a list of typedef dicts for this type and all contained type fields """ 81 instance = ros_loader.get_service_request_instance(servicetype)
88 """ Returns a list of typedef dicts for this type and all contained type fields """ 90 instance = ros_loader.get_service_response_instance(servicetype)
97 """ Gets a typedef dict for the specified instance """ 98 if instance
is None or not hasattr(instance,
"__slots__")
or not hasattr(instance,
"_slot_types"):
105 for i
in range(len(instance.__slots__)):
107 name = instance.__slots__[i]
108 fieldnames.append(name)
111 field_type = instance._slot_types[i]
113 if field_type[-1:]==
']':
114 if field_type[-2:-1]==
'[':
116 field_type = field_type[:-2]
118 split = field_type.find(
'[')
119 arraylen = int(field_type[split+1:-1])
120 field_type = field_type[:split]
121 fieldarraylen.append(arraylen)
124 field_instance = getattr(instance, name)
125 fieldtypes.append(
_type_name(field_type, field_instance))
128 example = field_instance
131 elif field_type
not in atomics:
133 examples.append(str(example))
137 "fieldnames": fieldnames,
138 "fieldtypes": fieldtypes,
139 "fieldarraylen": fieldarraylen,
147 if type==
"time" or type==
"duration":
150 "fieldnames": [
"secs",
"nsecs"],
151 "fieldtypes": [
"int32",
"int32"],
152 "fieldarraylen": [-1, -1],
153 "examples": [
"0",
"0" ]
158 """ returns the type def for this type as well as the type defs for any fields within the type """ 159 if type
in typesseen:
164 typesseen.append(type)
176 typedefs = [ typedef ]
177 for fieldtype
in typedef[
"fieldtypes"]:
183 """ given a short type, and an object instance of that type, 184 determines and returns the fully qualified type """ 186 if type
in atomics
or type
in specials:
191 if isinstance(instance, list):
198 mod = instance.__module__
199 type = mod[0:mod.find(
'.')]+
"/"+instance.__class__.__name__
def _type_name(type, instance)
def _get_special_typedef(type)
def _get_typedef(instance)
def get_service_request_typedef_recursive(servicetype)
def get_service_request_typedef(servicetype)
def get_service_response_typedef(servicetype)
def _type_name_from_instance(instance)
def _get_subtypedefs_recursive(typedef, typesseen)
def get_service_response_typedef_recursive(servicetype)
def _get_typedefs_recursive(type, typesseen)
def get_typedef_recursive(type)