mirror of
https://gitee.com/xiaohuolufeihua/bizhang_-obav.git
synced 2026-05-21 01:12:11 +00:00
platforms: use define for lockstep scheduler
Instead of using the define __PX4_POSIX_SITL it makes more sense to have a define just to determine if the lockstep scheduler should be used.
This commit is contained in:
@@ -216,6 +216,13 @@ include(${PX4_CONFIG_FILE})
|
|||||||
message(STATUS "PX4 config: ${PX4_CONFIG}")
|
message(STATUS "PX4 config: ${PX4_CONFIG}")
|
||||||
message(STATUS "PX4 platform: ${PX4_PLATFORM}")
|
message(STATUS "PX4 platform: ${PX4_PLATFORM}")
|
||||||
|
|
||||||
|
if (ENABLE_LOCKSTEP_SCHEDULER)
|
||||||
|
add_definitions(-DENABLE_LOCKSTEP_SCHEDULER)
|
||||||
|
message(STATUS "PX4 lockstep: enabled")
|
||||||
|
else()
|
||||||
|
message(STATUS "PX4 lockstep: disabled")
|
||||||
|
endif()
|
||||||
|
|
||||||
# external modules
|
# external modules
|
||||||
set(EXTERNAL_MODULES_LOCATION "" CACHE STRING "External modules source location")
|
set(EXTERNAL_MODULES_LOCATION "" CACHE STRING "External modules source location")
|
||||||
|
|
||||||
|
|||||||
@@ -98,5 +98,4 @@ if(REPLAY_FILE)
|
|||||||
add_definitions(-DORB_USE_PUBLISHER_RULES)
|
add_definitions(-DORB_USE_PUBLISHER_RULES)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_definitions(-D__PX4_POSIX_SITL)
|
set(ENABLE_LOCKSTEP_SCHEDULER yes)
|
||||||
set(LOCKSTEP_SCHEDULER_NEEDED yes)
|
|
||||||
|
|||||||
@@ -96,3 +96,5 @@ if(REPLAY_FILE)
|
|||||||
message("Building with uorb publisher rules support")
|
message("Building with uorb publisher rules support")
|
||||||
add_definitions(-DORB_USE_PUBLISHER_RULES)
|
add_definitions(-DORB_USE_PUBLISHER_RULES)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
set(ENABLE_LOCKSTEP_SCHEDULER no)
|
||||||
|
|||||||
@@ -31,7 +31,7 @@
|
|||||||
#
|
#
|
||||||
############################################################################
|
############################################################################
|
||||||
|
|
||||||
if (LOCKSTEP_SCHEDULER_NEEDED)
|
if (ENABLE_LOCKSTEP_SCHEDULER)
|
||||||
add_subdirectory(lockstep_scheduler)
|
add_subdirectory(lockstep_scheduler)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ target_compile_definitions(px4_layer PRIVATE MODULE_NAME="px4")
|
|||||||
target_link_libraries(px4_layer PRIVATE work_queue)
|
target_link_libraries(px4_layer PRIVATE work_queue)
|
||||||
target_link_libraries(px4_layer PRIVATE px4_daemon)
|
target_link_libraries(px4_layer PRIVATE px4_daemon)
|
||||||
|
|
||||||
if(LOCKSTEP_SCHEDULER_NEEDED)
|
if(ENABLE_LOCKSTEP_SCHEDULER)
|
||||||
target_link_libraries(px4_layer PRIVATE lockstep_scheduler)
|
target_link_libraries(px4_layer PRIVATE lockstep_scheduler)
|
||||||
include_directories(${PX4_SOURCE_DIR}/platforms/posix/src/lockstep_scheduler/include)
|
include_directories(${PX4_SOURCE_DIR}/platforms/posix/src/lockstep_scheduler/include)
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
@@ -49,7 +49,7 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include "hrt_work.h"
|
#include "hrt_work.h"
|
||||||
|
|
||||||
#if defined(__PX4_POSIX_SITL)
|
#if defined(ENABLE_LOCKSTEP_SCHEDULER)
|
||||||
#include <lockstep_scheduler/lockstep_scheduler.h>
|
#include <lockstep_scheduler/lockstep_scheduler.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -72,7 +72,7 @@ static hrt_abstime _delay_interval = 0;
|
|||||||
static hrt_abstime max_time = 0;
|
static hrt_abstime max_time = 0;
|
||||||
static pthread_mutex_t _hrt_mutex = PTHREAD_MUTEX_INITIALIZER;
|
static pthread_mutex_t _hrt_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||||
|
|
||||||
#if defined(__PX4_POSIX_SITL)
|
#if defined(ENABLE_LOCKSTEP_SCHEDULER)
|
||||||
static LockstepScheduler lockstep_scheduler;
|
static LockstepScheduler lockstep_scheduler;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -594,7 +594,7 @@ void abstime_to_ts(struct timespec *ts, hrt_abstime abstime)
|
|||||||
ts->tv_nsec = abstime * 1000;
|
ts->tv_nsec = abstime * 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(__PX4_POSIX_SITL)
|
#if defined(ENABLE_LOCKSTEP_SCHEDULER)
|
||||||
int px4_clock_gettime(clockid_t clk_id, struct timespec *tp)
|
int px4_clock_gettime(clockid_t clk_id, struct timespec *tp)
|
||||||
{
|
{
|
||||||
if (clk_id == CLOCK_MONOTONIC) {
|
if (clk_id == CLOCK_MONOTONIC) {
|
||||||
|
|||||||
@@ -65,7 +65,7 @@
|
|||||||
*/
|
*/
|
||||||
#define system_exit exit
|
#define system_exit exit
|
||||||
|
|
||||||
#if defined(__PX4_POSIX_SITL)
|
#if defined(ENABLE_LOCKSTEP_SCHEDULER)
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
@@ -99,7 +99,7 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
#else // defined(__PX4_POSIX_SITL)
|
#else // defined(ENABLE_LOCKSTEP_SCHEDULER)
|
||||||
|
|
||||||
#define system_usleep usleep
|
#define system_usleep usleep
|
||||||
#define system_sleep sleep
|
#define system_sleep sleep
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
#define clockid_t int
|
#define clockid_t int
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__PX4_POSIX_SITL) || defined(__PX4_QURT)
|
#if defined(ENABLE_LOCKSTEP_SCHEDULER) || defined(__PX4_QURT)
|
||||||
|
|
||||||
__BEGIN_DECLS
|
__BEGIN_DECLS
|
||||||
__EXPORT int px4_clock_gettime(clockid_t clk_id, struct timespec *tp);
|
__EXPORT int px4_clock_gettime(clockid_t clk_id, struct timespec *tp);
|
||||||
|
|||||||
Reference in New Issue
Block a user