mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-16 16:03:33 +08:00
uORB::Publication simplify and cleanup
- base class is now template - drop linked list - virtualization no longer required
This commit is contained in:
@@ -43,7 +43,6 @@
|
||||
#include <cstring>
|
||||
|
||||
#include <uORB/SubscriptionPollable.hpp>
|
||||
#include <uORB/Publication.hpp>
|
||||
|
||||
namespace control
|
||||
{
|
||||
@@ -118,24 +117,6 @@ void Block::updateSubscriptions()
|
||||
}
|
||||
}
|
||||
|
||||
void Block::updatePublications()
|
||||
{
|
||||
uORB::PublicationNode *pub = getPublications().getHead();
|
||||
int count = 0;
|
||||
|
||||
while (pub != nullptr) {
|
||||
if (count++ > maxPublicationsPerBlock) {
|
||||
char name[blockNameLengthMax];
|
||||
getName(name, blockNameLengthMax);
|
||||
PX4_ERR("exceeded max publications for block: %s", name);
|
||||
break;
|
||||
}
|
||||
|
||||
pub->update();
|
||||
pub = pub->getSibling();
|
||||
}
|
||||
}
|
||||
|
||||
void SuperBlock::setDt(float dt)
|
||||
{
|
||||
Block::setDt(dt);
|
||||
@@ -191,26 +172,7 @@ void SuperBlock::updateChildSubscriptions()
|
||||
}
|
||||
}
|
||||
|
||||
void SuperBlock::updateChildPublications()
|
||||
{
|
||||
Block *child = getChildren().getHead();
|
||||
int count = 0;
|
||||
|
||||
while (child != nullptr) {
|
||||
if (count++ > maxChildrenPerBlock) {
|
||||
char name[blockNameLengthMax];
|
||||
getName(name, blockNameLengthMax);
|
||||
PX4_ERR("exceeded max children for block: %s", name);
|
||||
break;
|
||||
}
|
||||
|
||||
child->updatePublications();
|
||||
child = child->getSibling();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace control
|
||||
|
||||
template class List<uORB::SubscriptionPollableNode *>;
|
||||
template class List<uORB::PublicationNode *>;
|
||||
template class List<control::BlockParamBase *>;
|
||||
|
||||
@@ -40,7 +40,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <containers/List.hpp>
|
||||
#include <uORB/Publication.hpp>
|
||||
#include <uORB/SubscriptionPollable.hpp>
|
||||
#include <controllib/block/BlockParam.hpp>
|
||||
|
||||
@@ -50,7 +49,6 @@ namespace control
|
||||
static constexpr uint8_t maxChildrenPerBlock = 100;
|
||||
static constexpr uint8_t maxParamsPerBlock = 110;
|
||||
static constexpr uint8_t maxSubscriptionsPerBlock = 100;
|
||||
static constexpr uint8_t maxPublicationsPerBlock = 100;
|
||||
static constexpr uint8_t blockNameLengthMax = 40;
|
||||
|
||||
// forward declaration
|
||||
@@ -77,7 +75,6 @@ public:
|
||||
|
||||
virtual void updateParams();
|
||||
virtual void updateSubscriptions();
|
||||
virtual void updatePublications();
|
||||
|
||||
virtual void setDt(float dt) { _dt = dt; }
|
||||
float getDt() { return _dt; }
|
||||
@@ -88,7 +85,6 @@ protected:
|
||||
|
||||
SuperBlock *getParent() { return _parent; }
|
||||
List<uORB::SubscriptionPollableNode *> &getSubscriptions() { return _subscriptions; }
|
||||
List<uORB::PublicationNode *> &getPublications() { return _publications; }
|
||||
List<BlockParamBase *> &getParams() { return _params; }
|
||||
|
||||
const char *_name;
|
||||
@@ -96,7 +92,6 @@ protected:
|
||||
float _dt{0.0f};
|
||||
|
||||
List<uORB::SubscriptionPollableNode *> _subscriptions;
|
||||
List<uORB::PublicationNode *> _publications;
|
||||
List<BlockParamBase *> _params;
|
||||
};
|
||||
|
||||
@@ -130,18 +125,11 @@ public:
|
||||
|
||||
if (getChildren().getHead() != nullptr) { updateChildSubscriptions(); }
|
||||
}
|
||||
void updatePublications() override
|
||||
{
|
||||
Block::updatePublications();
|
||||
|
||||
if (getChildren().getHead() != nullptr) { updateChildPublications(); }
|
||||
}
|
||||
|
||||
protected:
|
||||
List<Block *> &getChildren() { return _children; }
|
||||
void updateChildParams();
|
||||
void updateChildSubscriptions();
|
||||
void updateChildPublications();
|
||||
|
||||
List<Block *> _children;
|
||||
};
|
||||
|
||||
@@ -68,7 +68,7 @@ private:
|
||||
|
||||
void configure_filter(float cutoff_freq) { _filter.set_cutoff_frequency(_sample_rate, cutoff_freq); }
|
||||
|
||||
uORB::Publication<sensor_accel_s> _sensor_accel_pub;
|
||||
uORB::PublicationData<sensor_accel_s> _sensor_accel_pub;
|
||||
|
||||
math::LowPassFilter2pVector3f _filter{1000, 100};
|
||||
Integrator _integrator{4000, false};
|
||||
|
||||
@@ -59,7 +59,7 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
uORB::Publication<sensor_baro_s> _sensor_baro_pub;
|
||||
uORB::PublicationData<sensor_baro_s> _sensor_baro_pub;
|
||||
|
||||
int _class_device_instance{-1};
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ private:
|
||||
|
||||
void configure_filter(float cutoff_freq) { _filter.set_cutoff_frequency(_sample_rate, cutoff_freq); }
|
||||
|
||||
uORB::Publication<sensor_gyro_s> _sensor_gyro_pub;
|
||||
uORB::PublicationData<sensor_gyro_s> _sensor_gyro_pub;
|
||||
|
||||
math::LowPassFilter2pVector3f _filter{1000, 100};
|
||||
Integrator _integrator{4000, true};
|
||||
|
||||
@@ -63,7 +63,7 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
uORB::Publication<sensor_mag_s> _sensor_mag_pub;
|
||||
uORB::PublicationData<sensor_mag_s> _sensor_mag_pub;
|
||||
|
||||
const enum Rotation _rotation;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user