mirror of
https://gitee.com/xiaohuolufeihua/bizhang_-obav.git
synced 2026-05-21 01:12:11 +00:00
uorb autogeneration
This commit is contained in:
committed by
Lorenz Meier
parent
728de5f87b
commit
9a0e962cbf
@@ -57,8 +57,7 @@ uorb_struct = '%s_s'%spec.short_name
|
||||
uorb_pack_func = 'pack_%s'%spec.short_name
|
||||
topic_name = spec.short_name
|
||||
|
||||
type_map = {
|
||||
'int8': 'int8_t',
|
||||
type_map = {'int8': 'int8_t',
|
||||
'int16': 'int16_t',
|
||||
'int32': 'int32_t',
|
||||
'int64': 'int64_t',
|
||||
@@ -72,11 +71,9 @@ type_map = {
|
||||
'char': 'char',
|
||||
'fence_vertex': 'fence_vertex',
|
||||
'position_setpoint': 'position_setpoint',
|
||||
'esc_report': 'esc_report'
|
||||
}
|
||||
'esc_report': 'esc_report'}
|
||||
|
||||
msgtype_size_map = {
|
||||
'int8': 8,
|
||||
msgtype_size_map = {'int8': 8,
|
||||
'int16': 16,
|
||||
'int32': 32,
|
||||
'int64': 64,
|
||||
@@ -90,8 +87,7 @@ msgtype_size_map = {
|
||||
'char': 1,
|
||||
'fence_vertex': 8,
|
||||
'position_setpoint': 104,
|
||||
'esc_report': 36
|
||||
}
|
||||
'esc_report': 36}
|
||||
|
||||
def convert_type(spec_type):
|
||||
bare_type = spec_type
|
||||
|
||||
@@ -63,6 +63,11 @@ topic_name = spec.short_name
|
||||
@# Generic Includes
|
||||
@##############################
|
||||
#include <stdint.h>
|
||||
#ifdef __cplusplus
|
||||
#include <cstring>
|
||||
#else
|
||||
#include <string.h>
|
||||
#endif
|
||||
#include <uORB/uORB.h>
|
||||
|
||||
@##############################
|
||||
@@ -88,8 +93,7 @@ for field in spec.parsed_fields():
|
||||
@# Main struct of message
|
||||
@##############################
|
||||
@{
|
||||
type_map = {
|
||||
'int8': 'int8_t',
|
||||
type_map = {'int8': 'int8_t',
|
||||
'int16': 'int16_t',
|
||||
'int32': 'int32_t',
|
||||
'int64': 'int64_t',
|
||||
@@ -124,6 +128,33 @@ msgtype_size_map = {
|
||||
'esc_report': 36
|
||||
}
|
||||
|
||||
def bare_name(msg_type):
|
||||
bare = msg_type
|
||||
if '/' in msg_type:
|
||||
# removing prefix
|
||||
bare = (msg_type.split('/'))[1]
|
||||
# removing suffix
|
||||
return bare.split('[')[0]
|
||||
|
||||
def sizeof_field_type(field):
|
||||
return msgtype_size_map[bare_name(field.type)]
|
||||
|
||||
msgtype_size_map = {'int8': 8,
|
||||
'int16': 16,
|
||||
'int32': 32,
|
||||
'int64': 64,
|
||||
'uint8': 8,
|
||||
'uint16': 16,
|
||||
'uint32': 32,
|
||||
'uint64': 64,
|
||||
'float32': 32,
|
||||
'float64': 64,
|
||||
'bool': 1,
|
||||
'char': 1,
|
||||
'fence_vertex': 8,
|
||||
'position_setpoint': 104,
|
||||
'esc_report': 36}
|
||||
|
||||
def bare_name(msg_type):
|
||||
bare = msg_type
|
||||
if '/' in msg_type:
|
||||
@@ -173,8 +204,7 @@ def print_parsed_fields():
|
||||
|
||||
}@
|
||||
|
||||
// #pragma pack(push, 1)
|
||||
ORBPACKED(
|
||||
#pragma pack(push, 1)
|
||||
#ifdef __cplusplus
|
||||
@#class @(uorb_struct) {
|
||||
struct __EXPORT @(uorb_struct) {
|
||||
@@ -199,8 +229,12 @@ for constant in spec.constants:
|
||||
print('\tstatic const %s %s = %s;'%(type_px4, constant.name, int(constant.val)))
|
||||
}
|
||||
#endif
|
||||
});
|
||||
//#pragma pack(pop)
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
/**
|
||||
* @@}
|
||||
*/
|
||||
|
||||
/* register this as object request broker structure */
|
||||
@[for multi_topic in topics]@
|
||||
|
||||
@@ -118,7 +118,7 @@ enum ORB_PRIO {
|
||||
*
|
||||
* @param _name The name of the topic.
|
||||
* @param _struct The structure the topic provides.
|
||||
* @param _fields All fields in a semicolon separated list e.g: "float[3] position;bool armed"
|
||||
* @param _func The pointer to a function that packs topic
|
||||
*/
|
||||
#define ORB_DEFINE(_name, _struct, _fields) \
|
||||
const struct orb_metadata __orb_##_name = { \
|
||||
|
||||
Reference in New Issue
Block a user