2929from rosidl_parser .definition import AbstractSequence
3030from rosidl_parser .definition import AbstractString
3131from rosidl_parser .definition import AbstractWString
32+ from rosidl_parser .definition import Action
3233from rosidl_parser .definition import Array
3334from rosidl_parser .definition import BASIC_TYPES
3435from rosidl_parser .definition import BasicType
@@ -93,13 +94,20 @@ def generate_rs(generator_arguments_file, typesupport_impls):
9394 os .path .join (template_dir , 'srv.rs.em' ): ['rust/src/%s.rs' ],
9495 }
9596
97+ mapping_actions = {
98+ os .path .join (template_dir , 'action.rs.em' ): ['rust/src/%s.rs' ],
99+ }
100+
96101 # Ensure the required templates exist
97102 for template_file in mapping_msgs .keys ():
98103 assert os .path .exists (template_file ), \
99104 'Messages template file %s not found' % template_file
100105 for template_file in mapping_srvs .keys ():
101106 assert os .path .exists (template_file ), \
102107 'Services template file %s not found' % template_file
108+ for template_file in mapping_actions .keys ():
109+ assert os .path .exists (template_file ), \
110+ 'Actions template file %s not found' % template_file
103111
104112 data = {
105113 'get_rmw_rs_type' : make_get_rmw_rs_type (args ['package_name' ]),
@@ -113,6 +121,7 @@ def generate_rs(generator_arguments_file, typesupport_impls):
113121 convert_lower_case_underscore_to_camel_case ,
114122 'msg_specs' : [],
115123 'srv_specs' : [],
124+ 'action_specs' : [],
116125 'package_name' : args ['package_name' ],
117126 'typesupport_impls' : typesupport_impls ,
118127 'interface_path' : idl_rel_path ,
@@ -127,6 +136,9 @@ def generate_rs(generator_arguments_file, typesupport_impls):
127136 for service in idl_content .get_elements_of_type (Service ):
128137 data ['srv_specs' ].append (('srv' , service ))
129138
139+ for action in idl_content .get_elements_of_type (Action ):
140+ data ['action_specs' ].append (('action' , action ))
141+
130142 if data ['msg_specs' ]:
131143 for template_file , generated_filenames in mapping_msgs .items ():
132144 for generated_filename in generated_filenames :
@@ -149,6 +161,17 @@ def generate_rs(generator_arguments_file, typesupport_impls):
149161 generated_file ,
150162 minimum_timestamp = latest_target_timestamp )
151163
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+ expand_template (
170+ os .path .join (template_dir , template_file ),
171+ data .copy (),
172+ generated_file ,
173+ minimum_timestamp = latest_target_timestamp )
174+
152175 expand_template (
153176 os .path .join (template_dir , 'lib.rs.em' ),
154177 data .copy (),
0 commit comments