mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-11-11 19:11:36 +08:00
PX4 ROS2 msg conformity and explicit topics
- .msg files are PascalCase - topics are still either per msg or explicitly listed in TOPICS - compatible structs are still generated (eg struct msg_s), but ROS2 style px4::msg::Msg is also available
This commit is contained in:
@@ -35,13 +35,13 @@ set(SRCS)
|
||||
|
||||
if(NOT "${PX4_BOARD}" MATCHES "io-v2" AND NOT "${PX4_BOARD_LABEL}" MATCHES "bootloader")
|
||||
list(APPEND SRCS
|
||||
events.cpp
|
||||
px4_log.cpp
|
||||
)
|
||||
endif()
|
||||
|
||||
add_library(px4_platform
|
||||
add_library(px4_platform STATIC
|
||||
board_identity.c
|
||||
events.cpp
|
||||
external_reset_lockout.cpp
|
||||
i2c.cpp
|
||||
i2c_spi_buses.cpp
|
||||
@@ -54,7 +54,7 @@ add_library(px4_platform
|
||||
)
|
||||
target_link_libraries(px4_platform prebuild_targets px4_work_queue)
|
||||
|
||||
if (NOT "${PX4_BOARD}" MATCHES "io-v2")
|
||||
if(NOT "${PX4_BOARD}" MATCHES "io-v2")
|
||||
add_subdirectory(uORB)
|
||||
endif()
|
||||
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace px4
|
||||
{
|
||||
|
||||
class Node
|
||||
{
|
||||
public:
|
||||
explicit Node(const char *node_name) :
|
||||
_name(node_name)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
~Node() override = default;
|
||||
|
||||
|
||||
const char *get_name() const { return _name; }
|
||||
|
||||
// bool get_parameter()
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
const char *_name{nullptr};
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
// int main(int argc, char *argv[])
|
||||
// {
|
||||
// rclcpp::init(argc, argv);
|
||||
// rclcpp::spin(std::make_shared<MulticopterRateControl>());
|
||||
// rclcpp::shutdown();
|
||||
// return 0;
|
||||
// }
|
||||
|
||||
|
||||
// #include "rclcpp_components/register_node_macro.hpp"
|
||||
|
||||
// // Register the component with class_loader.
|
||||
// // This acts as a sort of entry point, allowing the component to be discoverable when its library
|
||||
// // is being loaded into a running process.
|
||||
// RCLCPP_COMPONENTS_REGISTER_NODE(composition::Client)
|
||||
@@ -43,7 +43,6 @@
|
||||
|
||||
#include <stdint.h>
|
||||
#include <queue.h>
|
||||
#include <px4_platform_types.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
|
||||
@@ -34,8 +34,6 @@
|
||||
# this includes the generated topics directory
|
||||
include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
set(SRCS)
|
||||
|
||||
set(SRCS_COMMON
|
||||
ORBSet.hpp
|
||||
Publication.hpp
|
||||
@@ -49,22 +47,22 @@ set(SRCS_COMMON
|
||||
uORB.h
|
||||
uORBCommon.hpp
|
||||
uORBCommunicator.hpp
|
||||
uORBManager.hpp
|
||||
uORBUtils.cpp
|
||||
uORBUtils.hpp
|
||||
uORBDeviceMaster.hpp
|
||||
uORBDeviceNode.hpp
|
||||
)
|
||||
)
|
||||
|
||||
set(SRCS_KERNEL
|
||||
uORBDeviceMaster.cpp
|
||||
uORBDeviceMaster.hpp
|
||||
uORBDeviceNode.cpp
|
||||
uORBDeviceNode.hpp
|
||||
uORBManager.cpp
|
||||
)
|
||||
uORBManager.hpp
|
||||
)
|
||||
|
||||
set(SRCS_USER
|
||||
uORBManagerUsr.cpp
|
||||
)
|
||||
)
|
||||
|
||||
if (NOT DEFINED CONFIG_BUILD_FLAT AND "${PX4_PLATFORM}" MATCHES "nuttx")
|
||||
# Kernel side library in nuttx kernel/protected build
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
|
||||
#include <uORB/uORB.h>
|
||||
#include "uORBManager.hpp"
|
||||
#include <uORB/topics/uORBTopics.hpp>
|
||||
#include <uORBTopics.hpp>
|
||||
|
||||
namespace uORB
|
||||
{
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <uORB/uORB.h>
|
||||
#include <uORB/topics/uORBTopics.hpp>
|
||||
#include <uORBTopics.hpp>
|
||||
|
||||
#include <px4_platform_common/defines.h>
|
||||
#include <lib/mathlib/mathlib.h>
|
||||
@@ -181,6 +181,10 @@ public:
|
||||
unsigned get_last_generation() const { return _last_generation; }
|
||||
orb_id_t get_topic() const { return get_orb_meta(_orb_id); }
|
||||
|
||||
ORB_ID get_topic_enum() const { return _orb_id; }
|
||||
|
||||
size_t get_topic_size() const { return get_orb_meta(_orb_id)->o_size; }
|
||||
|
||||
protected:
|
||||
|
||||
friend class SubscriptionCallback;
|
||||
|
||||
@@ -140,6 +140,9 @@ public:
|
||||
unsigned get_last_generation() const { return _subscription.get_last_generation(); }
|
||||
orb_id_t get_topic() const { return _subscription.get_topic(); }
|
||||
|
||||
ORB_ID get_topic_enum() const { return _subscription.get_topic_enum(); }
|
||||
size_t get_topic_size() const { return _subscription.get_topic_size(); }
|
||||
|
||||
/**
|
||||
* Set the interval in microseconds
|
||||
* @param interval The interval in microseconds.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copyright (c) 2012-2015 PX4 Development Team. All rights reserved.
|
||||
* Copyright (c) 2012-2021 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
|
||||
@@ -251,10 +251,16 @@ void orb_print_message_internal(const struct orb_metadata *meta, const void *dat
|
||||
__END_DECLS
|
||||
|
||||
/* Diverse uORB header defines */ //XXX: move to better location
|
||||
#define ORB_ID_VEHICLE_ATTITUDE_CONTROLS ORB_ID(actuator_controls_0)
|
||||
typedef uint8_t arming_state_t;
|
||||
typedef uint8_t main_state_t;
|
||||
typedef uint8_t hil_state_t;
|
||||
typedef uint8_t navigation_state_t;
|
||||
typedef uint8_t switch_pos_t;
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
#include <uORBTopics.hpp>
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
@@ -100,8 +100,6 @@ public:
|
||||
|
||||
virtual int16_t add_subscription(const char *messageName, int32_t msgRateInHz) = 0;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Interface to notify the remote entity of removal of a subscription
|
||||
*
|
||||
@@ -116,13 +114,11 @@ public:
|
||||
|
||||
virtual int16_t remove_subscription(const char *messageName) = 0;
|
||||
|
||||
|
||||
/**
|
||||
* Register Message Handler. This is internal for the IChannel implementer*
|
||||
*/
|
||||
virtual int16_t register_handler(uORBCommunicator::IChannelRxHandler *handler) = 0;
|
||||
|
||||
|
||||
//=========================================================================
|
||||
// INTERFACES FOR Data messages
|
||||
//=========================================================================
|
||||
@@ -143,7 +139,6 @@ public:
|
||||
*/
|
||||
|
||||
virtual int16_t send_message(const char *messageName, int32_t length, uint8_t *data) = 0;
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -153,7 +148,6 @@ public:
|
||||
class uORBCommunicator::IChannelRxHandler
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Interface to process a received topic from remote.
|
||||
* @param topic_name
|
||||
@@ -184,7 +178,6 @@ public:
|
||||
|
||||
virtual int16_t process_add_subscription(const char *messageName, int32_t msgRateInHz) = 0;
|
||||
|
||||
|
||||
/**
|
||||
* Interface to process a received control msg to remove subscription
|
||||
* @param messageName
|
||||
@@ -198,7 +191,6 @@ public:
|
||||
|
||||
virtual int16_t process_remove_subscription(const char *messageName) = 0;
|
||||
|
||||
|
||||
/**
|
||||
* Interface to process the received data message.
|
||||
* @param messageName
|
||||
@@ -215,7 +207,6 @@ public:
|
||||
*/
|
||||
|
||||
virtual int16_t process_received_message(const char *messageName, int32_t length, uint8_t *data) = 0;
|
||||
|
||||
};
|
||||
|
||||
#endif /* _uORBCommunicator_hpp_ */
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#include "uORBCommon.hpp"
|
||||
#include <uORB/topics/uORBTopics.hpp>
|
||||
#include <uORBTopics.hpp>
|
||||
|
||||
#include <px4_platform_common/posix.h>
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
#include "uORBCommon.hpp"
|
||||
#include "uORBDeviceMaster.hpp"
|
||||
|
||||
#include <uORB/topics/uORBTopics.hpp> // For ORB_ID enum
|
||||
#include <uORBTopics.hpp> // For ORB_ID enum
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __PX4_NUTTX
|
||||
|
||||
@@ -38,4 +38,13 @@ px4_add_module(
|
||||
SRCS
|
||||
uORB_tests_main.cpp
|
||||
uORBTest_UnitTest.cpp
|
||||
PUBLICATIONS
|
||||
"px4::msg::OrbTest /orb_test"
|
||||
"px4::msg::OrbTest /orb_multitest"
|
||||
"px4::msg::OrbTestMedium /orb_test_medium"
|
||||
"px4::msg::OrbTestMedium /orb_test_medium_multi"
|
||||
"px4::msg::OrbTestMedium /orb_test_medium_queue"
|
||||
"px4::msg::OrbTestMedium /orb_test_medium_queue_poll"
|
||||
"px4::msg::OrbTestMedium /orb_test_medium_wrap_around"
|
||||
"px4::msg::OrbTestLarge /orb_test_large"
|
||||
)
|
||||
|
||||
@@ -32,9 +32,9 @@
|
||||
############################################################################
|
||||
|
||||
# nuttx uses internal work queue currently
|
||||
if (NOT "${PX4_PLATFORM}" MATCHES "nuttx")
|
||||
if(NOT "${PX4_PLATFORM}" MATCHES "nuttx")
|
||||
|
||||
add_library(work_queue
|
||||
add_library(work_queue STATIC
|
||||
dq_addlast.c
|
||||
dq_rem.c
|
||||
dq_remfirst.c
|
||||
|
||||
@@ -52,30 +52,6 @@
|
||||
#include <px4_platform_common/posix.h>
|
||||
#include "hrt_work.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Type Declarations
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Variables
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Variables
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: hrt_work_queue
|
||||
*
|
||||
@@ -125,7 +101,7 @@ int hrt_work_queue(struct work_s *work, worker_t worker, void *arg, uint32_t del
|
||||
|
||||
dq_addlast((dq_entry_t *)work, &wqueue->q);
|
||||
|
||||
if (px4_getpid() != wqueue->pid) { /* only need to wake up if called from a different thread */
|
||||
if (getpid() != wqueue->pid) { /* only need to wake up if called from a different thread */
|
||||
#ifdef __PX4_QURT
|
||||
px4_task_kill(wqueue->pid, SIGALRM); /* Wake up the worker thread */
|
||||
#else
|
||||
|
||||
@@ -96,7 +96,7 @@ static void _sighandler(int sig_num);
|
||||
****************************************************************************/
|
||||
static void _sighandler(int sig_num)
|
||||
{
|
||||
PX4_DEBUG("RECEIVED SIGNAL %d", sig_num);
|
||||
//PX4_DEBUG("RECEIVED SIGNAL %d", sig_num);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -176,7 +176,7 @@ static void hrt_work_process()
|
||||
hrt_work_unlock();
|
||||
|
||||
if (!worker) {
|
||||
PX4_ERR("MESSED UP: worker = 0");
|
||||
//PX4_ERR("MESSED UP: worker = 0");
|
||||
|
||||
} else {
|
||||
worker(arg);
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
#include <stdio.h>
|
||||
#include "work_lock.h"
|
||||
|
||||
#include <px4_platform_common/sem.h>
|
||||
|
||||
extern px4_sem_t _work_lock[];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user