mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-07-13 04:00:35 +08:00
Control lib update.
This commit is contained in:
@@ -50,37 +50,63 @@
|
||||
#include "topics/encoders.h"
|
||||
#include "topics/tecs_status.h"
|
||||
#include "topics/rc_channels.h"
|
||||
#include "topics/filtered_bottom_flow.h"
|
||||
|
||||
#include <px4_defines.h>
|
||||
|
||||
namespace uORB
|
||||
{
|
||||
|
||||
template<class T>
|
||||
Publication<T>::Publication(
|
||||
const struct orb_metadata *meta,
|
||||
List<PublicationNode *> *list) :
|
||||
T(), // initialize data structure to zero
|
||||
PublicationNode(meta, list)
|
||||
PublicationBase::PublicationBase(const struct orb_metadata *meta,
|
||||
int priority) :
|
||||
_meta(meta),
|
||||
_priority(priority),
|
||||
_instance(),
|
||||
_handle(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
template<class T>
|
||||
Publication<T>::~Publication() {}
|
||||
|
||||
template<class T>
|
||||
void *Publication<T>::getDataVoidPtr()
|
||||
void PublicationBase::update(void *data)
|
||||
{
|
||||
return (void *)(T *)(this);
|
||||
if (_handle != nullptr) {
|
||||
int ret = orb_publish(getMeta(), getHandle(), data);
|
||||
|
||||
if (ret != PX4_OK) { warnx("publish fail"); }
|
||||
|
||||
} else {
|
||||
orb_advert_t handle;
|
||||
|
||||
if (_priority > 0) {
|
||||
handle = orb_advertise_multi(
|
||||
getMeta(), data,
|
||||
&_instance, _priority);
|
||||
|
||||
} else {
|
||||
handle = orb_advertise(getMeta(), data);
|
||||
}
|
||||
|
||||
if (int64_t(handle) != PX4_ERROR) {
|
||||
setHandle(handle);
|
||||
|
||||
} else {
|
||||
warnx("advert fail");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PublicationBase::~PublicationBase()
|
||||
{
|
||||
}
|
||||
|
||||
PublicationNode::PublicationNode(const struct orb_metadata *meta,
|
||||
int priority,
|
||||
List<PublicationNode *> *list) :
|
||||
PublicationBase(meta)
|
||||
PublicationBase(meta, priority)
|
||||
{
|
||||
if (list != nullptr) { list->add(this); }
|
||||
}
|
||||
|
||||
|
||||
// explicit template instantiation
|
||||
template class __EXPORT Publication<vehicle_attitude_s>;
|
||||
template class __EXPORT Publication<vehicle_local_position_s>;
|
||||
template class __EXPORT Publication<vehicle_global_position_s>;
|
||||
@@ -94,5 +120,6 @@ template class __EXPORT Publication<actuator_direct_s>;
|
||||
template class __EXPORT Publication<encoders_s>;
|
||||
template class __EXPORT Publication<tecs_status_s>;
|
||||
template class __EXPORT Publication<rc_channels_s>;
|
||||
template class __EXPORT Publication<filtered_bottom_flow_s>;
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user