def convert_action_to_idl(package_dir, package_name, input_file, output_dir): assert package_dir.is_absolute() assert not input_file.is_absolute() assert input_file.suffix == '.action' abs_input_file = package_dir / input_file print('Reading input file: {abs_input_file}'.format_map(locals())) abs_input_file = package_dir / input_file content = abs_input_file.read_text(encoding='utf-8') action = parse_action_string(package_name, input_file.stem, content) # HACK as long as the return action specification contains implicitly added # fields they have to be skipped when generating .idl files assert len(action.goal_service.request.fields) >= 1 assert action.goal_service.request.fields[0].name == 'uuid' action.goal_service.request.fields.pop(0) assert len(action.goal_service.response.fields) >= 2 assert action.goal_service.response.fields[0].name == 'accepted' assert action.goal_service.response.fields[1].name == 'stamp' action.goal_service.response.fields.pop(1) action.goal_service.response.fields.pop(0) assert len(action.result_service.request.fields) >= 1 assert action.result_service.request.fields[0].name == 'uuid' action.result_service.request.fields.pop(0) assert len(action.result_service.response.fields) >= 1 assert action.result_service.response.fields[0].name == 'status' action.result_service.response.fields.pop(0) assert len(action.feedback.fields) >= 1 assert action.feedback.fields[0].name == 'uuid' action.feedback.fields.pop(0) output_file = output_dir / input_file.with_suffix('.idl').name abs_output_file = output_file.absolute() print('Writing output file: {abs_output_file}'.format_map(locals())) data = { 'pkg_name': package_name, 'relative_input_file': input_file, 'action': action, } expand_template('action.idl.em', data, output_file) return output_file
def convert_srv_to_idl(package_dir, package_name, input_file, output_dir): assert package_dir.is_absolute() assert not input_file.is_absolute() assert input_file.suffix == '.srv' abs_input_file = package_dir / input_file print('Reading input file: {abs_input_file}'.format_map(locals())) abs_input_file = package_dir / input_file content = abs_input_file.read_text(encoding='utf-8') srv = parse_service_string(package_name, input_file.stem, content) output_file = output_dir / input_file.with_suffix('.idl').name abs_output_file = output_file.absolute() print('Writing output file: {abs_output_file}'.format_map(locals())) data = { 'pkg_name': package_name, 'relative_input_file': input_file, 'srv': srv, } expand_template('srv.idl.em', data, output_file, encoding='iso-8859-1') return output_file
def convert_msg_to_idl(package_dir, package_name, input_file, output_dir): assert package_dir.is_absolute() assert not input_file.is_absolute() assert input_file.suffix == '.msg' abs_input_file = package_dir / input_file print(f'Reading input file: {abs_input_file}') abs_input_file = package_dir / input_file content = abs_input_file.read_text(encoding='utf-8') msg = parse_message_string(package_name, input_file.stem, content) output_file = output_dir / input_file.with_suffix('.idl').name abs_output_file = output_file.absolute() print(f'Writing output file: {abs_output_file}') data = { 'pkg_name': package_name, 'relative_input_file': input_file.as_posix(), 'msg': msg, } expand_template('msg.idl.em', data, output_file, encoding='iso-8859-1') return output_file
def convert_msg_to_idl(package_dir, package_name, input_file, output_dir): assert package_dir.is_absolute() assert not input_file.is_absolute() assert input_file.suffix == '.msg' abs_input_file = package_dir / input_file print('Reading input file: {abs_input_file}'.format_map(locals())) abs_input_file = package_dir / input_file content = abs_input_file.read_text(encoding='utf-8') msg = parse_message_string(package_name, input_file.stem, content) output_file = output_dir / input_file.with_suffix('.idl').name abs_output_file = output_file.absolute() print('Writing output file: {abs_output_file}'.format_map(locals())) data = { 'pkg_name': package_name, 'relative_input_file': input_file, 'msg': msg, } expand_template('msg.idl.em', data, output_file) return output_file
def convert_action_to_idl(package_dir, package_name, input_file, output_dir): assert package_dir.is_absolute() assert not input_file.is_absolute() assert input_file.suffix == '.action' abs_input_file = package_dir / input_file print('Reading input file: {abs_input_file}'.format_map(locals())) abs_input_file = package_dir / input_file content = abs_input_file.read_text(encoding='utf-8') action = parse_action_string(package_name, input_file.stem, content) output_file = output_dir / input_file.with_suffix('.idl').name abs_output_file = output_file.absolute() print('Writing output file: {abs_output_file}'.format_map(locals())) data = { 'pkg_name': package_name, 'relative_input_file': input_file, 'action': action, } expand_template('action.idl.em', data, output_file) return output_file