28
28
from rosidl_parser .definition import AbstractSequence
29
29
from rosidl_parser .definition import AbstractString
30
30
from rosidl_parser .definition import AbstractWString
31
+ from rosidl_parser .definition import Action
31
32
from rosidl_parser .definition import Array
32
33
from rosidl_parser .definition import BASIC_TYPES
33
34
from rosidl_parser .definition import BasicType
@@ -92,13 +93,20 @@ def generate_rs(generator_arguments_file, typesupport_impls):
92
93
os .path .join (template_dir , 'srv.rs.em' ): ['rust/src/%s.rs' ],
93
94
}
94
95
96
+ mapping_actions = {
97
+ os .path .join (template_dir , 'action.rs.em' ): ['rust/src/%s.rs' ],
98
+ }
99
+
95
100
# Ensure the required templates exist
96
101
for template_file in mapping_msgs .keys ():
97
102
assert os .path .exists (template_file ), \
98
103
'Messages template file %s not found' % template_file
99
104
for template_file in mapping_srvs .keys ():
100
105
assert os .path .exists (template_file ), \
101
106
'Services template file %s not found' % template_file
107
+ for template_file in mapping_actions .keys ():
108
+ assert os .path .exists (template_file ), \
109
+ 'Actions template file %s not found' % template_file
102
110
103
111
data = {
104
112
'pre_field_serde' : pre_field_serde ,
@@ -113,6 +121,7 @@ def generate_rs(generator_arguments_file, typesupport_impls):
113
121
convert_lower_case_underscore_to_camel_case ,
114
122
'msg_specs' : [],
115
123
'srv_specs' : [],
124
+ 'action_specs' : [],
116
125
'package_name' : args ['package_name' ],
117
126
'typesupport_impls' : typesupport_impls ,
118
127
'interface_path' : idl_rel_path ,
@@ -127,6 +136,9 @@ def generate_rs(generator_arguments_file, typesupport_impls):
127
136
for service in idl_content .get_elements_of_type (Service ):
128
137
data ['srv_specs' ].append (('srv' , service ))
129
138
139
+ for action in idl_content .get_elements_of_type (Action ):
140
+ data ['action_specs' ].append (('action' , action ))
141
+
130
142
if data ['msg_specs' ]:
131
143
for template_file , generated_filenames in mapping_msgs .items ():
132
144
for generated_filename in generated_filenames :
@@ -149,6 +161,17 @@ def generate_rs(generator_arguments_file, typesupport_impls):
149
161
generated_file ,
150
162
minimum_timestamp = latest_target_timestamp )
151
163
164
+ if data ['action_specs' ]:
165
+ for template_file , generated_filenames in mapping_actions .items ():
166
+ for generated_filename in generated_filenames :
167
+ generated_file = os .path .join (args ['output_dir' ],
168
+ generated_filename % 'action' )
169
+ rosidl_pycommon .expand_template (
170
+ os .path .join (template_dir , template_file ),
171
+ data .copy (),
172
+ generated_file ,
173
+ minimum_timestamp = latest_target_timestamp )
174
+
152
175
rosidl_pycommon .expand_template (
153
176
os .path .join (template_dir , 'lib.rs.em' ),
154
177
data .copy (),
0 commit comments