mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-21 02:13:33 +08:00
Abstractions to compile systemlib for Linux and Nuttx
Modified uint32_t casts of pointers to unsigned long for portability. It otherwise breaks on x86_64. Added _PX4_IOC to handle the conflice between _IOC on Linux and NuttX. Removed use of px4::ok() because it cannot be used in a thread based implementation. Changed to use px4::AppMgr which uses ok() on ROS. Removed up_cxxinitialize.c from Linux build. Signed-off-by: Mark Charlebois <charlebm@gmail.com>
This commit is contained in:
@@ -44,7 +44,7 @@
|
||||
using namespace px4;
|
||||
|
||||
PublisherExample::PublisherExample() :
|
||||
_n(),
|
||||
_n(mgr),
|
||||
_rc_channels_pub(_n.advertise<px4_rc_channels>()),
|
||||
_v_att_pub(_n.advertise<px4_vehicle_attitude>()),
|
||||
_parameter_update_pub(_n.advertise<px4_parameter_update>())
|
||||
@@ -55,7 +55,7 @@ int PublisherExample::main()
|
||||
{
|
||||
px4::Rate loop_rate(10);
|
||||
|
||||
while (px4::ok()) {
|
||||
while (!mgr.exitRequested()) {
|
||||
loop_rate.sleep();
|
||||
_n.spinOnce();
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
*/
|
||||
#pragma once
|
||||
#include <px4.h>
|
||||
#include <px4_app.h>
|
||||
|
||||
class PublisherExample
|
||||
{
|
||||
@@ -48,6 +49,8 @@ public:
|
||||
~PublisherExample() {};
|
||||
|
||||
int main();
|
||||
|
||||
static px4::AppMgr mgr;
|
||||
protected:
|
||||
px4::NodeHandle _n;
|
||||
px4::Publisher<px4::px4_rc_channels> *_rc_channels_pub;
|
||||
|
||||
@@ -49,7 +49,7 @@ void rc_channels_callback_function(const px4_rc_channels &msg)
|
||||
}
|
||||
|
||||
SubscriberExample::SubscriberExample() :
|
||||
_n(),
|
||||
_n(_mgr),
|
||||
_p_sub_interv("SUB_INTERV", PARAM_SUB_INTERV_DEFAULT),
|
||||
_p_test_float("SUB_TESTF", PARAM_SUB_TESTF_DEFAULT)
|
||||
{
|
||||
|
||||
@@ -51,12 +51,14 @@ public:
|
||||
~SubscriberExample() {};
|
||||
|
||||
void spin() {_n.spin();}
|
||||
|
||||
protected:
|
||||
px4::NodeHandle _n;
|
||||
px4::ParameterInt _p_sub_interv;
|
||||
px4::ParameterFloat _p_test_float;
|
||||
px4::Subscriber<px4_rc_channels> *_sub_rc_chan;
|
||||
|
||||
AppMgr _mgr;
|
||||
|
||||
void rc_channels_callback(const px4_rc_channels &msg);
|
||||
void vehicle_attitude_callback(const px4_vehicle_attitude &msg);
|
||||
|
||||
Reference in New Issue
Block a user