38 atomics = [
'bool',
'byte',
'int8',
'uint8',
'int16',
'uint16',
'int32',
'uint32',
'int64',
'uint64',
'float32',
'float64',
'string']
39 specials = [
'time',
'duration']
42 """ A typedef is a dict containing the following fields: 49 - string[] constvalues 50 get_typedef will return a typedef dict for the specified message type """ 60 instance = ros_loader.get_message_instance(type)
64 """ Returns a typedef dict for the service request class for the specified service type """ 66 instance = ros_loader.get_service_request_instance(servicetype)
70 """ Returns a typedef dict for the service response class for the specified service type """ 72 instance = ros_loader.get_service_response_instance(servicetype)
76 """ Returns a list of typedef dicts for this type and all contained type fields """ 81 """ Returns a list of typedef dicts for this type and all contained type fields """ 83 instance = ros_loader.get_service_request_instance(servicetype)
90 """ Returns a list of typedef dicts for this type and all contained type fields """ 92 instance = ros_loader.get_service_response_instance(servicetype)
99 """ Returns the full text (similar to `gendeps --cat`) for the specified message type """ 102 instance = ros_loader.get_message_instance(type)
103 return instance._full_text
108 """ Gets a typedef dict for the specified instance """ 109 if instance
is None or not hasattr(instance,
"__slots__")
or not hasattr(instance,
"_slot_types"):
118 for i
in range(len(instance.__slots__)):
120 name = instance.__slots__[i]
121 fieldnames.append(name)
124 field_type = instance._slot_types[i]
126 if field_type[-1:]==
']':
127 if field_type[-2:-1]==
'[':
129 field_type = field_type[:-2]
131 split = field_type.find(
'[')
132 arraylen = int(field_type[split+1:-1])
133 field_type = field_type[:split]
134 fieldarraylen.append(arraylen)
137 field_instance = getattr(instance, name)
138 fieldtypes.append(
_type_name(field_type, field_instance))
141 example = field_instance
144 elif field_type
not in atomics:
146 examples.append(str(example))
149 attributes = inspect.getmembers(instance)
150 for attribute
in attributes:
151 if attribute[0]
not in instance.__slots__
and not attribute[0].startswith(
'_')
and not inspect.isroutine(attribute[1]):
152 constnames.append(str(attribute[0]))
153 constvalues.append(str(attribute[1]))
157 "fieldnames" : fieldnames,
158 "fieldtypes" : fieldtypes,
159 "fieldarraylen" : fieldarraylen,
160 "examples" : examples,
161 "constnames" : constnames,
162 "constvalues" : constvalues
169 if type==
"time" or type==
"duration":
172 "fieldnames": [
"secs",
"nsecs"],
173 "fieldtypes": [
"int32",
"int32"],
174 "fieldarraylen": [-1, -1],
175 "examples": [
"0",
"0" ],
182 """ returns the type def for this type as well as the type defs for any fields within the type """ 183 if type
in typesseen:
188 typesseen.append(type)
200 typedefs = [ typedef ]
201 for fieldtype
in typedef[
"fieldtypes"]:
207 """ given a short type, and an object instance of that type, 208 determines and returns the fully qualified type """ 210 if type
in atomics
or type
in specials:
215 if isinstance(instance, list):
222 mod = instance.__module__
223 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_full_text(type)
def get_typedef_recursive(type)