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:
Daniel Agar
2022-01-21 09:32:30 -05:00
parent 7cb8ed3a1f
commit 56de0e27d8
395 changed files with 5601 additions and 1517 deletions
+33 -27
View File
@@ -31,33 +31,39 @@
#
############################################################################
set(SRCS)
if(NOT "${PX4_BOARD_LABEL}" MATCHES "bootloader")
if(NOT "${PX4_BOARD}" MATCHES "io-v2" AND NOT "${PX4_BOARD_LABEL}" MATCHES "bootloader")
list(APPEND SRCS
px4_log.cpp
set(SRCS)
if(NOT "${PX4_BOARD}" MATCHES "io-v2")
list(APPEND SRCS
events.cpp
px4_log.cpp
)
endif()
add_library(px4_platform STATIC
board_identity.c
external_reset_lockout.cpp
i2c.cpp
i2c_spi_buses.cpp
module.cpp
px4_getopt.c
px4_cli.cpp
shutdown.cpp
spi.cpp
${SRCS}
)
add_dependencies(px4_platform prebuild_targets)
if(NOT "${PX4_BOARD}" MATCHES "io-v2")
add_subdirectory(uORB)
target_link_libraries(px4_platform PRIVATE uORB)
endif()
add_subdirectory(px4_work_queue)
add_subdirectory(work_queue)
else()
add_library(px4_platform STATIC ${PX4_SOURCE_DIR}/platforms/common/empty.c) # TODO
add_dependencies(px4_platform prebuild_targets)
endif()
add_library(px4_platform
board_identity.c
events.cpp
external_reset_lockout.cpp
i2c.cpp
i2c_spi_buses.cpp
module.cpp
px4_getopt.c
px4_cli.cpp
shutdown.cpp
spi.cpp
${SRCS}
)
add_dependencies(px4_platform prebuild_targets)
if (NOT "${PX4_BOARD}" MATCHES "io-v2")
add_subdirectory(uORB)
target_link_libraries(px4_platform PRIVATE uORB)
endif()
add_subdirectory(px4_work_queue)
add_subdirectory(work_queue)
@@ -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
+1 -1
View File
@@ -43,7 +43,7 @@
#include <uORB/uORB.h>
#include "uORBManager.hpp"
#include <uORB/topics/uORBTopics.hpp>
#include <uORBTopics.hpp>
namespace uORB
{
+5 -1
View File
@@ -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>
@@ -160,6 +160,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.
+8 -2
View File
@@ -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_ */
+1 -1
View File
@@ -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,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"
)
+2 -2
View File
@@ -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
+1 -25
View File
@@ -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
+2 -2
View File
@@ -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);
+1
View File
@@ -35,6 +35,7 @@
#include <stdio.h>
#include "work_lock.h"
#include <px4_platform_common/sem.h>
extern px4_sem_t _work_lock[];