2828from rosidl_parser .definition import AbstractSequence
2929from rosidl_parser .definition import AbstractString
3030from rosidl_parser .definition import AbstractWString
31+ from rosidl_parser .definition import Action
3132from rosidl_parser .definition import Array
3233from rosidl_parser .definition import BASIC_TYPES
3334from rosidl_parser .definition import BasicType
@@ -92,13 +93,20 @@ def generate_rs(generator_arguments_file, typesupport_impls):
9293 os .path .join (template_dir , 'srv.rs.em' ): ['rust/src/%s.rs' ],
9394 }
9495
96+ mapping_actions = {
97+ os .path .join (template_dir , 'action.rs.em' ): ['rust/src/%s.rs' ],
98+ }
99+
95100 # Ensure the required templates exist
96101 for template_file in mapping_msgs .keys ():
97102 assert os .path .exists (template_file ), \
98103 'Messages template file %s not found' % template_file
99104 for template_file in mapping_srvs .keys ():
100105 assert os .path .exists (template_file ), \
101106 '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
102110
103111 data = {
104112 'get_rmw_rs_type' : make_get_rmw_rs_type (args ['package_name' ]),
@@ -112,6 +120,7 @@ def generate_rs(generator_arguments_file, typesupport_impls):
112120 convert_lower_case_underscore_to_camel_case ,
113121 'msg_specs' : [],
114122 'srv_specs' : [],
123+ 'action_specs' : [],
115124 'package_name' : args ['package_name' ],
116125 'typesupport_impls' : typesupport_impls ,
117126 'interface_path' : idl_rel_path ,
@@ -126,6 +135,9 @@ def generate_rs(generator_arguments_file, typesupport_impls):
126135 for service in idl_content .get_elements_of_type (Service ):
127136 data ['srv_specs' ].append (('srv' , service ))
128137
138+ for action in idl_content .get_elements_of_type (Action ):
139+ data ['action_specs' ].append (('action' , action ))
140+
129141 if data ['msg_specs' ]:
130142 for template_file , generated_filenames in mapping_msgs .items ():
131143 for generated_filename in generated_filenames :
@@ -148,6 +160,17 @@ def generate_rs(generator_arguments_file, typesupport_impls):
148160 generated_file ,
149161 minimum_timestamp = latest_target_timestamp )
150162
163+ if data ['action_specs' ]:
164+ for template_file , generated_filenames in mapping_actions .items ():
165+ for generated_filename in generated_filenames :
166+ generated_file = os .path .join (args ['output_dir' ],
167+ generated_filename % 'action' )
168+ rosidl_pycommon .expand_template (
169+ os .path .join (template_dir , template_file ),
170+ data .copy (),
171+ generated_file ,
172+ minimum_timestamp = latest_target_timestamp )
173+
151174 rosidl_pycommon .expand_template (
152175 os .path .join (template_dir , 'lib.rs.em' ),
153176 data .copy (),
0 commit comments