mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-08-01 20:27:57 +08:00
uORB: add bitset for faster orb_exists check and remove uORB::Subscription lazy subscribe hack/optimization
- add PX4 bitset and atomic_bitset with testing - add uORB::Subscription constructor to take ORB_ID enum - move orb test messages into msg/
This commit is contained in:
@@ -13,7 +13,7 @@
|
||||
@###############################################
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copyright (C) 2013-2015 PX4 Development Team. All rights reserved.
|
||||
* Copyright (C) 2013-2020 PX4 Development Team. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@@ -44,31 +44,35 @@
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#include <uORB/uORBTopics.h>
|
||||
#include <uORB/topics/uORBTopics.hpp>
|
||||
#include <uORB/uORB.h>
|
||||
@{
|
||||
msg_names = [mn.replace(".msg", "") for mn in msgs]
|
||||
msgs_count = len(msg_names)
|
||||
msg_names_all = list(set(msg_names + multi_topics)) # set() filters duplicates
|
||||
msg_names_all.sort()
|
||||
msgs_count_all = len(msg_names_all)
|
||||
}@
|
||||
@[for msg_name in msg_names]@
|
||||
#include <uORB/topics/@(msg_name).h>
|
||||
@[end for]
|
||||
|
||||
const size_t _uorb_topics_count = @(msgs_count_all);
|
||||
const constexpr struct orb_metadata* const _uorb_topics_list[_uorb_topics_count] = {
|
||||
const constexpr struct orb_metadata *const uorb_topics_list[ORB_TOPICS_COUNT] = {
|
||||
@[for idx, msg_name in enumerate(msg_names_all, 1)]@
|
||||
ORB_ID(@(msg_name))@[if idx != msgs_count_all],@[end if]
|
||||
ORB_ID(@(msg_name))@[if idx != msgs_count_all], @[end if]
|
||||
@[end for]
|
||||
};
|
||||
|
||||
size_t orb_topics_count()
|
||||
const struct orb_metadata *const *orb_get_topics()
|
||||
{
|
||||
return _uorb_topics_count;
|
||||
return uorb_topics_list;
|
||||
}
|
||||
|
||||
const struct orb_metadata *const*orb_get_topics()
|
||||
const struct orb_metadata *get_orb_meta(ORB_ID id)
|
||||
{
|
||||
return _uorb_topics_list;
|
||||
if (id == ORB_ID::INVALID) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return uorb_topics_list[static_cast<uint8_t>(id)];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user