mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-09-25 20:28:26 +08:00
Add Zenoh pico support
This commit is contained in:
committed by
Daniel Agar
parent
5137ca1ccc
commit
019d232911
@@ -70,9 +70,9 @@ __license__ = "BSD"
|
||||
__email__ = "thomasgubler@gmail.com"
|
||||
|
||||
|
||||
TEMPLATE_FILE = ['msg.h.em', 'msg.cpp.em']
|
||||
TEMPLATE_FILE = ['msg.h.em', 'msg.cpp.em', 'uorb_idl_header.h.em']
|
||||
TOPICS_LIST_TEMPLATE_FILE = ['uORBTopics.hpp.em', 'uORBTopics.cpp.em']
|
||||
OUTPUT_FILE_EXT = ['.h', '.cpp']
|
||||
OUTPUT_FILE_EXT = ['.h', '.cpp', '.h']
|
||||
INCL_DEFAULT = ['std_msgs:./msg/std_msgs']
|
||||
PACKAGE = 'px4'
|
||||
TOPICS_TOKEN = '# TOPICS '
|
||||
@@ -150,6 +150,7 @@ def generate_output_from_file(format_idx, filename, outputdir, package, template
|
||||
em_globals = {
|
||||
"name_snake_case": full_type_name_snake,
|
||||
"file_name_in": filename,
|
||||
"file_base_name": file_base_name,
|
||||
"search_path": search_path,
|
||||
"msg_context": msg_context,
|
||||
"spec": spec,
|
||||
@@ -161,7 +162,10 @@ def generate_output_from_file(format_idx, filename, outputdir, package, template
|
||||
os.makedirs(outputdir)
|
||||
|
||||
template_file = os.path.join(templatedir, TEMPLATE_FILE[format_idx])
|
||||
output_file = os.path.join(outputdir, full_type_name_snake + OUTPUT_FILE_EXT[format_idx])
|
||||
if format_idx == 2:
|
||||
output_file = os.path.join(outputdir, file_base_name + OUTPUT_FILE_EXT[format_idx])
|
||||
else:
|
||||
output_file = os.path.join(outputdir, full_type_name_snake + OUTPUT_FILE_EXT[format_idx])
|
||||
|
||||
return generate_by_template(output_file, template_file, em_globals)
|
||||
|
||||
@@ -217,6 +221,7 @@ if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser(description='Convert msg files to uorb headers/sources')
|
||||
parser.add_argument('--headers', help='Generate header files', action='store_true')
|
||||
parser.add_argument('--sources', help='Generate source files', action='store_true')
|
||||
parser.add_argument('--uorb-idl-header', help='Generate uORB compatible idl header', action='store_true')
|
||||
parser.add_argument('-f', dest='file',
|
||||
help="files to convert (use only without -d)",
|
||||
nargs="+")
|
||||
@@ -241,6 +246,11 @@ if __name__ == "__main__":
|
||||
generate_idx = 0
|
||||
elif args.sources:
|
||||
generate_idx = 1
|
||||
elif args.uorb_idl_header:
|
||||
for f in args.file:
|
||||
print(f)
|
||||
generate_output_from_file(2, f, args.outputdir, args.package, args.templatedir, INCL_DEFAULT)
|
||||
exit(0)
|
||||
else:
|
||||
print('Error: either --headers or --sources must be specified')
|
||||
exit(-1)
|
||||
|
||||
65
Tools/msg/templates/cdrstream/uorb_idl_header.h.em
Normal file
65
Tools/msg/templates/cdrstream/uorb_idl_header.h.em
Normal file
@@ -0,0 +1,65 @@
|
||||
@{
|
||||
import genmsg.msgs
|
||||
import re
|
||||
|
||||
from px_generate_uorb_topic_helper import * # this is in Tools/
|
||||
|
||||
uorb_struct = '%s_s'%name_snake_case
|
||||
uorb_struct_upper = name_snake_case.upper()
|
||||
}@
|
||||
|
||||
/****************************************************************
|
||||
|
||||
PX4 Cyclone DDS IDL to C Translator compatible idl struct
|
||||
Source: @file_name_in
|
||||
Compatible with Cyclone DDS: V0.11.0
|
||||
|
||||
*****************************************************************/
|
||||
#ifndef DDSC_IDL_UORB_@(uorb_struct_upper)_H
|
||||
#define DDSC_IDL_UORB_@(uorb_struct_upper)_H
|
||||
|
||||
#include "dds/ddsc/dds_public_impl.h"
|
||||
#include "dds/cdr/dds_cdrstream.h"
|
||||
#include <uORB/topics/@(name_snake_case).h>
|
||||
|
||||
@##############################
|
||||
@# Includes for dependencies
|
||||
@##############################
|
||||
@{
|
||||
for field in spec.parsed_fields():
|
||||
if (not field.is_builtin):
|
||||
if (not field.is_header):
|
||||
(package, name) = genmsg.names.package_resource_name(field.base_type)
|
||||
package = package or spec.package # convert '' to package
|
||||
|
||||
print('#include "%s.h"'%(name))
|
||||
name = re.sub(r'(?<!^)(?=[A-Z])', '_', name).lower()
|
||||
print('#include <uORB/topics/%s.h>'%(name))
|
||||
}@
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
@{
|
||||
for field in spec.parsed_fields():
|
||||
if (not field.is_builtin):
|
||||
if (not field.is_header):
|
||||
(package, name) = genmsg.names.package_resource_name(field.base_type)
|
||||
package = package or spec.package # convert '' to package
|
||||
|
||||
print('typedef px4_msg_%s px4_msg_px4__msg__%s;' % (name,name))
|
||||
}@
|
||||
|
||||
|
||||
|
||||
typedef struct @uorb_struct px4_msg_@(file_base_name);
|
||||
|
||||
extern const struct dds_cdrstream_desc px4_msg_@(file_base_name)_cdrstream_desc;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DDSC_IDL_UORB_@(uorb_struct_upper)_H */
|
||||
Reference in New Issue
Block a user