From 102f5b54d7edb11b7913514e1edd081eb4a0d642 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Fri, 5 Aug 2016 21:29:49 +0200 Subject: [PATCH] Revert "Improvements to SITL to make paths more flexible. (#5181)" This reverts commit 699b6a2cb340f4b6ec3979ae7748ff9c56cfdb89. --- CMakeLists.txt | 65 ++-- Makefile | 33 +- Tools/sitl_gazebo | 2 +- Tools/sitl_run.sh | 83 ++--- cmake/common/px4_base.cmake | 90 ++--- cmake/configs/nuttx_mindpx-v2_default.cmake | 2 +- .../nuttx_px4-stm32f4discovery_default.cmake | 2 +- cmake/configs/nuttx_px4fmu-v1_default.cmake | 2 +- cmake/configs/nuttx_px4fmu-v2_default.cmake | 2 +- cmake/configs/nuttx_px4fmu-v2_ekf2.cmake | 2 +- cmake/configs/nuttx_px4fmu-v2_test.cmake | 2 +- cmake/configs/nuttx_px4fmu-v4_default.cmake | 2 +- cmake/configs/nuttx_tap-v1_default.cmake | 2 +- cmake/configs/posix_bebop_default.cmake | 2 +- cmake/configs/posix_eagle_default.cmake | 4 +- cmake/configs/posix_eagle_hil.cmake | 4 +- .../posix_eagle_legacy_driver_default.cmake | 4 +- cmake/configs/posix_eagle_muorb.cmake | 4 +- cmake/configs/posix_rpi_cross.cmake | 2 +- cmake/configs/posix_rpi_native.cmake | 2 +- cmake/configs/posix_sdflight_default.cmake | 4 +- cmake/configs/posix_sitl_broadcast.cmake | 2 +- cmake/configs/posix_sitl_default.cmake | 2 +- cmake/configs/posix_sitl_replay.cmake | 2 +- cmake/configs/qurt_eagle_hello.cmake | 4 +- cmake/configs/qurt_eagle_hil.cmake | 4 +- .../qurt_eagle_legacy_driver_default.cmake | 4 +- cmake/configs/qurt_eagle_muorb.cmake | 4 +- cmake/configs/qurt_eagle_test.cmake | 4 +- cmake/configs/qurt_eagle_travis.cmake | 4 +- cmake/configs/qurt_sdflight_default.cmake | 4 +- cmake/nuttx/px4_impl_nuttx.cmake | 52 +-- cmake/posix/px4_impl_posix.cmake | 4 +- cmake/qurt/px4_impl_qurt.cmake | 4 +- cmake/ros-CMakeLists.txt | 334 ++++++++++++++++++ integrationtests/run_tests.bash | 93 ++--- integrationtests/setup_gazebo_ros.bash | 19 +- launch/mavros_posix_sitl.launch | 13 +- launch/mavros_posix_tests_iris.launch | 1 - .../mavros_posix_tests_standard_vtol.launch | 2 +- launch/posix_sitl.launch | 20 +- posix-configs/SITL/README.md | 2 +- posix-configs/SITL/init/rcS_gazebo_iris | 2 +- .../SITL/init/rcS_gazebo_iris_opt_flow | 2 +- posix-configs/SITL/init/rcS_gazebo_plane | 2 +- posix-configs/SITL/init/rcS_gazebo_solo | 2 +- .../SITL/init/rcS_gazebo_standard_vtol | 2 +- posix-configs/SITL/init/rcS_gazebo_tailsitter | 2 +- .../SITL/init/rcS_gazebo_typhoon_h480 | 2 +- posix-configs/SITL/init/rcS_jmavsim_iris | 2 +- posix-configs/SITL/init/rcS_lpe_gazebo_iris | 2 +- .../SITL/init/rcS_lpe_gazebo_iris_opt_flow | 2 +- posix-configs/SITL/init/rcS_lpe_jmavsim_iris | 2 +- .../init/{rcS_tests_none_iris => rcS_tests} | 0 posix-configs/SITL/init/rc_iris_ros | 2 +- src/firmware/nuttx/CMakeLists.txt | 18 +- src/firmware/nuttx/gdbinit.in | 2 +- src/firmware/posix/CMakeLists.txt | 88 +---- src/firmware/qurt/CMakeLists.txt | 12 +- src/lib/rc/rc_tests/CMakeLists.txt | 1 - src/lib/rc/rc_tests/RCTest.cpp | 4 +- src/modules/muorb/krait/CMakeLists.txt | 4 +- src/modules/param/CMakeLists.txt | 4 +- src/modules/px4iofirmware/CMakeLists.txt | 6 +- src/modules/systemlib/CMakeLists.txt | 2 +- src/modules/uavcan/uavcan_servers.hpp | 2 +- src/platforms/posix/main.cpp | 227 ++---------- src/platforms/posix/px4_layer/CMakeLists.txt | 4 +- src/platforms/qurt/px4_layer/CMakeLists.txt | 2 +- src/systemcmds/tests/test_mixer.cpp | 4 +- src/systemcmds/topic_listener/CMakeLists.txt | 4 +- unittests/CMakeLists.txt | 14 +- 72 files changed, 672 insertions(+), 643 deletions(-) create mode 100644 cmake/ros-CMakeLists.txt rename posix-configs/SITL/init/{rcS_tests_none_iris => rcS_tests} (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 498b6ba7d8..9397b87c99 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -121,14 +121,6 @@ # and leads to wrong toolchain detection cmake_minimum_required(VERSION 2.8 FATAL_ERROR) -set(PX4_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}") -set(PX4_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}") - -execute_process( - COMMAND Tools/check_submodules.sh - WORKING_DIRECTORY ${PX4_SOURCE_DIR} - ) - # Use clang #SET (CMAKE_C_COMPILER /usr/bin/clang-3.6) #SET (CMAKE_CXX_COMPILER /usr/bin/clang++-3.6) @@ -163,9 +155,6 @@ message(STATUS "${target_name}") # Define GNU standard installation directories include(GNUInstallDirs) -# Add support for external project building -include(ExternalProject) - # Setup install paths if(NOT CMAKE_INSTALL_PREFIX) if (${OS} STREQUAL "posix") @@ -174,8 +163,12 @@ if(NOT CMAKE_INSTALL_PREFIX) endif() message(STATUS "CMAKE_INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX}") -list(APPEND CMAKE_MODULE_PATH "${PX4_SOURCE_DIR}/cmake") -message(STATUS "cmake module path: ${CMAKE_MODULE_PATH}") +# switch to ros CMake file if building ros +if (${OS} STREQUAL "ros") + include("cmake/ros-CMakeLists.txt") +else() # otherwise use the rest of this file + +list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake) set(config_module "configs/${CONFIG}") include(${config_module}) @@ -206,9 +199,6 @@ if(DEFINED config_df_driver_list) message("DF Drivers: ${config_df_driver_list}") endif() -# force static lib build -set(BUILD_SHARED_LIBS OFF) - #============================================================================= # project definition # @@ -229,22 +219,8 @@ set(version "${version_major}.${version_minor}.${version_patch}") set(package-contact "px4users@googlegroups.com") #============================================================================= -# find programs and packages +# programs # - -# see if catkin was invoked to build this -if (CATKIN_DEVEL_PREFIX) - message(STATUS "catkin ENABLED") - find_package(catkin REQUIRED) - if (catkin_FOUND) - catkin_package() - else() - message(FATAL_ERROR "catkin not found") - endif() -else() - message(STATUS "catkin DISABLED") -endif() - find_package(PythonInterp REQUIRED) #============================================================================= @@ -281,7 +257,7 @@ px4_add_git_submodule(TARGET git_matrix PATH "src/lib/matrix") px4_add_git_submodule(TARGET git_cmake_hexagon PATH "cmake/cmake_hexagon") add_custom_target(submodule_clean - WORKING_DIRECTORY ${PX4_SOURCE_DIR} + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} COMMAND git submodule deinit -f . COMMAND rm -rf .git/modules/* ) @@ -291,12 +267,12 @@ add_custom_target(submodule_clean # add_custom_target(check_format COMMAND Tools/check_code_style.sh - WORKING_DIRECTORY ${PX4_SOURCE_DIR} + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} ) add_custom_target(config COMMAND cmake-gui . - WORKING_DIRECTORY ${PX4_BINARY_DIR} + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} ) #============================================================================= @@ -345,7 +321,7 @@ add_custom_target(xml_gen # external projects # -set(ep_base ${PX4_BINARY_DIR}/external) +set(ep_base ${CMAKE_BINARY_DIR}/external) set_property(DIRECTORY PROPERTY EP_BASE ${ep_base}) # add external project install folders to build @@ -374,7 +350,7 @@ foreach(module ${config_module_list}) if(external_module) STRING(REGEX REPLACE "//" "/" EXT_MODULE ${module}) STRING(REGEX REPLACE "/" "__" EXT_MODULE_PREFIX ${EXT_MODULE}) - add_subdirectory(${module} ${PX4_BINARY_DIR}/${EXT_MODULE_PREFIX}) + add_subdirectory(${module} ${CMAKE_BINARY_DIR}/${EXT_MODULE_PREFIX}) else() add_subdirectory(src/${module}) endif() @@ -399,7 +375,7 @@ endif() #============================================================================= # generate git version # -px4_create_git_hash_header(HEADER ${PX4_BINARY_DIR}/build_git_version.h) +px4_create_git_hash_header(HEADER ${CMAKE_BINARY_DIR}/build_git_version.h) #============================================================================= # packaging @@ -418,14 +394,17 @@ set(CPACK_GENERATOR "ZIP") set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${CONFIG}-${version}") set(CPACK_SOURCE_PACKAGE_FILE_NAME "${PROJECT_NAME}-${version}") set(CPACK_SOURCE_GENERATOR "ZIP;TBZ2") -set(CPACK_PACKAGING_INSTALL_PREFIX "/usr") -set(CPACK_SET_DESTDIR "OFF") if ("${CMAKE_SYSTEM}" MATCHES "Linux") - find_program(DPKG_PROGRAM dpkg) - if (EXISTS ${DPKG_PROGRAM}) - list (APPEND CPACK_GENERATOR "DEB") - endif() + find_program(DPKG_PROGRAM dpkg) + if (EXISTS ${DPKG_PROGRAM}) + list (APPEND CPACK_GENERATOR "DEB") + endif() +endif() +if (${OS} STREQUAL "posix") + set(CPACK_SET_DESTDIR "ON") endif() include(CPack) +endif() # ros alternative endif + # vim: set noet fenc=utf-8 ff=unix ft=cmake : diff --git a/Makefile b/Makefile index b4a02f8d8c..f80a24399c 100644 --- a/Makefile +++ b/Makefile @@ -111,23 +111,20 @@ else BUILD_DIR_SUFFIX := endif -SRC_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))) - # Functions # -------------------------------------------------------------------- # describe how to build a cmake config define cmake-build -+@$(eval BUILD_DIR = $(SRC_DIR)/build_$@$(BUILD_DIR_SUFFIX)) -+@if [ $(PX4_CMAKE_GENERATOR) = "Ninja" ] && [ -e $(BUILD_DIR)/Makefile ]; then rm -rf $(BUILD_DIR); fi -+@if [ ! -e $(BUILD_DIR)/CMakeCache.txt ]; then mkdir -p $(BUILD_DIR) && cd $(BUILD_DIR) && cmake .. -G$(PX4_CMAKE_GENERATOR) -DCONFIG=$(1) || (cd .. && rm -rf $(BUILD_DIR)); fi -+@(echo "PX4 CONFIG: $(BUILD_DIR)" && cd $(BUILD_DIR) && $(PX4_MAKE) $(PX4_MAKE_ARGS) $(ARGS)) ++@if [ $(PX4_CMAKE_GENERATOR) = "Ninja" ] && [ -e ./build_$@$(BUILD_DIR_SUFFIX)/Makefile ]; then rm -rf ./build_$@$(BUILD_DIR_SUFFIX); fi ++@if [ ! -e ./build_$@$(BUILD_DIR_SUFFIX)/CMakeCache.txt ]; then Tools/check_submodules.sh && mkdir -p ./build_$@$(BUILD_DIR_SUFFIX) && cd ./build_$@$(BUILD_DIR_SUFFIX) && cmake .. -G$(PX4_CMAKE_GENERATOR) -DCONFIG=$(1) || (cd .. && rm -rf ./build_$@$(BUILD_DIR_SUFFIX)); fi ++@Tools/check_submodules.sh ++@(echo "PX4 CONFIG: $@$(BUILD_DIR_SUFFIX)" && cd ./build_$@$(BUILD_DIR_SUFFIX) && $(PX4_MAKE) $(PX4_MAKE_ARGS) $(ARGS)) endef define cmake-build-other -+@$(eval BUILD_DIR = $(SRC_DIR)/build_$@$(BUILD_DIR_SUFFIX)) -+@if [ $(PX4_CMAKE_GENERATOR) = "Ninja" ] && [ -e $(BUILD_DIR)/Makefile ]; then rm -rf $(BUILD_DIR); fi -+@if [ ! -e $(BUILD_DIR)/CMakeCache.txt ]; then mkdir -p $(BUILD_DIR) && cd $(BUILD_DIR) && cmake $(2) -G$(PX4_CMAKE_GENERATOR) -DCONFIG=$(1) || (cd .. && rm -rf $(BUILD_DIR)); fi -+@(cd $(BUILD_DIR) && $(PX4_MAKE) $(PX4_MAKE_ARGS) $(ARGS)) ++@if [ $(PX4_CMAKE_GENERATOR) = "Ninja" ] && [ -e ./build_$@/Makefile ]; then rm -rf ./build_$@; fi ++@if [ ! -e ./build_$@/CMakeCache.txt ]; then Tools/check_submodules.sh && mkdir -p ./build_$@ && cd ./build_$@ && cmake $(2) -G$(PX4_CMAKE_GENERATOR) || (cd .. && rm -rf ./build_$@); fi ++@(cd ./build_$@ && $(PX4_MAKE) $(PX4_MAKE_ARGS) $(ARGS)) endef # create empty targets to avoid msgs for targets passed to cmake @@ -236,8 +233,14 @@ run_sitl_ros: sitl_deprecation # Other targets # -------------------------------------------------------------------- -.PHONY: uavcan_firmware check check_format unittest tests qgc_firmware package_firmware clean submodulesclean distclean -.NOTPARALLEL: uavcan_firmware check check_format unittest tests qgc_firmware package_firmware clean submodulesclean distclean +.PHONY: gazebo_build uavcan_firmware check check_format unittest tests qgc_firmware package_firmware clean submodulesclean distclean +.NOTPARALLEL: gazebo_build uavcan_firmware check check_format unittest tests qgc_firmware package_firmware clean submodulesclean distclean + +gazebo_build: + @mkdir -p build_gazebo + @if [ ! -e ./build_gazebo/CMakeCache.txt ];then cd build_gazebo && cmake -Wno-dev -G$(PX4_CMAKE_GENERATOR) ../Tools/sitl_gazebo; fi + @cd build_gazebo && $(PX4_MAKE) $(PX4_MAKE_ARGS) + @cd build_gazebo && $(PX4_MAKE) $(PX4_MAKE_ARGS) sdf uavcan_firmware: ifeq ($(VECTORCONTROL),1) @@ -299,7 +302,11 @@ unittest: posix_sitl_default @(cd build_unittest && ctest -j2 --output-on-failure) run_tests_posix: posix_sitl_default - @(cd build_posix_sitl_default/ && ctest -V) + @mkdir -p build_posix_sitl_default/src/firmware/posix/rootfs/fs/microsd + @mkdir -p build_posix_sitl_default/src/firmware/posix/rootfs/eeprom + @touch build_posix_sitl_default/src/firmware/posix/rootfs/eeprom/parameters + @(cd build_posix_sitl_default/src/firmware/posix && ./px4 -d ../../../../posix-configs/SITL/init/rcS_tests | tee test_output) + @(cd build_posix_sitl_default/src/firmware/posix && grep --color=always "All tests passed" test_output) tests: check_unittest run_tests_posix diff --git a/Tools/sitl_gazebo b/Tools/sitl_gazebo index 9486c331a7..00dcabb1c2 160000 --- a/Tools/sitl_gazebo +++ b/Tools/sitl_gazebo @@ -1 +1 @@ -Subproject commit 9486c331a758fcadfaa314f6e9e44c36af5f243b +Subproject commit 00dcabb1c2c001b40713903da1a4a7f71d01ef27 diff --git a/Tools/sitl_run.sh b/Tools/sitl_run.sh index 8dfa2a62c6..6e467c31fd 100755 --- a/Tools/sitl_run.sh +++ b/Tools/sitl_run.sh @@ -1,29 +1,22 @@ #!/bin/bash -set -e - -echo args: $@ - -sitl_bin=$1 -rc_script=$2 -debugger=$3 -program=$4 -model=$5 -src_path=$6 -build_path=$7 +rc_script=$1 +debugger=$2 +program=$3 +model=$4 +build_path=$5 +curr_dir=`pwd` echo SITL ARGS - -echo sitl_bin: $sitl_bin echo rc_script: $rc_script echo debugger: $debugger echo program: $program echo model: $model -echo src_path: $src_path echo build_path: $build_path -working_dir=`pwd` -sitl_bin=$build_path/src/firmware/posix/px4 +mkdir -p $build_path/src/firmware/posix/rootfs/fs/microsd +mkdir -p $build_path/src/firmware/posix/rootfs/eeprom +touch $build_path/src/firmware/posix/rootfs/eeprom/parameters if [ "$chroot" == "1" ] then @@ -42,36 +35,32 @@ fi if [ "$#" -lt 5 ] then - echo usage: sitl_run.sh rc_script debugger program model devel_path + echo usage: sitl_run.sh rc_script debugger program model build_path echo "" exit 1 fi -command_exists () { - type "$1" &> /dev/null ; -} - # kill process names that might stil # be running from last time -pgrep gazebo && pkill gazebo -pgrep px4 && pkill px4 -if command_exists jps +pkill gazebo +pkill px4 +jmavsim_pid=`jps | grep Simulator | cut -d" " -f1` +if [ -n "$jmavsim_pid" ] then - jmavsim_pid=`jps | grep Simulator | cut -d" " -f1` - if [ -n "$jmavsim_pid" ] - then - kill $jmavsim_pid - fi + kill $jmavsim_pid fi -cp $src_path/Tools/posix_lldbinit $working_dir/.lldbinit -cp $src_path/Tools/posix.gdbinit $working_dir/.gdbinit +set -e + +cd $build_path/.. +cp Tools/posix_lldbinit $build_path/src/firmware/posix/.lldbinit +cp Tools/posix.gdbinit $build_path/src/firmware/posix/.gdbinit SIM_PID=0 if [ "$program" == "jmavsim" ] && [ ! -n "$no_sim" ] then - cd $src_path/Tools/jMAVSim + cd Tools/jMAVSim ant create_run_jar copy_res cd out/production java -Djava.ext.dirs= -jar jmavsim_run.jar -udp 127.0.0.1:14560 & @@ -82,9 +71,15 @@ then if [ -x "$(command -v gazebo)" ] then # Set the plugin path so Gazebo finds our model and sim - source /usr/share/gazebo/setup.sh - source $src_path/integrationtests/setup_gazebo_ros.bash ${src_path} ${build_path} - gzserver --verbose worlds/${model}.world & + export GAZEBO_PLUGIN_PATH=$curr_dir/build_gazebo:${GAZEBO_PLUGIN_PATH} + # Set the model path so Gazebo finds the airframes + export GAZEBO_MODEL_PATH=${GAZEBO_MODEL_PATH}:$curr_dir/Tools/sitl_gazebo/models + # The next line would disable online model lookup, can be commented in, in case of unstable behaviour. + # export GAZEBO_MODEL_DATABASE_URI="" + export SITL_GAZEBO_PATH=$curr_dir/Tools/sitl_gazebo + make --no-print-directory gazebo_build + + gzserver --verbose $curr_dir/Tools/sitl_gazebo/worlds/${model}.world & SIM_PID=`echo $!` if [[ -n "$HEADLESS" ]]; then @@ -103,17 +98,17 @@ then # This is not a simulator, but a log file to replay # Check if we need to creat a param file to allow user to change parameters - if ! [ -f "$rootfs/replay_params.txt" ] + if ! [ -f "${build_path}/src/firmware/posix/rootfs/replay_params.txt" ] then - touch $rootfs/replay_params.txt + touch ${build_path}/src/firmware/posix/rootfs/replay_params.txt fi fi -cd $working_dir +cd $build_path/src/firmware/posix if [ "$logfile" != "" ] then - cp $logfile $rootfs/replay.px4log + cp $logfile rootfs/replay.px4log fi # Do not exit on failure now from here on because we want the complete cleanup @@ -122,18 +117,18 @@ set +e # Start Java simulator if [ "$debugger" == "lldb" ] then - lldb -- $sitl_bin $src_path $src_path/${rc_script}_${program}_${model} + lldb -- px4 ../../../../${rc_script}_${program}_${model} elif [ "$debugger" == "gdb" ] then - gdb --args $sitl_bin $src_path $src_path/${rc_script}_${program}_${model} + gdb --args px4 ../../../../${rc_script}_${program}_${model} elif [ "$debugger" == "ddd" ] then - ddd --debugger gdb --args px4 $src_path $src_path/${rc_script}_${program}_${model} + ddd --debugger gdb --args px4 ../../../../${rc_script}_${program}_${model} elif [ "$debugger" == "valgrind" ] then - valgrind $sitl_bin $src_path $src_path/${rc_script}_${program}_${model} + valgrind ./px4 ../../../../${rc_script}_${program}_${model} else - $sudo_enabled $sitl_bin $chroot_enabled $src_path $src_path/${rc_script}_${program}_${model} + $sudo_enabled ./px4 $chroot_enabled ../../../../${rc_script}_${program}_${model} fi if [ "$program" == "jmavsim" ] diff --git a/cmake/common/px4_base.cmake b/cmake/common/px4_base.cmake index 88f1e57f98..ef05520375 100644 --- a/cmake/common/px4_base.cmake +++ b/cmake/common/px4_base.cmake @@ -136,14 +136,14 @@ function(px4_add_git_submodule) REQUIRED TARGET PATH ARGN ${ARGN}) string(REPLACE "/" "_" NAME ${PATH}) - add_custom_command(OUTPUT ${PX4_BINARY_DIR}/git_init_${NAME}.stamp - WORKING_DIRECTORY ${PX4_SOURCE_DIR} - COMMAND touch ${PX4_BINARY_DIR}/git_init_${NAME}.stamp - DEPENDS ${PX4_SOURCE_DIR}/.gitmodules + add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/git_init_${NAME}.stamp + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + COMMAND touch ${CMAKE_BINARY_DIR}/git_init_${NAME}.stamp + DEPENDS ${CMAKE_SOURCE_DIR}/.gitmodules ) add_custom_target(${TARGET} - WORKING_DIRECTORY ${PX4_SOURCE_DIR} - DEPENDS ${PX4_BINARY_DIR}/git_init_${NAME}.stamp + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + DEPENDS ${CMAKE_BINARY_DIR}/git_init_${NAME}.stamp ) endfunction() @@ -371,7 +371,7 @@ function(px4_generate_messages) endif() # headers - set(msg_out_path ${PX4_BINARY_DIR}/src/modules/uORB/topics) + set(msg_out_path ${CMAKE_BINARY_DIR}/src/modules/uORB/topics) set(msg_list) foreach(msg_file ${MSG_FILES}) get_filename_component(msg ${msg_file} NAME_WE) @@ -389,15 +389,15 @@ function(px4_generate_messages) -d msg -o ${msg_out_path} -e msg/templates/uorb - -t ${PX4_BINARY_DIR}/topics_temporary_header + -t ${CMAKE_BINARY_DIR}/topics_temporary_header DEPENDS ${DEPENDS} ${MSG_FILES} - WORKING_DIRECTORY ${PX4_SOURCE_DIR} + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} COMMENT "Generating uORB topic headers" VERBATIM ) # !sources - set(msg_source_out_path ${PX4_BINARY_DIR}/topics_sources) + set(msg_source_out_path ${CMAKE_BINARY_DIR}/topics_sources) set(msg_source_files_out ${msg_source_out_path}/uORBTopics.cpp) foreach(msg ${msg_list}) list(APPEND msg_source_files_out ${msg_source_out_path}/${msg}.cpp) @@ -410,9 +410,9 @@ function(px4_generate_messages) -d msg -o ${msg_source_out_path} -e msg/templates/uorb - -t ${PX4_BINARY_DIR}/topics_temporary_sources + -t ${CMAKE_BINARY_DIR}/topics_temporary_sources DEPENDS ${DEPENDS} ${MSG_FILES} - WORKING_DIRECTORY ${PX4_SOURCE_DIR} + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} COMMENT "Generating uORB topic sources" VERBATIM ) @@ -427,7 +427,7 @@ function(px4_generate_messages) # multi messages for target OS set(msg_multi_out_path - ${PX4_BINARY_DIR}/src/platforms/${OS}/px4_messages) + ${CMAKE_BINARY_DIR}/src/platforms/${OS}/px4_messages) set(msg_multi_files_out) foreach(msg ${msg_list}) list(APPEND msg_multi_files_out ${msg_multi_out_path}/px4_${msg}.h) @@ -440,10 +440,10 @@ function(px4_generate_messages) -d msg -o ${msg_multi_out_path} -e msg/templates/px4/uorb - -t ${PX4_BINARY_DIR}/multi_topics_temporary/${OS} + -t ${CMAKE_BINARY_DIR}/multi_topics_temporary/${OS} -p "px4_" DEPENDS ${DEPENDS} ${MSG_FILES} - WORKING_DIRECTORY ${PX4_SOURCE_DIR} + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} COMMENT "Generating uORB topic multi headers for ${OS}" VERBATIM ) @@ -504,9 +504,9 @@ function(px4_add_upload) px4_join(OUT serial_ports LIST "${serial_ports}" GLUE ",") add_custom_target(${OUT} COMMAND ${PYTHON_EXECUTABLE} - ${PX4_SOURCE_DIR}/Tools/px_uploader.py --port ${serial_ports} ${BUNDLE} + ${CMAKE_SOURCE_DIR}/Tools/px_uploader.py --port ${serial_ports} ${BUNDLE} DEPENDS ${BUNDLE} - WORKING_DIRECTORY ${PX4_BINARY_DIR} + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} COMMENT "uploading ${BUNDLE}" VERBATIM USES_TERMINAL @@ -523,9 +523,9 @@ function(px4_add_adb_push) ARGN ${ARGN}) add_custom_target(${OUT} - COMMAND ${PX4_SOURCE_DIR}/Tools/adb_upload.sh ${FILES} ${DEST} + COMMAND ${CMAKE_SOURCE_DIR}/Tools/adb_upload.sh ${FILES} ${DEST} DEPENDS ${DEPENDS} - WORKING_DIRECTORY ${PX4_BINARY_DIR} + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} COMMENT "uploading ${BUNDLE}" VERBATIM USES_TERMINAL @@ -541,9 +541,9 @@ function(px4_add_adb_push_to_bebop) ARGN ${ARGN}) add_custom_target(${OUT} - COMMAND ${PX4_SOURCE_DIR}/Tools/adb_upload_to_bebop.sh ${FILES} ${DEST} + COMMAND ${CMAKE_SOURCE_DIR}/Tools/adb_upload_to_bebop.sh ${FILES} ${DEST} DEPENDS ${DEPENDS} - WORKING_DIRECTORY ${PX4_BINARY_DIR} + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} COMMENT "uploading ${BUNDLE}" VERBATIM USES_TERMINAL @@ -559,9 +559,9 @@ function(px4_add_scp_push) ARGN ${ARGN}) add_custom_target(${OUT} - COMMAND ${PX4_SOURCE_DIR}/Tools/scp_upload.sh ${FILES} ${DEST} + COMMAND ${CMAKE_SOURCE_DIR}/Tools/scp_upload.sh ${FILES} ${DEST} DEPENDS ${DEPENDS} - WORKING_DIRECTORY ${PX4_BINARY_DIR} + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} COMMENT "uploading ${BUNDLE}" VERBATIM USES_TERMINAL @@ -761,21 +761,21 @@ function(px4_add_common_flags) ) set(added_include_dirs - ${PX4_SOURCE_DIR}/src - ${PX4_BINARY_DIR} - ${PX4_BINARY_DIR}/src - ${PX4_SOURCE_DIR}/src/modules - ${PX4_SOURCE_DIR}/src/include - ${PX4_SOURCE_DIR}/src/lib - ${PX4_SOURCE_DIR}/src/platforms + ${CMAKE_SOURCE_DIR}/src + ${CMAKE_BINARY_DIR} + ${CMAKE_BINARY_DIR}/src + ${CMAKE_SOURCE_DIR}/src/modules + ${CMAKE_SOURCE_DIR}/src/include + ${CMAKE_SOURCE_DIR}/src/lib + ${CMAKE_SOURCE_DIR}/src/platforms # TODO Build/versioning was in Makefile, # do we need this, how does it work with cmake - ${PX4_SOURCE_DIR}/src/drivers/boards/${BOARD} - ${PX4_BINARY_DIR} - ${PX4_BINARY_DIR}/src/modules/px4_messages - ${PX4_BINARY_DIR}/src/modules - ${PX4_SOURCE_DIR}/mavlink/include/mavlink - ${PX4_SOURCE_DIR}/src/lib/DriverFramework/framework/include + ${CMAKE_SOURCE_DIR}/src/drivers/boards/${BOARD} + ${CMAKE_BINARY_DIR} + ${CMAKE_BINARY_DIR}/src/modules/px4_messages + ${CMAKE_BINARY_DIR}/src/modules + ${CMAKE_SOURCE_DIR}/mavlink/include/mavlink + ${CMAKE_SOURCE_DIR}/src/lib/DriverFramework/framework/include ) list(APPEND added_include_dirs @@ -858,19 +858,19 @@ function(px4_create_git_hash_header) COMMAND git describe --always --tags OUTPUT_VARIABLE git_tag OUTPUT_STRIP_TRAILING_WHITESPACE - WORKING_DIRECTORY ${PX4_SOURCE_DIR} + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} ) message(STATUS "GIT_TAG = ${git_tag}") execute_process( COMMAND git rev-parse --verify HEAD OUTPUT_VARIABLE git_version OUTPUT_STRIP_TRAILING_WHITESPACE - WORKING_DIRECTORY ${PX4_SOURCE_DIR} + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} ) #message(STATUS "GIT_VERSION = ${git_version}") set(git_version_short) string(SUBSTRING ${git_version} 1 16 git_version_short) - configure_file(${PX4_SOURCE_DIR}/cmake/templates/build_git_version.h.in ${HEADER} @ONLY) + configure_file(${CMAKE_SOURCE_DIR}/cmake/templates/build_git_version.h.in ${HEADER} @ONLY) endfunction() #============================================================================= @@ -897,12 +897,12 @@ function(px4_generate_parameters_xml) ONE_VALUE OUT BOARD REQUIRED OUT BOARD ARGN ${ARGN}) - set(path ${PX4_SOURCE_DIR}/src) + set(path ${CMAKE_SOURCE_DIR}/src) file(GLOB_RECURSE param_src_files - ${PX4_SOURCE_DIR}/src/*params.c + ${CMAKE_SOURCE_DIR}/src/*params.c ) add_custom_command(OUTPUT ${OUT} - COMMAND ${PYTHON_EXECUTABLE} ${PX4_SOURCE_DIR}/Tools/px_process_params.py + COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/Tools/px_process_params.py -s ${path} --board CONFIG_ARCH_${BOARD} --xml --inject-xml DEPENDS ${param_src_files} ) @@ -944,7 +944,7 @@ function(px4_generate_parameters_source) set(SCOPE "") endif() add_custom_command(OUTPUT ${generated_files} - COMMAND ${PYTHON_EXECUTABLE} ${PX4_SOURCE_DIR}/Tools/px_generate_params.py ${XML} ${SCOPE} + COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/Tools/px_generate_params.py ${XML} ${SCOPE} DEPENDS ${XML} ${DEPS} ${SCOPE} ) set(${OUT} ${generated_files} PARENT_SCOPE) @@ -975,10 +975,10 @@ function(px4_generate_airframes_xml) ONE_VALUE OUT BOARD REQUIRED OUT BOARD ARGN ${ARGN}) - set(process_airframes ${PX4_SOURCE_DIR}/Tools/px_process_airframes.py) + set(process_airframes ${CMAKE_SOURCE_DIR}/Tools/px_process_airframes.py) add_custom_command(OUTPUT ${OUT} COMMAND ${PYTHON_EXECUTABLE} ${process_airframes} - -a ${PX4_SOURCE_DIR}/ROMFS/px4fmu_common/init.d + -a ${CMAKE_SOURCE_DIR}/ROMFS/px4fmu_common/init.d --board CONFIG_ARCH_BOARD_${BOARD} --xml ) set(${OUT} ${${OUT}} PARENT_SCOPE) diff --git a/cmake/configs/nuttx_mindpx-v2_default.cmake b/cmake/configs/nuttx_mindpx-v2_default.cmake index 32bbf050fd..41c9d32df8 100644 --- a/cmake/configs/nuttx_mindpx-v2_default.cmake +++ b/cmake/configs/nuttx_mindpx-v2_default.cmake @@ -1,6 +1,6 @@ include(nuttx/px4_impl_nuttx) -set(CMAKE_TOOLCHAIN_FILE ${PX4_SOURCE_DIR}/cmake/toolchains/Toolchain-arm-none-eabi.cmake) +set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/cmake/toolchains/Toolchain-arm-none-eabi.cmake) set(config_uavcan_num_ifaces 2) diff --git a/cmake/configs/nuttx_px4-stm32f4discovery_default.cmake b/cmake/configs/nuttx_px4-stm32f4discovery_default.cmake index 377a90f335..c71db2fc31 100644 --- a/cmake/configs/nuttx_px4-stm32f4discovery_default.cmake +++ b/cmake/configs/nuttx_px4-stm32f4discovery_default.cmake @@ -1,6 +1,6 @@ include(nuttx/px4_impl_nuttx) -set(CMAKE_TOOLCHAIN_FILE ${PX4_SOURCE_DIR}/cmake/toolchains/Toolchain-arm-none-eabi.cmake) +set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/cmake/toolchains/Toolchain-arm-none-eabi.cmake) set(config_module_list # diff --git a/cmake/configs/nuttx_px4fmu-v1_default.cmake b/cmake/configs/nuttx_px4fmu-v1_default.cmake index 2c0a5f7315..75f8d054ed 100644 --- a/cmake/configs/nuttx_px4fmu-v1_default.cmake +++ b/cmake/configs/nuttx_px4fmu-v1_default.cmake @@ -1,6 +1,6 @@ include(nuttx/px4_impl_nuttx) -set(CMAKE_TOOLCHAIN_FILE ${PX4_SOURCE_DIR}/cmake/toolchains/Toolchain-arm-none-eabi.cmake) +set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/cmake/toolchains/Toolchain-arm-none-eabi.cmake) set(config_module_list # diff --git a/cmake/configs/nuttx_px4fmu-v2_default.cmake b/cmake/configs/nuttx_px4fmu-v2_default.cmake index 13d02e6d28..c38d726702 100644 --- a/cmake/configs/nuttx_px4fmu-v2_default.cmake +++ b/cmake/configs/nuttx_px4fmu-v2_default.cmake @@ -1,6 +1,6 @@ include(nuttx/px4_impl_nuttx) -set(CMAKE_TOOLCHAIN_FILE ${PX4_SOURCE_DIR}/cmake/toolchains/Toolchain-arm-none-eabi.cmake) +set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/cmake/toolchains/Toolchain-arm-none-eabi.cmake) set(config_uavcan_num_ifaces 2) diff --git a/cmake/configs/nuttx_px4fmu-v2_ekf2.cmake b/cmake/configs/nuttx_px4fmu-v2_ekf2.cmake index e500752214..f43b782045 100644 --- a/cmake/configs/nuttx_px4fmu-v2_ekf2.cmake +++ b/cmake/configs/nuttx_px4fmu-v2_ekf2.cmake @@ -1,6 +1,6 @@ include(nuttx/px4_impl_nuttx) -set(CMAKE_TOOLCHAIN_FILE ${PX4_SOURCE_DIR}/cmake/toolchains/Toolchain-arm-none-eabi.cmake) +set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/cmake/toolchains/Toolchain-arm-none-eabi.cmake) set(config_uavcan_num_ifaces 2) diff --git a/cmake/configs/nuttx_px4fmu-v2_test.cmake b/cmake/configs/nuttx_px4fmu-v2_test.cmake index 1839d8689d..b72c5a8190 100644 --- a/cmake/configs/nuttx_px4fmu-v2_test.cmake +++ b/cmake/configs/nuttx_px4fmu-v2_test.cmake @@ -1,6 +1,6 @@ include(nuttx/px4_impl_nuttx) -set(CMAKE_TOOLCHAIN_FILE ${PX4_SOURCE_DIR}/cmake/toolchains/Toolchain-arm-none-eabi.cmake) +set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/cmake/toolchains/Toolchain-arm-none-eabi.cmake) set(config_uavcan_num_ifaces 2) diff --git a/cmake/configs/nuttx_px4fmu-v4_default.cmake b/cmake/configs/nuttx_px4fmu-v4_default.cmake index ad746ee426..866e19dc0d 100644 --- a/cmake/configs/nuttx_px4fmu-v4_default.cmake +++ b/cmake/configs/nuttx_px4fmu-v4_default.cmake @@ -1,6 +1,6 @@ include(nuttx/px4_impl_nuttx) -set(CMAKE_TOOLCHAIN_FILE ${PX4_SOURCE_DIR}/cmake/toolchains/Toolchain-arm-none-eabi.cmake) +set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/cmake/toolchains/Toolchain-arm-none-eabi.cmake) set(config_uavcan_num_ifaces 1) diff --git a/cmake/configs/nuttx_tap-v1_default.cmake b/cmake/configs/nuttx_tap-v1_default.cmake index 8a5b8187fb..2dad824901 100644 --- a/cmake/configs/nuttx_tap-v1_default.cmake +++ b/cmake/configs/nuttx_tap-v1_default.cmake @@ -1,6 +1,6 @@ include(nuttx/px4_impl_nuttx) -set(CMAKE_TOOLCHAIN_FILE ${PX4_SOURCE_DIR}/cmake/toolchains/Toolchain-arm-none-eabi.cmake) +set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/cmake/toolchains/Toolchain-arm-none-eabi.cmake) set(config_module_list # diff --git a/cmake/configs/posix_bebop_default.cmake b/cmake/configs/posix_bebop_default.cmake index 72e945db0f..5538ffe35a 100644 --- a/cmake/configs/posix_bebop_default.cmake +++ b/cmake/configs/posix_bebop_default.cmake @@ -1,6 +1,6 @@ include(posix/px4_impl_posix) -set(CMAKE_TOOLCHAIN_FILE ${PX4_SOURCE_DIR}/cmake/toolchains/Toolchain-arm-linux-gnueabihf-raspbian.cmake) +set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/cmake/toolchains/Toolchain-arm-linux-gnueabihf-raspbian.cmake) add_definitions( -D__PX4_POSIX_BEBOP diff --git a/cmake/configs/posix_eagle_default.cmake b/cmake/configs/posix_eagle_default.cmake index be81961425..3a6dd22755 100644 --- a/cmake/configs/posix_eagle_default.cmake +++ b/cmake/configs/posix_eagle_default.cmake @@ -4,9 +4,9 @@ # on the Linux side of the Snapdragon. include(configs/posix_sdflight_default) -set(CMAKE_TOOLCHAIN_FILE ${PX4_SOURCE_DIR}/cmake/cmake_hexagon/toolchain/Toolchain-arm-linux-gnueabihf.cmake) +set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/cmake/cmake_hexagon/toolchain/Toolchain-arm-linux-gnueabihf.cmake) -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PX4_SOURCE_DIR}/cmake/cmake_hexagon") +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/cmake_hexagon") set(CONFIG_SHMEM "1") diff --git a/cmake/configs/posix_eagle_hil.cmake b/cmake/configs/posix_eagle_hil.cmake index d38da131bd..909bdeecb1 100644 --- a/cmake/configs/posix_eagle_hil.cmake +++ b/cmake/configs/posix_eagle_hil.cmake @@ -1,13 +1,13 @@ include(posix/px4_impl_posix) -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PX4_SOURCE_DIR}/cmake/cmake_hexagon") +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/cmake_hexagon") # Use build stubs unless explicitly set not to if("${DSPAL_STUBS_ENABLE}" STREQUAL "") set(DSPAL_STUBS_ENABLE "1") endif() -set(CMAKE_TOOLCHAIN_FILE ${PX4_SOURCE_DIR}/cmake/toolchains/Toolchain-arm-linux-gnueabihf.cmake) +set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/cmake/toolchains/Toolchain-arm-linux-gnueabihf.cmake) set(config_generate_parameters_scope ALL) diff --git a/cmake/configs/posix_eagle_legacy_driver_default.cmake b/cmake/configs/posix_eagle_legacy_driver_default.cmake index 534d327f7e..ec172e7602 100644 --- a/cmake/configs/posix_eagle_legacy_driver_default.cmake +++ b/cmake/configs/posix_eagle_legacy_driver_default.cmake @@ -1,8 +1,8 @@ include(posix/px4_impl_posix) -set(CMAKE_TOOLCHAIN_FILE ${PX4_SOURCE_DIR}/cmake/cmake_hexagon/toolchain/Toolchain-arm-linux-gnueabihf.cmake) +set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/cmake/cmake_hexagon/toolchain/Toolchain-arm-linux-gnueabihf.cmake) -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PX4_SOURCE_DIR}/cmake/cmake_hexagon") +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/cmake_hexagon") set(config_generate_parameters_scope ALL) diff --git a/cmake/configs/posix_eagle_muorb.cmake b/cmake/configs/posix_eagle_muorb.cmake index f47c421dce..95a5c59beb 100644 --- a/cmake/configs/posix_eagle_muorb.cmake +++ b/cmake/configs/posix_eagle_muorb.cmake @@ -1,8 +1,8 @@ include(posix/px4_impl_posix) -set(CMAKE_TOOLCHAIN_FILE ${PX4_SOURCE_DIR}/cmake/toolchains/Toolchain-arm-linux-gnueabihf.cmake) +set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/cmake/toolchains/Toolchain-arm-linux-gnueabihf.cmake) -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PX4_SOURCE_DIR}/cmake/cmake_hexagon") +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/cmake_hexagon") set(config_generate_parameters_scope ALL) diff --git a/cmake/configs/posix_rpi_cross.cmake b/cmake/configs/posix_rpi_cross.cmake index 72896086c6..46243fc361 100644 --- a/cmake/configs/posix_rpi_cross.cmake +++ b/cmake/configs/posix_rpi_cross.cmake @@ -1,6 +1,6 @@ include(configs/posix_rpi_common) -set(CMAKE_TOOLCHAIN_FILE ${PX4_SOURCE_DIR}/cmake/toolchains/Toolchain-arm-linux-gnueabihf-raspbian.cmake) +set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/cmake/toolchains/Toolchain-arm-linux-gnueabihf-raspbian.cmake) set(CMAKE_PROGRAM_PATH "${RPI_TOOLCHAIN_DIR}/gcc-linaro-arm-linux-gnueabihf-raspbian/bin" diff --git a/cmake/configs/posix_rpi_native.cmake b/cmake/configs/posix_rpi_native.cmake index b2a54c4f65..e58f370282 100644 --- a/cmake/configs/posix_rpi_native.cmake +++ b/cmake/configs/posix_rpi_native.cmake @@ -1,3 +1,3 @@ include(configs/posix_rpi_common) -set(CMAKE_TOOLCHAIN_FILE ${PX4_SOURCE_DIR}/cmake/toolchains/Toolchain-native.cmake) +set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/cmake/toolchains/Toolchain-native.cmake) diff --git a/cmake/configs/posix_sdflight_default.cmake b/cmake/configs/posix_sdflight_default.cmake index fc66327184..c43e51974c 100644 --- a/cmake/configs/posix_sdflight_default.cmake +++ b/cmake/configs/posix_sdflight_default.cmake @@ -1,8 +1,8 @@ include(posix/px4_impl_posix) -set(CMAKE_TOOLCHAIN_FILE ${PX4_SOURCE_DIR}/cmake/toolchains/Toolchain-arm-linux-gnueabihf.cmake) +set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/cmake/toolchains/Toolchain-arm-linux-gnueabihf.cmake) -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PX4_SOURCE_DIR}/cmake/cmake_hexagon") +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/cmake_hexagon") set(config_generate_parameters_scope ALL) diff --git a/cmake/configs/posix_sitl_broadcast.cmake b/cmake/configs/posix_sitl_broadcast.cmake index 0c7bf4b0a2..9a9029f1c0 100644 --- a/cmake/configs/posix_sitl_broadcast.cmake +++ b/cmake/configs/posix_sitl_broadcast.cmake @@ -1,6 +1,6 @@ include(posix/px4_impl_posix) -set(CMAKE_TOOLCHAIN_FILE ${PX4_SOURCE_DIR}/cmake/toolchains/Toolchain-native.cmake) +set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/cmake/toolchains/Toolchain-native.cmake) set(config_module_list drivers/device diff --git a/cmake/configs/posix_sitl_default.cmake b/cmake/configs/posix_sitl_default.cmake index 62caa65e72..6fa6d9c0b7 100644 --- a/cmake/configs/posix_sitl_default.cmake +++ b/cmake/configs/posix_sitl_default.cmake @@ -1,6 +1,6 @@ include(posix/px4_impl_posix) -set(CMAKE_TOOLCHAIN_FILE ${PX4_SOURCE_DIR}/cmake/toolchains/Toolchain-native.cmake) +set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/cmake/toolchains/Toolchain-native.cmake) set(config_module_list drivers/boards/sitl diff --git a/cmake/configs/posix_sitl_replay.cmake b/cmake/configs/posix_sitl_replay.cmake index a20a2d8cfe..3c99cba7a7 100644 --- a/cmake/configs/posix_sitl_replay.cmake +++ b/cmake/configs/posix_sitl_replay.cmake @@ -1,6 +1,6 @@ include(posix/px4_impl_posix) -set(CMAKE_TOOLCHAIN_FILE ${PX4_SOURCE_DIR}/cmake/toolchains/Toolchain-native.cmake) +set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/cmake/toolchains/Toolchain-native.cmake) set(config_module_list drivers/device diff --git a/cmake/configs/qurt_eagle_hello.cmake b/cmake/configs/qurt_eagle_hello.cmake index db16c17d2a..e1a66ea827 100644 --- a/cmake/configs/qurt_eagle_hello.cmake +++ b/cmake/configs/qurt_eagle_hello.cmake @@ -6,9 +6,9 @@ else() set(HEXAGON_SDK_ROOT $ENV{HEXAGON_SDK_ROOT}) endif() -set(CMAKE_TOOLCHAIN_FILE ${PX4_SOURCE_DIR}/cmake/cmake_hexagon/toolchain/Toolchain-qurt.cmake) +set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/cmake/cmake_hexagon/toolchain/Toolchain-qurt.cmake) -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PX4_SOURCE_DIR}/cmake/cmake_hexagon") +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/cmake_hexagon") set(config_generate_parameters_scope ALL) diff --git a/cmake/configs/qurt_eagle_hil.cmake b/cmake/configs/qurt_eagle_hil.cmake index 9eba5dea83..469432818f 100644 --- a/cmake/configs/qurt_eagle_hil.cmake +++ b/cmake/configs/qurt_eagle_hil.cmake @@ -6,9 +6,9 @@ else() set(HEXAGON_SDK_ROOT $ENV{HEXAGON_SDK_ROOT}) endif() -set(CMAKE_TOOLCHAIN_FILE ${PX4_SOURCE_DIR}/cmake/cmake_hexagon/toolchain/Toolchain-qurt.cmake) +set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/cmake/cmake_hexagon/toolchain/Toolchain-qurt.cmake) -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PX4_SOURCE_DIR}/cmake/cmake_hexagon") +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/cmake_hexagon") set(config_generate_parameters_scope ALL) diff --git a/cmake/configs/qurt_eagle_legacy_driver_default.cmake b/cmake/configs/qurt_eagle_legacy_driver_default.cmake index 852fe55b1f..f0fdb2dee5 100644 --- a/cmake/configs/qurt_eagle_legacy_driver_default.cmake +++ b/cmake/configs/qurt_eagle_legacy_driver_default.cmake @@ -10,9 +10,9 @@ set(CONFIG_SHMEM "1") set(config_generate_parameters_scope ALL) -set(CMAKE_TOOLCHAIN_FILE ${PX4_SOURCE_DIR}/cmake/cmake_hexagon/toolchain/Toolchain-qurt.cmake) +set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/cmake/cmake_hexagon/toolchain/Toolchain-qurt.cmake) -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PX4_SOURCE_DIR}/cmake/cmake_hexagon") +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/cmake_hexagon") add_definitions( -D__USING_SNAPDRAGON_LEGACY_DRIVER diff --git a/cmake/configs/qurt_eagle_muorb.cmake b/cmake/configs/qurt_eagle_muorb.cmake index 2af8ebdfb2..505ffd00cd 100644 --- a/cmake/configs/qurt_eagle_muorb.cmake +++ b/cmake/configs/qurt_eagle_muorb.cmake @@ -6,9 +6,9 @@ else() set(HEXAGON_SDK_ROOT $ENV{HEXAGON_SDK_ROOT}) endif() -set(CMAKE_TOOLCHAIN_FILE ${PX4_SOURCE_DIR}/cmake/cmake_hexagon/toolchain/Toolchain-qurt.cmake) +set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/cmake/cmake_hexagon/toolchain/Toolchain-qurt.cmake) -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PX4_SOURCE_DIR}/cmake/cmake_hexagon") +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/cmake_hexagon") set(config_generate_parameters_scope ALL) diff --git a/cmake/configs/qurt_eagle_test.cmake b/cmake/configs/qurt_eagle_test.cmake index 9131478577..9170b3da47 100644 --- a/cmake/configs/qurt_eagle_test.cmake +++ b/cmake/configs/qurt_eagle_test.cmake @@ -6,8 +6,8 @@ else() set(HEXAGON_SDK_ROOT $ENV{HEXAGON_SDK_ROOT}) endif() -set(CMAKE_TOOLCHAIN_FILE ${PX4_SOURCE_DIR}/cmake/cmake_hexagon/toolchain/Toolchain-qurt.cmake) -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PX4_SOURCE_DIR}/cmake/cmake_hexagon") +set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/cmake/cmake_hexagon/toolchain/Toolchain-qurt.cmake) +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/cmake_hexagon") set(config_generate_parameters_scope ALL) diff --git a/cmake/configs/qurt_eagle_travis.cmake b/cmake/configs/qurt_eagle_travis.cmake index 505635b8bd..16aa788edc 100644 --- a/cmake/configs/qurt_eagle_travis.cmake +++ b/cmake/configs/qurt_eagle_travis.cmake @@ -5,9 +5,9 @@ set(CONFIG_SHMEM "1") # Run a full link with build stubs to make sure qurt target isn't broken set(QURT_ENABLE_STUBS "1") -set(CMAKE_TOOLCHAIN_FILE ${PX4_SOURCE_DIR}/cmake/cmake_hexagon/toolchain/Toolchain-qurt.cmake) +set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/cmake/cmake_hexagon/toolchain/Toolchain-qurt.cmake) -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PX4_SOURCE_DIR}/cmake/cmake_hexagon") +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/cmake_hexagon") include(hexagon_sdk) if ("$ENV{HEXAGON_SDK_ROOT}" STREQUAL "") diff --git a/cmake/configs/qurt_sdflight_default.cmake b/cmake/configs/qurt_sdflight_default.cmake index 1d30699014..195219f7af 100644 --- a/cmake/configs/qurt_sdflight_default.cmake +++ b/cmake/configs/qurt_sdflight_default.cmake @@ -10,9 +10,9 @@ set(CONFIG_SHMEM "1") set(config_generate_parameters_scope ALL) -set(CMAKE_TOOLCHAIN_FILE ${PX4_SOURCE_DIR}/cmake/cmake_hexagon/toolchain/Toolchain-qurt.cmake) +set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/cmake/cmake_hexagon/toolchain/Toolchain-qurt.cmake) -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PX4_SOURCE_DIR}/cmake/cmake_hexagon") +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/cmake_hexagon") set(config_module_list # diff --git a/cmake/nuttx/px4_impl_nuttx.cmake b/cmake/nuttx/px4_impl_nuttx.cmake index 9a54b6277e..c969263be1 100644 --- a/cmake/nuttx/px4_impl_nuttx.cmake +++ b/cmake/nuttx/px4_impl_nuttx.cmake @@ -95,9 +95,9 @@ function(px4_nuttx_add_firmware) add_custom_command(OUTPUT ${OUT} COMMAND ${OBJCOPY} -O binary ${EXE} ${EXE}.bin - COMMAND ${PYTHON_EXECUTABLE} ${PX4_SOURCE_DIR}/Tools/px_mkfw.py - --prototype ${PX4_SOURCE_DIR}/Images/${BOARD}.prototype - --git_identity ${PX4_SOURCE_DIR} + COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/Tools/px_mkfw.py + --prototype ${CMAKE_SOURCE_DIR}/Images/${BOARD}.prototype + --git_identity ${CMAKE_SOURCE_DIR} ${extra_args} --image ${EXE}.bin > ${OUT} DEPENDS ${EXE} @@ -148,7 +148,7 @@ function(px4_nuttx_generate_builtin_commands) math(EXPR command_count "${command_count}+1") endif() endforeach() - configure_file(${PX4_SOURCE_DIR}/cmake/nuttx/builtin_commands.c.in + configure_file(${CMAKE_SOURCE_DIR}/cmake/nuttx/builtin_commands.c.in ${OUT}) endfunction() @@ -183,17 +183,17 @@ function(px4_nuttx_add_export) REQUIRED OUT CONFIG THREADS ARGN ${ARGN}) - set(nuttx_src ${PX4_BINARY_DIR}/${CONFIG}/NuttX) + set(nuttx_src ${CMAKE_BINARY_DIR}/${CONFIG}/NuttX) # patch add_custom_target(__nuttx_patch_${CONFIG}) - file(GLOB nuttx_patches RELATIVE ${PX4_SOURCE_DIR} - ${PX4_SOURCE_DIR}/nuttx-patches/*.patch) + file(GLOB nuttx_patches RELATIVE ${CMAKE_SOURCE_DIR} + ${CMAKE_SOURCE_DIR}/nuttx-patches/*.patch) foreach(patch ${nuttx_patches}) string(REPLACE "/" "_" patch_name "${patch}-${CONFIG}") message(STATUS "nuttx-patch: ${patch}") add_custom_command(OUTPUT nuttx_patch_${patch_name}.stamp - COMMAND ${PATCH} -p0 -N < ${PX4_SOURCE_DIR}/${patch} + COMMAND ${PATCH} -p0 -N < ${CMAKE_SOURCE_DIR}/${patch} COMMAND ${TOUCH} nuttx_patch_${patch_name}.stamp DEPENDS ${DEPENDS} ) @@ -204,7 +204,7 @@ function(px4_nuttx_add_export) # Read defconfig to see if CONFIG_ARMV7M_STACKCHECK is yes # note: CONFIG will be BOARD in the future evaluation of ${hw_stack_check_${CONFIG} - file(STRINGS "${PX4_SOURCE_DIR}/nuttx-configs/${CONFIG}/nsh/defconfig" + file(STRINGS "${CMAKE_SOURCE_DIR}/nuttx-configs/${CONFIG}/nsh/defconfig" hw_stack_check_${CONFIG} REGEX "CONFIG_ARMV7M_STACKCHECK=y" ) @@ -213,29 +213,29 @@ function(px4_nuttx_add_export) endif() # copy and export - file(RELATIVE_PATH nuttx_cp_src ${PX4_BINARY_DIR} ${PX4_SOURCE_DIR}/NuttX) - file(GLOB_RECURSE config_files ${PX4_SOURCE_DIR}/nuttx-configs/${CONFIG}/*) - add_custom_command(OUTPUT ${PX4_BINARY_DIR}/${CONFIG}.export + file(RELATIVE_PATH nuttx_cp_src ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR}/NuttX) + file(GLOB_RECURSE config_files ${CMAKE_SOURCE_DIR}/nuttx-configs/${CONFIG}/*) + add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/${CONFIG}.export COMMAND ${MKDIR} -p ${nuttx_src} COMMAND rsync -a --delete --exclude=.git ${nuttx_cp_src}/ ${CONFIG}/NuttX/ #COMMAND ${ECHO} Configuring NuttX for ${CONFIG} COMMAND ${MAKE} --no-print-directory -C${nuttx_src}/nuttx -r --quiet distclean - COMMAND ${CP} -r ${PX4_SOURCE_DIR}/nuttx-configs/PX4_Warnings.mk ${nuttx_src}/nuttx/ - COMMAND ${CP} -r ${PX4_SOURCE_DIR}/nuttx-configs/${CONFIG} ${nuttx_src}/nuttx/configs + COMMAND ${CP} -r ${CMAKE_SOURCE_DIR}/nuttx-configs/PX4_Warnings.mk ${nuttx_src}/nuttx/ + COMMAND ${CP} -r ${CMAKE_SOURCE_DIR}/nuttx-configs/${CONFIG} ${nuttx_src}/nuttx/configs COMMAND cd ${nuttx_src}/nuttx/tools && ./configure.sh ${CONFIG}/nsh && cd .. #COMMAND ${ECHO} Exporting NuttX for ${CONFIG} COMMAND ${MAKE} --no-print-directory --quiet -C ${nuttx_src}/nuttx -j${THREADS} -r CONFIG_ARCH_BOARD=${CONFIG} export > nuttx_build.log - COMMAND ${CP} -r ${nuttx_src}/nuttx/nuttx-export.zip ${PX4_BINARY_DIR}/${CONFIG}.export + COMMAND ${CP} -r ${nuttx_src}/nuttx/nuttx-export.zip ${CMAKE_BINARY_DIR}/${CONFIG}.export DEPENDS ${config_files} ${DEPENDS} - WORKING_DIRECTORY ${PX4_BINARY_DIR} + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} COMMENT "Building NuttX for ${CONFIG}") # extract add_custom_command(OUTPUT nuttx_export_${CONFIG}.stamp COMMAND ${RM} -rf ${nuttx_src}/nuttx-export - COMMAND ${UNZIP} -q ${PX4_BINARY_DIR}/${CONFIG}.export -d ${nuttx_src} + COMMAND ${UNZIP} -q ${CMAKE_BINARY_DIR}/${CONFIG}.export -d ${nuttx_src} COMMAND ${TOUCH} nuttx_export_${CONFIG}.stamp - DEPENDS ${DEPENDS} ${PX4_BINARY_DIR}/${CONFIG}.export) + DEPENDS ${DEPENDS} ${CMAKE_BINARY_DIR}/${CONFIG}.export) add_custom_target(${OUT} DEPENDS nuttx_export_${CONFIG}.stamp) @@ -308,16 +308,16 @@ function(px4_nuttx_add_romfs) REQUIRED OUT ROOT ARGN ${ARGN}) - set(romfs_temp_dir ${PX4_BINARY_DIR}/tmp/${ROOT}) - set(romfs_src_dir ${PX4_SOURCE_DIR}/${ROOT}) - set(romfs_autostart ${PX4_SOURCE_DIR}/Tools/px_process_airframes.py) - set(romfs_pruner ${PX4_SOURCE_DIR}/Tools/px_romfs_pruner.py) - set(bin_to_obj ${PX4_SOURCE_DIR}/cmake/nuttx/bin_to_obj.py) + set(romfs_temp_dir ${CMAKE_BINARY_DIR}/tmp/${ROOT}) + set(romfs_src_dir ${CMAKE_SOURCE_DIR}/${ROOT}) + set(romfs_autostart ${CMAKE_SOURCE_DIR}/Tools/px_process_airframes.py) + set(romfs_pruner ${CMAKE_SOURCE_DIR}/Tools/px_romfs_pruner.py) + set(bin_to_obj ${CMAKE_SOURCE_DIR}/cmake/nuttx/bin_to_obj.py) set(extras_dir ${CMAKE_CURRENT_BINARY_DIR}/extras) file(GLOB_RECURSE romfs_src_files ${romfs_src_dir} ${romfs_src_dir}/*) - set(cmake_test ${PX4_SOURCE_DIR}/cmake/test/cmake_tester.py) + set(cmake_test ${CMAKE_SOURCE_DIR}/cmake/test/cmake_tester.py) set(extras) @@ -346,7 +346,7 @@ function(px4_nuttx_add_romfs) #COMMAND cmake -E remove_directory ${romfs_temp_dir} COMMAND ${PYTHON_EXECUTABLE} ${bin_to_obj} --ld ${LD} --c_flags ${CMAKE_C_FLAGS} - --include_path "${PX4_SOURCE_DIR}/src/include" + --include_path "${CMAKE_SOURCE_DIR}/src/include" --c_compiler ${CMAKE_C_COMPILER} --nm ${NM} --objcopy ${OBJCOPY} --obj romfs.o @@ -414,7 +414,7 @@ function(px4_os_add_flags) LINK_DIRS ${LINK_DIRS} DEFINITIONS ${DEFINITIONS}) - set(nuttx_export_dir ${PX4_BINARY_DIR}/${BOARD}/NuttX/nuttx-export) + set(nuttx_export_dir ${CMAKE_BINARY_DIR}/${BOARD}/NuttX/nuttx-export) set(added_include_dirs ${nuttx_export_dir}/include ${nuttx_export_dir}/include/cxx diff --git a/cmake/posix/px4_impl_posix.cmake b/cmake/posix/px4_impl_posix.cmake index 7786097c4c..d661bfa5eb 100644 --- a/cmake/posix/px4_impl_posix.cmake +++ b/cmake/posix/px4_impl_posix.cmake @@ -49,7 +49,7 @@ # include(common/px4_base) -list(APPEND CMAKE_MODULE_PATH ${PX4_SOURCE_DIR}/cmake/posix) +list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/posix) #============================================================================= # @@ -101,7 +101,7 @@ function(px4_posix_generate_builtin_commands) math(EXPR command_count "${command_count}+1") endif() endforeach() - configure_file(${PX4_SOURCE_DIR}/cmake/posix/apps.h_in + configure_file(${CMAKE_SOURCE_DIR}/cmake/posix/apps.h_in ${OUT}) endfunction() diff --git a/cmake/qurt/px4_impl_qurt.cmake b/cmake/qurt/px4_impl_qurt.cmake index f5387c515e..efb1135d7b 100644 --- a/cmake/qurt/px4_impl_qurt.cmake +++ b/cmake/qurt/px4_impl_qurt.cmake @@ -50,7 +50,7 @@ # include(common/px4_base) -list(APPEND CMAKE_MODULE_PATH ${PX4_SOURCE_DIR}/cmake/qurt) +list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/qurt) #============================================================================= # @@ -95,7 +95,7 @@ function(px4_qurt_generate_builtin_commands) math(EXPR command_count "${command_count}+1") endif() endforeach() - configure_file(${PX4_SOURCE_DIR}/cmake/qurt/apps.h_in ${OUT}) + configure_file(${CMAKE_SOURCE_DIR}/cmake/qurt/apps.h_in ${OUT}) endfunction() #============================================================================= diff --git a/cmake/ros-CMakeLists.txt b/cmake/ros-CMakeLists.txt new file mode 100644 index 0000000000..67870b1e2c --- /dev/null +++ b/cmake/ros-CMakeLists.txt @@ -0,0 +1,334 @@ +cmake_minimum_required(VERSION 2.8.3) +project(px4) +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") +add_definitions(-D__PX4_ROS) +add_definitions(-D__EXPORT=) +add_definitions(-DMAVLINK_DIALECT=common) + +## Find catkin macros and libraries +## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz) +## is used, also find other catkin packages +find_package(catkin REQUIRED COMPONENTS + roscpp + rospy + std_msgs + geometry_msgs + message_generation + cmake_modules + gazebo_msgs + sensor_msgs + mav_msgs + libmavconn + tf +) +find_package(Eigen REQUIRED) + +## System dependencies are found with CMake's conventions +# find_package(Boost REQUIRED COMPONENTS system) + + +## Uncomment this if the package has a setup.py. This macro ensures +## modules and global scripts declared therein get installed +## See http://ros.org/doc/api/catkin/html/user_guide/setup_dot_py.html +# catkin_python_setup() + +################################################ +## Declare ROS messages, services and actions ## +################################################ + +## To declare and build messages, services or actions from within this +## package, follow these steps: +## * Let MSG_DEP_SET be the set of packages whose message types you use in +## your messages/services/actions (e.g. std_msgs, actionlib_msgs, ...). +## * In the file package.xml: +## * add a build_depend and a run_depend tag for each package in MSG_DEP_SET +## * If MSG_DEP_SET isn't empty the following dependencies might have been +## pulled in transitively but can be declared for certainty nonetheless: +## * add a build_depend tag for "message_generation" +## * add a run_depend tag for "message_runtime" +## * In this file (CMakeLists.txt): +## * add "message_generation" and every package in MSG_DEP_SET to +## find_package(catkin REQUIRED COMPONENTS ...) +## * add "message_runtime" and every package in MSG_DEP_SET to +## catkin_package(CATKIN_DEPENDS ...) +## * uncomment the add_*_files sections below as needed +## and list every .msg/.srv/.action file to be processed +## * uncomment the generate_messages entry below +## * add every package in MSG_DEP_SET to generate_messages(DEPENDENCIES ...) + +## Generate messages in the 'msg' folder +add_message_files( + FILES + actuator_armed.msg + actuator_controls.msg + commander_state.msg + control_state.msg + distance_sensor.msg + manual_control_setpoint.msg + mc_virtual_rates_setpoint.msg + offboard_control_mode.msg + parameter_update.msg + position_setpoint.msg + position_setpoint_triplet.msg + rc_channels.msg + ros/actuator_controls_0.msg + ros/actuator_controls_virtual_mc.msg + vehicle_attitude.msg + vehicle_attitude_setpoint.msg + vehicle_control_mode.msg + vehicle_force_setpoint.msg + vehicle_global_velocity_setpoint.msg + vehicle_local_position.msg + vehicle_local_position_setpoint.msg + vehicle_rates_setpoint.msg + vehicle_status.msg +) + +## Generate services in the 'srv' folder +# add_service_files( +# FILES +# Service1.srv +# Service2.srv +# ) + +## Generate actions in the 'action' folder +# add_action_files( +# FILES +# Action1.action +# Action2.action +# ) + +## Generate added messages and services with any dependencies listed here +generate_messages( + DEPENDENCIES + std_msgs + gazebo_msgs +) + +################################### +## catkin specific configuration ## +################################### +## The catkin_package macro generates cmake config files for your package +## Declare things to be passed to dependent projects +## INCLUDE_DIRS: uncomment this if you package contains header files +## LIBRARIES: libraries you create in this project that dependent projects also need +## CATKIN_DEPENDS: catkin_packages dependent projects also need +## DEPENDS: system dependencies of this project that dependent projects also need +catkin_package( + INCLUDE_DIRS src/include + LIBRARIES px4 + CATKIN_DEPENDS message_runtime roscpp rospy std_msgs libmavconn + DEPENDS system_lib +) + +########### +## Build ## +########### + +## Specify additional locations of header files +## Your package locations should be listed before other locations +include_directories( + ${catkin_INCLUDE_DIRS} + src/platforms + src/platforms/ros/px4_messages + src/include + src/modules + ${CMAKE_BINARY_DIR}/src/modules + src/ + src/lib + src/lib/matrix + ${EIGEN_INCLUDE_DIRS} + integrationtests +) + +## generate multiplatform wrapper headers +## note that the message header files are generated as in any ROS project with generate_messages() +set(MULTIPLATFORM_HEADER_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src/platforms/ros/px4_messages) +set(MULTIPLATFORM_TEMPLATE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/msg/templates/px4/ros) +set(TOPICHEADER_TEMP_DIR ${CMAKE_BINARY_DIR}/topics_temporary) +set(MULTIPLATFORM_PREFIX px4_) +add_custom_target(multiplatform_message_headers ALL ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/Tools/px_generate_uorb_topic_files.py + --headers -d ${CMAKE_CURRENT_SOURCE_DIR}/msg -o ${MULTIPLATFORM_HEADER_DIR} -e ${MULTIPLATFORM_TEMPLATE_DIR} + -t ${TOPICHEADER_TEMP_DIR} -p ${MULTIPLATFORM_PREFIX}) + +## Declare a cpp library +add_library(px4 + src/platforms/ros/px4_ros_impl.cpp + src/platforms/ros/perf_counter.cpp + src/platforms/ros/geo.cpp + src/lib/mathlib/math/Limits.cpp + src/modules/systemlib/circuit_breaker.cpp +) +add_dependencies(px4 ${PROJECT_NAME}_generate_messages_cpp multiplatform_message_headers) + +target_link_libraries(px4 + ${catkin_LIBRARIES} +) + +## Declare a test publisher +add_executable(publisher + src/examples/publisher/publisher_main.cpp + src/examples/publisher/publisher_example.cpp) +add_dependencies(publisher ${PROJECT_NAME}_generate_messages_cpp multiplatform_message_headers) +target_link_libraries(publisher + ${catkin_LIBRARIES} + px4 +) + +## Declare a test subscriber +add_executable(subscriber + src/examples/subscriber/subscriber_main.cpp + src/examples/subscriber/subscriber_example.cpp) +add_dependencies(subscriber ${PROJECT_NAME}_generate_messages_cpp multiplatform_message_headers) +target_link_libraries(subscriber + ${catkin_LIBRARIES} + px4 +) + +## MC Attitude Control +add_executable(mc_att_control + src/modules/mc_att_control_multiplatform/mc_att_control_main.cpp + src/modules/mc_att_control_multiplatform/mc_att_control.cpp + src/modules/mc_att_control_multiplatform/mc_att_control_base.cpp) +add_dependencies(mc_att_control ${PROJECT_NAME}_generate_messages_cpp_cpp) +target_link_libraries(mc_att_control + ${catkin_LIBRARIES} + px4 +) + +## MC Position Control +add_executable(mc_pos_control + src/modules/mc_pos_control_multiplatform/mc_pos_control_main.cpp + src/modules/mc_pos_control_multiplatform/mc_pos_control.cpp) +add_dependencies(mc_pos_control ${PROJECT_NAME}_generate_messages_cpp_cpp) +target_link_libraries(mc_pos_control + ${catkin_LIBRARIES} + px4 +) + +## Attitude Estimator dummy +add_executable(attitude_estimator + src/platforms/ros/nodes/attitude_estimator/attitude_estimator.cpp) +add_dependencies(attitude_estimator ${PROJECT_NAME}_generate_messages_cpp_cpp) +target_link_libraries(attitude_estimator + ${catkin_LIBRARIES} + px4 +) + +## Position Estimator dummy +add_executable(position_estimator + src/platforms/ros/nodes/position_estimator/position_estimator.cpp) +add_dependencies(position_estimator ${PROJECT_NAME}_generate_messages_cpp_cpp) +target_link_libraries(position_estimator + ${catkin_LIBRARIES} + px4 +) + +## Manual input +add_executable(manual_input + src/platforms/ros/nodes/manual_input/manual_input.cpp) +add_dependencies(manual_input ${PROJECT_NAME}_generate_messages_cpp_cpp) +target_link_libraries(manual_input + ${catkin_LIBRARIES} + px4 +) + +## Multicopter Mixer dummy +add_executable(mc_mixer + src/platforms/ros/nodes/mc_mixer/mc_mixer.cpp) +add_dependencies(mc_mixer ${PROJECT_NAME}_generate_messages_cpp_cpp) +target_link_libraries(mc_mixer + ${catkin_LIBRARIES} + px4 +) + +## Commander dummy +add_executable(commander + src/platforms/ros/nodes/commander/commander.cpp) +add_dependencies(commander ${PROJECT_NAME}_generate_messages_cpp_cpp) +target_link_libraries(commander + ${catkin_LIBRARIES} + px4 +) + +## Mavlink dummy +add_executable(mavlink + src/platforms/ros/nodes/mavlink/mavlink.cpp) +add_dependencies(mavlink ${PROJECT_NAME}_generate_messages_cpp_cpp) +target_link_libraries(mavlink + ${catkin_LIBRARIES} + px4 +) + +## Offboard Position Setpoint Demo +add_executable(demo_offboard_position_setpoints + src/platforms/ros/nodes/demo_offboard_position_setpoints/demo_offboard_position_setpoints.cpp) +add_dependencies(demo_offboard_position_setpoints ${PROJECT_NAME}_generate_messages_cpp_cpp) +target_link_libraries(demo_offboard_position_setpoints + ${catkin_LIBRARIES} + px4 +) + +## Offboard Attitude Setpoint Demo +add_executable(demo_offboard_attitude_setpoints + src/platforms/ros/nodes/demo_offboard_attitude_setpoints/demo_offboard_attitude_setpoints.cpp) +add_dependencies(demo_offboard_attitude_setpoints ${PROJECT_NAME}_generate_messages_cpp_cpp) +target_link_libraries(demo_offboard_attitude_setpoints + ${catkin_LIBRARIES} + px4 +) + +############# +## Install ## +############# + +# all install targets should use catkin DESTINATION variables +# See http://ros.org/doc/api/catkin/html/adv_user_guide/variables.html + +## Mark executable scripts (Python etc.) for installation +## in contrast to setup.py, you can choose the destination +# install(PROGRAMS +# scripts/my_python_script +# DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} +# ) + +## Mark executables and/or libraries for installation +install(TARGETS ${PROJECT_NAME} + ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} +) + +## Mark cpp header files for installation +# install(DIRECTORY include/${PROJECT_NAME}/ +# DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION} +# FILES_MATCHING PATTERN "*.h" +# PATTERN ".svn" EXCLUDE +# ) + +## Mark other files for installation (e.g. launch and bag files, etc.) +# install(FILES +# # myfile1 +# # myfile2 +# DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION} +# ) + +############# +## Testing ## +############# + +## Add gtest based cpp test target and link libraries +# catkin_add_gtest(${PROJECT_NAME}-test test/test_px4test.cpp) +# if(TARGET ${PROJECT_NAME}-test) +# target_link_libraries(${PROJECT_NAME}-test ${PROJECT_NAME}) +# endif() + +## Add folders to be run by python nosetests +# catkin_add_nosetests(test) + +## Tests on multiplatform SITL (deprecated) have been moved to POSIX SITL +#if(CATKIN_ENABLE_TESTING) +# find_package(rostest REQUIRED) +# add_rostest(integrationtests/demo_tests/direct_tests.launch) +# add_rostest(integrationtests/demo_tests/mavros_tests.launch) +#endif() diff --git a/integrationtests/run_tests.bash b/integrationtests/run_tests.bash index 61569a1a73..2a3a4c2a0d 100755 --- a/integrationtests/run_tests.bash +++ b/integrationtests/run_tests.bash @@ -5,27 +5,26 @@ # License: according to LICENSE.md in the root directory of the PX4 Firmware repository set -e -# handle cleaning command -do_clean=true -if [ "$1" = "-o" ] +if [ "$#" -lt 1 ] then - echo not cleaning - do_clean=false + echo usage: run_tests.bash firmware_src_dir + echo "" + exit 1 fi -# determine the directory of the source given the directory of this script -pushd `dirname $0` > /dev/null -SCRIPTPATH=`pwd` -popd > /dev/null -ORIG_SRC=$(dirname $SCRIPTPATH) +SRC_DIR=$1 +JOB_DIR=$SRC_DIR/.. +BUILD=posix_sitl_default +# TODO +ROS_TEST_RESULT_DIR=/root/.ros/test_results/px4 +ROS_LOG_DIR=/root/.ros/log +PX4_LOG_DIR=${SRC_DIR}/build_${BUILD}/src/firmware/posix/rootfs/fs/microsd/log +TEST_RESULT_TARGET_DIR=$JOB_DIR/test_results +# BAGS=/root/.ros +# CHARTS=/root/.ros/charts +# EXPORT_CHARTS=/sitl/testing/export_charts.py -# set paths -JOB_DIR=$(dirname $ORIG_SRC) -CATKIN_DIR=$JOB_DIR/catkin -BUILD_DIR=$CATKIN_DIR/build/px4 -SRC_DIR=${CATKIN_DIR}/src/px4 - -echo setting up ROS paths +# source ROS env if [ -f /opt/ros/indigo/setup.bash ] then source /opt/ros/indigo/setup.bash @@ -36,57 +35,26 @@ else echo "could not find /opt/ros/{ros-distro}/setup.bash" exit 1 fi -export ROS_HOME=$JOB_DIR/.ros -export ROS_LOG_DIR=$ROS_HOME/log -export ROS_TEST_RESULT_DIR=$ROS_HOME/test_results/px4 +source $SRC_DIR/integrationtests/setup_gazebo_ros.bash $SRC_DIR -PX4_LOG_DIR=$ROS_HOME/rootfs/fs/microsd/log -TEST_RESULT_TARGET_DIR=$JOB_DIR/test_results - -# TODO -# BAGS=$ROS_HOME -# CHARTS=$ROS_HOME/charts -# EXPORT_CHARTS=/sitl/testing/export_charts.py - -echo setting up gazebo paths -source /usr/share/gazebo/setup.sh -source $SCRIPTPATH/setup_gazebo_ros.bash ${SRC_DIR} ${BUILD_DIR} - -if $do_clean -then - echo cleaning - rm -rf $CATKIN_DIR - rm -rf $ROS_HOME - rm -rf $TEST_RESULT_TARGET_DIR -else - echo skipping clean step +echo "deleting previous test results ($TEST_RESULT_TARGET_DIR)" +if [ -d ${TEST_RESULT_TARGET_DIR} ]; then + rm -r ${TEST_RESULT_TARGET_DIR} fi +# FIXME: Firmware compilation seems to CD into this directory (/root/Firmware) +# when run from "run_container.bash". Why? +if [ -d /root/Firmware ]; then + rm /root/Firmware +fi +ln -s ${SRC_DIR} /root/Firmware + echo "=====> compile ($SRC_DIR)" -mkdir -p $ROS_HOME -mkdir -p $CATKIN_DIR/src -mkdir -p $TEST_RESULT_TARGET_DIR -if ! [ -d $SRC_DIR ] -then - ln -s $ORIG_SRC $SRC_DIR - ln -s $ORIG_SRC/Tools/sitl_gazebo ${CATKIN_DIR}/src/mavlink_sitl_gazebo -fi -cd $CATKIN_DIR -catkin_make -. ./devel/setup.bash +cd $SRC_DIR +make ${BUILD} +make --no-print-directory gazebo_build echo "<=====" -# print paths to user -echo -e "JOB_DIR\t\t: $JOB_DIR" -echo -e "ROS_HOME\t: $ROS_HOME" -echo -e "CATKIN_DIR\t: $CATKIN_DIR" -echo -e "BUILD_DIR\t: $BUILD_DIR" -echo -e "SRC_DIR\t\t: $SRC_DIR" -echo -e "ROS_TEST_RESULT_DIR\t: $ROS_TEST_RESULT_DIR" -echo -e "ROS_LOG_DIR\t\t: $ROS_LOG_DIR" -echo -e "PX4_LOG_DIR\t\t: $PX4_LOG_DIR" -echo -e "TEST_RESULT_TARGET_DIR\t: $TEST_RESULT_TARGET_DIR" - # don't exit on error anymore from here on (because single tests or exports might fail) set +e echo "=====> run tests" @@ -105,6 +73,7 @@ echo "=====> process test results" # done echo "copy build test results to job directory" +mkdir -p ${TEST_RESULT_TARGET_DIR} cp -r $ROS_TEST_RESULT_DIR/* ${TEST_RESULT_TARGET_DIR} cp -r $ROS_LOG_DIR/* ${TEST_RESULT_TARGET_DIR} cp -r $PX4_LOG_DIR/* ${TEST_RESULT_TARGET_DIR} diff --git a/integrationtests/setup_gazebo_ros.bash b/integrationtests/setup_gazebo_ros.bash index 8cc4a5c58b..6c22bbe192 100755 --- a/integrationtests/setup_gazebo_ros.bash +++ b/integrationtests/setup_gazebo_ros.bash @@ -4,24 +4,19 @@ # # License: according to LICENSE.md in the root directory of the PX4 Firmware repository -if [ "$#" != 2 ] +if [ "$#" -lt 1 ] then - echo usage: source setup_gazebo_ros.bash src_dir build_dir + echo usage: source setup_gazebo_ros.bash firmware_src_dir echo "" return 1 fi SRC_DIR=$1 -BUILD_DIR=$2 # setup Gazebo env and update package path -export GAZEBO_RESOURCE_PATH=${SRC_DIR}/Tools/sitl_gazebo:${GAZEBO_RESOURCE_PATH} -export GAZEBO_MODEL_PATH=${SRC_DIR}/Tools/sitl_gazebo/models:${GAZEBO_MODEL_PATH} -export GAZEBO_PLUGIN_PATH=${BUILD_DIR}/build_gazebo:${GAZEBO_PLUGIN_PATH} -export LD_LIBRARY_PATH=${SRC_DIR}/Tools/sitl_gazebo/Build/msgs/:${BUILD_DIR}/build_gazebo:${LD_LIBRARY_PATH}: +export GAZEBO_MODEL_PATH=${GAZEBO_MODEL_PATH}:${SRC_DIR}/Tools/sitl_gazebo/models +export GAZEBO_PLUGIN_PATH=${SRC_DIR}/build_gazebo:${GAZEBO_PLUGIN_PATH} +export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${SRC_DIR}/Tools/sitl_gazebo/Build/msgs/ +export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:${SRC_DIR} export GAZEBO_MODEL_DATABASE_URI="" - -echo -e "GAZEBO_RESOURCE_PATH $GAZEBO_RESOURCE_PATH" -echo -e "GAZEBO_MODEL_PATH $GAZEBO_MODEL_PATH" -echo -e "GAZEBO_PLUGIN_PATH $GAZEBO_PLUGIN_PATH" -echo -e "LD_LIBRARY_PATH $LD_LIBRARY_PATH" +export SITL_GAZEBO_PATH=$SRC_DIR/Tools/sitl_gazebo diff --git a/launch/mavros_posix_sitl.launch b/launch/mavros_posix_sitl.launch index 29793e10f8..558f3bbadb 100644 --- a/launch/mavros_posix_sitl.launch +++ b/launch/mavros_posix_sitl.launch @@ -1,25 +1,18 @@ - - - - - - + - - - + @@ -29,5 +22,3 @@ - - diff --git a/launch/mavros_posix_tests_iris.launch b/launch/mavros_posix_tests_iris.launch index 8112f6f1f6..235acda6f2 100644 --- a/launch/mavros_posix_tests_iris.launch +++ b/launch/mavros_posix_tests_iris.launch @@ -9,7 +9,6 @@ - diff --git a/launch/mavros_posix_tests_standard_vtol.launch b/launch/mavros_posix_tests_standard_vtol.launch index b20f4801c4..d5aa9e285e 100644 --- a/launch/mavros_posix_tests_standard_vtol.launch +++ b/launch/mavros_posix_tests_standard_vtol.launch @@ -9,7 +9,7 @@ - + diff --git a/launch/posix_sitl.launch b/launch/posix_sitl.launch index 6c2d2da649..9895ee9d43 100644 --- a/launch/posix_sitl.launch +++ b/launch/posix_sitl.launch @@ -1,31 +1,19 @@ - - - - - - + - + + - + - - - - - - diff --git a/posix-configs/SITL/README.md b/posix-configs/SITL/README.md index a98a6515fa..2588c4b09b 100644 --- a/posix-configs/SITL/README.md +++ b/posix-configs/SITL/README.md @@ -105,5 +105,5 @@ param set RC_MAP_POSCTL_SW 7 param set RC_MAP_RETURN_SW 8 param set MC_PITCHRATE_P 0.05 param set MC_ROLLRATE_P 0.05 -mixer load /dev/pwm_output0 ROMFS/px4fmu_common/mixers/quad_x.main.mix +mixer load /dev/pwm_output0 ../../ROMFS/px4fmu_common/mixers/quad_x.main.mix ``` diff --git a/posix-configs/SITL/init/rcS_gazebo_iris b/posix-configs/SITL/init/rcS_gazebo_iris index 6b93b86c2e..d985929601 100644 --- a/posix-configs/SITL/init/rcS_gazebo_iris +++ b/posix-configs/SITL/init/rcS_gazebo_iris @@ -60,7 +60,7 @@ navigator start ekf2 start mc_pos_control start mc_att_control start -mixer load /dev/pwm_output0 ROMFS/px4fmu_common/mixers/quad_w.main.mix +mixer load /dev/pwm_output0 ../../../../ROMFS/px4fmu_common/mixers/quad_w.main.mix mavlink start -u 14556 -r 4000000 mavlink start -u 14557 -r 4000000 -m onboard -o 14540 mavlink stream -r 50 -s POSITION_TARGET_LOCAL_NED -u 14556 diff --git a/posix-configs/SITL/init/rcS_gazebo_iris_opt_flow b/posix-configs/SITL/init/rcS_gazebo_iris_opt_flow index 44060e1b52..2be4900b81 100644 --- a/posix-configs/SITL/init/rcS_gazebo_iris_opt_flow +++ b/posix-configs/SITL/init/rcS_gazebo_iris_opt_flow @@ -59,7 +59,7 @@ attitude_estimator_q start position_estimator_inav start mc_pos_control start mc_att_control start -mixer load /dev/pwm_output0 ROMFS/px4fmu_common/mixers/quad_w.main.mix +mixer load /dev/pwm_output0 ../../../../ROMFS/px4fmu_common/mixers/quad_w.main.mix mavlink start -u 14556 -r 2000000 mavlink start -u 14557 -r 2000000 -m onboard -o 14540 mavlink stream -r 80 -s POSITION_TARGET_LOCAL_NED -u 14556 diff --git a/posix-configs/SITL/init/rcS_gazebo_plane b/posix-configs/SITL/init/rcS_gazebo_plane index bc837d2acd..b4f40ce2dd 100644 --- a/posix-configs/SITL/init/rcS_gazebo_plane +++ b/posix-configs/SITL/init/rcS_gazebo_plane @@ -47,7 +47,7 @@ ekf2 start fw_pos_control_l1 start fw_att_control start land_detector start fixedwing -mixer load /dev/pwm_output0 ROMFS/sitl/mixers/plane_sitl.main.mix +mixer load /dev/pwm_output0 ../../../../ROMFS/sitl/mixers/plane_sitl.main.mix mavlink start -u 14556 -r 2000000 mavlink start -u 14557 -r 2000000 -m onboard -o 14540 mavlink stream -r 80 -s POSITION_TARGET_LOCAL_NED -u 14556 diff --git a/posix-configs/SITL/init/rcS_gazebo_solo b/posix-configs/SITL/init/rcS_gazebo_solo index 8701609064..008261b6ec 100644 --- a/posix-configs/SITL/init/rcS_gazebo_solo +++ b/posix-configs/SITL/init/rcS_gazebo_solo @@ -57,7 +57,7 @@ navigator start ekf2 start mc_pos_control start mc_att_control start -mixer load /dev/pwm_output0 ROMFS/px4fmu_common/mixers/quad_x.main.mix +mixer load /dev/pwm_output0 ../../../../ROMFS/px4fmu_common/mixers/quad_x.main.mix mavlink start -u 14556 -r 4000000 mavlink start -u 14557 -r 4000000 -m onboard -o 14540 mavlink stream -r 50 -s POSITION_TARGET_LOCAL_NED -u 14556 diff --git a/posix-configs/SITL/init/rcS_gazebo_standard_vtol b/posix-configs/SITL/init/rcS_gazebo_standard_vtol index d90ddfa891..a1f448bb58 100644 --- a/posix-configs/SITL/init/rcS_gazebo_standard_vtol +++ b/posix-configs/SITL/init/rcS_gazebo_standard_vtol @@ -69,7 +69,7 @@ mc_pos_control start mc_att_control start fw_pos_control_l1 start fw_att_control start -mixer load /dev/pwm_output0 ROMFS/sitl/mixers/standard_vtol_sitl.main.mix +mixer load /dev/pwm_output0 ../../../../ROMFS/sitl/mixers/standard_vtol_sitl.main.mix mavlink start -u 14556 -r 2000000 mavlink start -u 14557 -r 2000000 -m onboard -o 14540 mavlink stream -r 80 -s POSITION_TARGET_LOCAL_NED -u 14556 diff --git a/posix-configs/SITL/init/rcS_gazebo_tailsitter b/posix-configs/SITL/init/rcS_gazebo_tailsitter index 04d3a2b2f2..2ba72c5b8c 100644 --- a/posix-configs/SITL/init/rcS_gazebo_tailsitter +++ b/posix-configs/SITL/init/rcS_gazebo_tailsitter @@ -60,7 +60,7 @@ mc_pos_control start mc_att_control start fw_pos_control_l1 start fw_att_control start -mixer load /dev/pwm_output0 ROMFS/px4fmu_common/mixers/quad_x_vtol.main.mix +mixer load /dev/pwm_output0 ../../../../ROMFS/px4fmu_common/mixers/quad_x_vtol.main.mix mavlink start -u 14556 -r 2000000 mavlink start -u 14557 -r 2000000 -m onboard -o 14540 mavlink stream -r 80 -s POSITION_TARGET_LOCAL_NED -u 14556 diff --git a/posix-configs/SITL/init/rcS_gazebo_typhoon_h480 b/posix-configs/SITL/init/rcS_gazebo_typhoon_h480 index 8713c62f74..87c620c750 100644 --- a/posix-configs/SITL/init/rcS_gazebo_typhoon_h480 +++ b/posix-configs/SITL/init/rcS_gazebo_typhoon_h480 @@ -59,7 +59,7 @@ navigator start ekf2 start mc_pos_control start mc_att_control start -mixer load /dev/pwm_output0 ROMFS/px4fmu_common/mixers/hexa_x.main.mix +mixer load /dev/pwm_output0 ../../../../ROMFS/px4fmu_common/mixers/hexa_x.main.mix mavlink start -u 14556 -r 4000000 mavlink start -u 14557 -r 4000000 -m onboard -o 14540 mavlink stream -r 50 -s POSITION_TARGET_LOCAL_NED -u 14556 diff --git a/posix-configs/SITL/init/rcS_jmavsim_iris b/posix-configs/SITL/init/rcS_jmavsim_iris index 64cf0a19a1..26db22d8f0 100644 --- a/posix-configs/SITL/init/rcS_jmavsim_iris +++ b/posix-configs/SITL/init/rcS_jmavsim_iris @@ -61,7 +61,7 @@ navigator start ekf2 start mc_pos_control start mc_att_control start -mixer load /dev/pwm_output0 ROMFS/px4fmu_common/mixers/quad_x.main.mix +mixer load /dev/pwm_output0 ../../../../ROMFS/px4fmu_common/mixers/quad_x.main.mix mavlink start -u 14556 -r 2000000 mavlink start -u 14557 -r 2000000 -m onboard -o 14540 mavlink stream -r 80 -s POSITION_TARGET_LOCAL_NED -u 14556 diff --git a/posix-configs/SITL/init/rcS_lpe_gazebo_iris b/posix-configs/SITL/init/rcS_lpe_gazebo_iris index 59b11d1c5e..9c84018e98 100644 --- a/posix-configs/SITL/init/rcS_lpe_gazebo_iris +++ b/posix-configs/SITL/init/rcS_lpe_gazebo_iris @@ -60,7 +60,7 @@ attitude_estimator_q start local_position_estimator start mc_pos_control start mc_att_control start -mixer load /dev/pwm_output0 ROMFS/px4fmu_common/mixers/quad_w.main.mix +mixer load /dev/pwm_output0 /usr/share/px4/ROMFS/px4fmu_common/mixers/quad_w.main.mix mavlink start -u 14556 -r 4000000 mavlink start -u 14557 -r 4000000 -m onboard -o 14540 mavlink stream -r 50 -s POSITION_TARGET_LOCAL_NED -u 14556 diff --git a/posix-configs/SITL/init/rcS_lpe_gazebo_iris_opt_flow b/posix-configs/SITL/init/rcS_lpe_gazebo_iris_opt_flow index 759831595a..c1a6a2eae5 100644 --- a/posix-configs/SITL/init/rcS_lpe_gazebo_iris_opt_flow +++ b/posix-configs/SITL/init/rcS_lpe_gazebo_iris_opt_flow @@ -69,7 +69,7 @@ attitude_estimator_q start local_position_estimator start mc_pos_control start mc_att_control start -mixer load /dev/pwm_output0 ROMFS/px4fmu_common/mixers/quad_w.main.mix +mixer load /dev/pwm_output0 /usr/share/px4/ROMFS/px4fmu_common/mixers/quad_w.main.mix mavlink start -u 14556 -r 2000000 mavlink start -u 14557 -r 2000000 -m onboard -o 14540 mavlink stream -r 80 -s POSITION_TARGET_LOCAL_NED -u 14556 diff --git a/posix-configs/SITL/init/rcS_lpe_jmavsim_iris b/posix-configs/SITL/init/rcS_lpe_jmavsim_iris index 286cb13f9c..106d032275 100644 --- a/posix-configs/SITL/init/rcS_lpe_jmavsim_iris +++ b/posix-configs/SITL/init/rcS_lpe_jmavsim_iris @@ -61,7 +61,7 @@ attitude_estimator_q start local_position_estimator start mc_pos_control start mc_att_control start -mixer load /dev/pwm_output0 ROMFS/px4fmu_common/mixers/quad_x.main.mix +mixer load /dev/pwm_output0 /usr/share/px4/ROMFS/px4fmu_common/mixers/quad_x.main.mix mavlink start -u 14556 -r 2000000 mavlink start -u 14557 -r 2000000 -m onboard -o 14540 mavlink stream -r 80 -s POSITION_TARGET_LOCAL_NED -u 14556 diff --git a/posix-configs/SITL/init/rcS_tests_none_iris b/posix-configs/SITL/init/rcS_tests similarity index 100% rename from posix-configs/SITL/init/rcS_tests_none_iris rename to posix-configs/SITL/init/rcS_tests diff --git a/posix-configs/SITL/init/rc_iris_ros b/posix-configs/SITL/init/rc_iris_ros index 2aa41cdbc8..ca1cf0961e 100644 --- a/posix-configs/SITL/init/rc_iris_ros +++ b/posix-configs/SITL/init/rc_iris_ros @@ -60,7 +60,7 @@ attitude_estimator_q start position_estimator_inav start mc_pos_control_m start mc_att_control_m start -mixer load /dev/pwm_output0 ROMFS/px4fmu_common/mixers/quad_x.main.mix +mixer load /dev/pwm_output0 ../../../../ROMFS/px4fmu_common/mixers/quad_x.main.mix mavlink start -u 14556 -r 2000000 mavlink stream -r 80 -s POSITION_TARGET_LOCAL_NED -u 14556 mavlink stream -r 80 -s LOCAL_POSITION_NED -u 14556 diff --git a/src/firmware/nuttx/CMakeLists.txt b/src/firmware/nuttx/CMakeLists.txt index 4d27d2758b..53988b43cf 100644 --- a/src/firmware/nuttx/CMakeLists.txt +++ b/src/firmware/nuttx/CMakeLists.txt @@ -10,7 +10,7 @@ add_executable(firmware_nuttx builtin_commands.c) -set(nuttx_export_dir ${PX4_BINARY_DIR}/${BOARD}/NuttX/nuttx-export) +set(nuttx_export_dir ${CMAKE_BINARY_DIR}/${BOARD}/NuttX/nuttx-export) set(link_libs romfs apps nuttx m gcc @@ -20,7 +20,7 @@ if(NOT ${BOARD} STREQUAL "sim") list(APPEND link_libs nosys) set(main_link_flags "-T${nuttx_export_dir}/build/ld.script" - "-Wl,-Map=${PX4_BINARY_DIR}/${BOARD}/main.map" + "-Wl,-Map=${CMAKE_BINARY_DIR}/${BOARD}/main.map" ) px4_join(OUT main_link_flags LIST ${main_link_flags} GLUE " ") set_target_properties(firmware_nuttx PROPERTIES LINK_FLAGS ${main_link_flags}) @@ -43,12 +43,12 @@ add_custom_target(check_weak if(NOT ${BOARD} STREQUAL "sim") if (config_io_board) - set(extras "${PX4_BINARY_DIR}/src/modules/px4iofirmware/${config_io_board}.bin") + set(extras "${CMAKE_BINARY_DIR}/src/modules/px4iofirmware/${config_io_board}.bin") endif() set(romfs_dir "ROMFS/px4fmu_common") if (${BOARD} STREQUAL "tap-v1") - set(romfs_dir "ROMFS/tap_common") + set(romfs_dir "ROMFS/tap_common") endif() if (${BOARD} STREQUAL "px4fmu-v2" AND ${LABEL} STREQUAL "test") set(romfs_dir "ROMFS/px4fmu_test") @@ -68,8 +68,8 @@ if(NOT ${BOARD} STREQUAL "sim") px4_nuttx_add_firmware(OUT ${fw_file} BOARD ${BOARD} EXE ${CMAKE_CURRENT_BINARY_DIR}/firmware_nuttx - PARAM_XML ${PX4_BINARY_DIR}/parameters.xml - AIRFRAMES_XML ${PX4_BINARY_DIR}/airframes.xml + PARAM_XML ${CMAKE_BINARY_DIR}/parameters.xml + AIRFRAMES_XML ${CMAKE_BINARY_DIR}/airframes.xml ) configure_file(gdbinit.in .gdbinit) @@ -94,21 +94,21 @@ if(NOT ${BOARD} STREQUAL "sim") add_custom_target(debug_io COMMAND ${GDB} - ${PX4_BINARY_DIR}/src/modules/px4iofirmware/${config_io_board} + ${CMAKE_BINARY_DIR}/src/modules/px4iofirmware/${config_io_board} DEPENDS firmware_nuttx ${CMAKE_CURRENT_BINARY_DIR}/.gdbinit ) add_custom_target(debug_io_tui COMMAND ${GDBTUI} - ${PX4_BINARY_DIR}/src/modules/px4iofirmware/${config_io_board} + ${CMAKE_BINARY_DIR}/src/modules/px4iofirmware/${config_io_board} DEPENDS firmware_nuttx ${CMAKE_CURRENT_BINARY_DIR}/.gdbinit ) add_custom_target(debug_io_ddd COMMAND ${DDD} --debugger ${GDB} - ${PX4_BINARY_DIR}/src/modules/px4iofirmware/${config_io_board} + ${CMAKE_BINARY_DIR}/src/modules/px4iofirmware/${config_io_board} DEPENDS firmware_nuttx ${CMAKE_CURRENT_BINARY_DIR}/.gdbinit ) diff --git a/src/firmware/nuttx/gdbinit.in b/src/firmware/nuttx/gdbinit.in index fd1b1c451e..e820673b21 100644 --- a/src/firmware/nuttx/gdbinit.in +++ b/src/firmware/nuttx/gdbinit.in @@ -4,4 +4,4 @@ attach 1 monitor vector_catch disable hard set mem inaccessible-by-default off set print pretty -source ${PX4_SOURCE_DIR}/Debug/PX4 +source ${CMAKE_SOURCE_DIR}/Debug/PX4 diff --git a/src/firmware/posix/CMakeLists.txt b/src/firmware/posix/CMakeLists.txt index 58ab449b5a..3e8e8b5227 100644 --- a/src/firmware/posix/CMakeLists.txt +++ b/src/firmware/posix/CMakeLists.txt @@ -18,7 +18,7 @@ if ("${BOARD}" STREQUAL "eagle" OR ("${BOARD}" STREQUAL "excelsior")) APPS_DEST "/home/linaro" SOURCES px4muorb_stub.c - ${PX4_SOURCE_DIR}/src/platforms/posix/main.cpp + ${CMAKE_SOURCE_DIR}/src/platforms/posix/main.cpp apps.h LINK_LIBS -Wl,--start-group @@ -33,14 +33,14 @@ if ("${BOARD}" STREQUAL "eagle" OR ("${BOARD}" STREQUAL "excelsior")) OS ${OS} BOARD ${BOARD} FILES ${CMAKE_CURRENT_BINARY_DIR}/px4 - ${PX4_SOURCE_DIR}/posix-configs/eagle/flight/mainapp.config + ${CMAKE_SOURCE_DIR}/posix-configs/eagle/flight/mainapp.config DEPENDS px4 DEST /home/linaro) elseif ("${BOARD}" STREQUAL "rpi") add_executable(px4 - ${PX4_SOURCE_DIR}/src/platforms/posix/main.cpp + ${CMAKE_SOURCE_DIR}/src/platforms/posix/main.cpp apps.h ) @@ -57,7 +57,7 @@ elseif ("${BOARD}" STREQUAL "rpi") OS ${OS} BOARD ${BOARD} FILES ${CMAKE_CURRENT_BINARY_DIR}/px4 - ${PX4_SOURCE_DIR}/posix-configs/rpi/px4.config + ${CMAKE_SOURCE_DIR}/posix-configs/rpi/px4.config DEPENDS px4 DEST /home/pi) @@ -67,7 +67,7 @@ elseif ("${BOARD}" STREQUAL "bebop") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static") add_executable(px4 - ${PX4_SOURCE_DIR}/src/platforms/posix/main.cpp + ${CMAKE_SOURCE_DIR}/src/platforms/posix/main.cpp apps.h ) @@ -91,14 +91,14 @@ elseif ("${BOARD}" STREQUAL "bebop") OS ${OS} BOARD ${BOARD} FILES ${CMAKE_CURRENT_BINARY_DIR}/px4 - ${PX4_SOURCE_DIR}/posix-configs/bebop/px4.config + ${CMAKE_SOURCE_DIR}/posix-configs/bebop/px4.config DEPENDS px4 DEST /usr/bin) else() add_executable(px4 - ${PX4_SOURCE_DIR}/src/platforms/posix/main.cpp + ${CMAKE_SOURCE_DIR}/src/platforms/posix/main.cpp apps.h ) if (NOT APPLE) @@ -118,43 +118,17 @@ else() endif() endif() -#============================================================================= -# sitl run targets -# - -set(SITL_WORKING_DIR ${PX4_BINARY_DIR}/tmp) -file(MAKE_DIRECTORY ${SITL_WORKING_DIR}) - add_custom_target(run_config - COMMAND Tools/sitl_run.sh - "$" - "${config_sitl_rcS}" - "${config_sitl_debugger}" - "${config_sitl_viewer}" - "${config_sitl_model}" - "${PX4_SOURCE_DIR}" - "${PX4_BINARY_DIR}" - WORKING_DIRECTORY ${SITL_WORKING_DIR} + COMMAND Tools/sitl_run.sh "${config_sitl_rcS}" "${config_sitl_debugger}" + "${config_sitl_viewer}" "${config_sitl_model}" "${CMAKE_BINARY_DIR}" + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} USES_TERMINAL ) add_dependencies(run_config px4) -# project to build sitl_gazebo if necessary -ExternalProject_Add(sitl_gazebo - SOURCE_DIR ${PX4_SOURCE_DIR}/Tools/sitl_gazebo - CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} - BINARY_DIR ${PX4_BINARY_DIR}/build_gazebo - INSTALL_COMMAND "" - ) -set_target_properties(sitl_gazebo PROPERTIES EXCLUDE_FROM_ALL TRUE) - -# create targets for each viewer/model/debugger combination -set(viewers none jmavsim gazebo replay) -set(debuggers none gdb lldb ddd valgrind) -set(models none iris iris_opt_flow tailsitter standard_vtol plane solo typhoon_h480) -foreach(viewer ${viewers}) - foreach(debugger ${debuggers}) - foreach(model ${models}) +foreach(viewer none jmavsim gazebo replay) + foreach(debugger none gdb lldb ddd valgrind) + foreach(model none iris iris_opt_flow tailsitter standard_vtol plane solo typhoon_h480) if (debugger STREQUAL "none") if (model STREQUAL "none") set(_targ_name "${viewer}") @@ -169,20 +143,13 @@ foreach(viewer ${viewers}) endif() endif() add_custom_target(${_targ_name} - COMMAND ${PX4_SOURCE_DIR}/Tools/sitl_run.sh - $ - ${config_sitl_rcS} - ${debugger} - ${viewer} - ${model} - ${PX4_SOURCE_DIR} - ${PX4_BINARY_DIR} - WORKING_DIRECTORY ${SITL_WORKING_DIR} + COMMAND Tools/sitl_run.sh "${config_sitl_rcS}" + "${debugger}" + "${viewer}" "${model}" "${CMAKE_BINARY_DIR}" + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} USES_TERMINAL ) - if (viewer STREQUAL "gazebo") - add_dependencies(${_targ_name} sitl_gazebo) - endif() + add_dependencies(${_targ_name} px4) endforeach() endforeach() endforeach() @@ -191,25 +158,8 @@ endforeach() # install # -install(TARGETS px4 DESTINATION ${CMAKE_INSTALL_BINDIR}) +install(TARGETS px4 DESTINATION bin) install(DIRECTORY ${PROJECT_SOURCE_DIR}/ROMFS DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}) install(DIRECTORY ${PROJECT_SOURCE_DIR}/posix-configs DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}) -#============================================================================= -# tests -# - -add_test(NAME rcS_tests - COMMAND ${PX4_SOURCE_DIR}/Tools/sitl_run.sh - $ - posix-configs/SITL/init/rcS_tests - none - none - none - ${PX4_SOURCE_DIR} - ${PX4_BINARY_DIR} - WORKING_DIRECTORY ${SITL_WORKING_DIR}) -set_tests_properties(rcS_tests PROPERTIES - PASS_REGULAR_EXPRESSION "All tests passed") - # vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/firmware/qurt/CMakeLists.txt b/src/firmware/qurt/CMakeLists.txt index 2e30c6aa8d..81be14afc5 100644 --- a/src/firmware/qurt/CMakeLists.txt +++ b/src/firmware/qurt/CMakeLists.txt @@ -1,4 +1,4 @@ -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PX4_SOURCE_DIR}/cmake/cmake_hexagon") +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/cmake_hexagon") include(fastrpc) include(qurt_lib) @@ -7,7 +7,7 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR}) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-missing-prototypes") px4_qurt_generate_builtin_commands( - OUT ${PX4_BINARY_DIR}/apps.h + OUT ${CMAKE_BINARY_DIR}/apps.h MODULE_LIST ${module_libraries}) FASTRPC_STUB_GEN(px4muorb.idl) @@ -20,8 +20,8 @@ if ("${QURT_ENABLE_STUBS}" STREQUAL "1") ${FASTRPC_DSP_INCLUDES} ) add_executable(px4 - ${PX4_BINARY_DIR}/src/firmware/qurt/px4muorb_skel.c - ${PX4_BINARY_DIR}/apps.h) + ${CMAKE_BINARY_DIR}/src/firmware/qurt/px4muorb_skel.c + ${CMAKE_BINARY_DIR}/apps.h) target_link_libraries(px4 -Wl,--start-group @@ -40,7 +40,7 @@ else() QURT_LIB(LIB_NAME px4 IDL_NAME px4muorb SOURCES - ${PX4_BINARY_DIR}/apps.h + ${CMAKE_BINARY_DIR}/apps.h LINK_LIBS ${module_libraries} ${target_libraries} @@ -54,7 +54,7 @@ else() BOARD ${BOARD} FILES ${CMAKE_CURRENT_BINARY_DIR}/libpx4.so ${CMAKE_CURRENT_BINARY_DIR}/libpx4muorb_skel.so - ${PX4_SOURCE_DIR}/posix-configs/eagle/flight/px4.config + ${CMAKE_SOURCE_DIR}/posix-configs/eagle/flight/px4.config DEPENDS px4 px4muorb_skel DEST /usr/share/data/adsp) endif() diff --git a/src/lib/rc/rc_tests/CMakeLists.txt b/src/lib/rc/rc_tests/CMakeLists.txt index 8a5be79ec2..42a5a1b1ba 100644 --- a/src/lib/rc/rc_tests/CMakeLists.txt +++ b/src/lib/rc/rc_tests/CMakeLists.txt @@ -40,5 +40,4 @@ px4_add_module( DEPENDS platforms__common ) - # vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/lib/rc/rc_tests/RCTest.cpp b/src/lib/rc/rc_tests/RCTest.cpp index 14119835f5..d7a834d5c8 100644 --- a/src/lib/rc/rc_tests/RCTest.cpp +++ b/src/lib/rc/rc_tests/RCTest.cpp @@ -16,7 +16,7 @@ #if !defined(CONFIG_ARCH_BOARD_SITL) #define TEST_DATA_PATH "/fs/microsd" #else -#define TEST_DATA_PATH "./src/lib/rc/rc_tests/test_data/" +#define TEST_DATA_PATH "../../../../src/lib/rc/rc_tests/test_data/" #endif extern "C" __EXPORT int rc_tests_main(int argc, char *argv[]); @@ -51,8 +51,8 @@ bool RCTest::dsmTest(void) FILE *fp; fp = fopen(filepath, "rt"); - warnx("loading data from: %s", filepath); ut_test(fp != nullptr); + //warnx("loading data from: %s", filepath); float f; unsigned x; diff --git a/src/modules/muorb/krait/CMakeLists.txt b/src/modules/muorb/krait/CMakeLists.txt index ad05492026..b9e054e3e7 100644 --- a/src/modules/muorb/krait/CMakeLists.txt +++ b/src/modules/muorb/krait/CMakeLists.txt @@ -30,10 +30,10 @@ # POSSIBILITY OF SUCH DAMAGE. # ############################################################################ -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PX4_SOURCE_DIR}/cmake/cmake_hexagon") +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/cmake_hexagon") include(hexagon_sdk) -include_directories(${PX4_BINARY_DIR}/src/firmware/posix) +include_directories(${CMAKE_BINARY_DIR}/src/firmware/posix) include_directories(${HEXAGON_SDK_INCLUDES}) px4_add_module( diff --git a/src/modules/param/CMakeLists.txt b/src/modules/param/CMakeLists.txt index 3f64a9826c..b3148baab1 100644 --- a/src/modules/param/CMakeLists.txt +++ b/src/modules/param/CMakeLists.txt @@ -34,8 +34,8 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR}) px4_generate_parameters_source(OUT param_files - XML ${PX4_BINARY_DIR}/parameters.xml - SCOPE ${PX4_SOURCE_DIR}/cmake/configs/${OS}_${BOARD}_${LABEL}.cmake + XML ${CMAKE_BINARY_DIR}/parameters.xml + SCOPE ${CMAKE_SOURCE_DIR}/cmake/configs/${OS}_${BOARD}_${LABEL}.cmake DEPS xml_gen ) diff --git a/src/modules/px4iofirmware/CMakeLists.txt b/src/modules/px4iofirmware/CMakeLists.txt index 67183999eb..ab2778711c 100644 --- a/src/modules/px4iofirmware/CMakeLists.txt +++ b/src/modules/px4iofirmware/CMakeLists.txt @@ -63,7 +63,7 @@ px4_join(OUT CMAKE_CXX_FLAGS LIST "${cxx_flags}" GLUE " ") include_directories( ${include_dirs} - ${PX4_BINARY_DIR}/src/modules/systemlib/mixer + ${CMAKE_BINARY_DIR}/src/modules/systemlib/mixer . ) link_directories(${link_dirs}) @@ -117,10 +117,10 @@ add_dependencies(${fw_io_name} mixer_gen ) -set(nuttx_export_dir ${PX4_BINARY_DIR}/${config_io_board}/NuttX/nuttx-export) +set(nuttx_export_dir ${CMAKE_BINARY_DIR}/${config_io_board}/NuttX/nuttx-export) set(main_link_flags "-T${nuttx_export_dir}/build/ld.script" - "-Wl,-Map=${PX4_BINARY_DIR}/${config_io_board}/main.map" + "-Wl,-Map=${CMAKE_BINARY_DIR}/${config_io_board}/main.map" ) px4_join(OUT main_link_flags LIST ${main_link_flags} GLUE " ") set_target_properties(${fw_io_name} PROPERTIES LINK_FLAGS ${main_link_flags}) diff --git a/src/modules/systemlib/CMakeLists.txt b/src/modules/systemlib/CMakeLists.txt index 91f405d605..7277ee3ca1 100644 --- a/src/modules/systemlib/CMakeLists.txt +++ b/src/modules/systemlib/CMakeLists.txt @@ -32,7 +32,7 @@ ############################################################################ # for generated files -include_directories(${PX4_BINARY_DIR}/src/modules/param) +include_directories(${CMAKE_BINARY_DIR}/src/modules/param) set(SRCS perf_counter.c diff --git a/src/modules/uavcan/uavcan_servers.hpp b/src/modules/uavcan/uavcan_servers.hpp index 47131f2ec6..17e94cd311 100644 --- a/src/modules/uavcan/uavcan_servers.hpp +++ b/src/modules/uavcan/uavcan_servers.hpp @@ -70,7 +70,7 @@ /** * A UAVCAN Server Sub node. */ -class __EXPORT UavcanServers +class UavcanServers { static constexpr unsigned NumIfaces = 1; // UAVCAN_STM32_NUM_IFACES diff --git a/src/platforms/posix/main.cpp b/src/platforms/posix/main.cpp index ac0520c858..646b94610f 100644 --- a/src/platforms/posix/main.cpp +++ b/src/platforms/posix/main.cpp @@ -50,7 +50,6 @@ #include "px4_middleware.h" #include "DriverFramework.hpp" #include -#include namespace px4 { @@ -63,12 +62,6 @@ typedef int (*px4_main_t)(int argc, char *argv[]); #define CMD_BUFF_SIZE 100 -#ifdef PATH_MAX -const unsigned path_max_len = PATH_MAX; -#else -const unsigned path_max_len = 1024; -#endif - static bool _ExitFlag = false; static struct termios orig_term; @@ -92,96 +85,6 @@ extern "C" { } } -static inline bool fileExists(const string &name) -{ - struct stat buffer; - return (stat(name.c_str(), &buffer) == 0); -} - -static inline bool dirExists(const string &path) -{ - struct stat info; - - if (stat(path.c_str(), &info) != 0) { - return false; - - } else if (info.st_mode & S_IFDIR) { - return true; - - } else { - return false; - } -} - -static inline void touch(const string &name) -{ - fstream fs; - fs.open(name, ios::out); - fs.close(); -} - -static int mkpath(const char *path, mode_t mode); - -static int do_mkdir(const char *path, mode_t mode) -{ - struct stat st; - int status = 0; - - if (stat(path, &st) != 0) { - /* Directory does not exist. EEXIST for race condition */ - if (mkdir(path, mode) != 0 && errno != EEXIST) { - status = -1; - } - - } else if (!S_ISDIR(st.st_mode)) { - errno = ENOTDIR; - status = -1; - } - - return (status); -} - -/** -** mkpath - ensure all directories in path exist -** Algorithm takes the pessimistic view and works top-down to ensure -** each directory in path exists, rather than optimistically creating -** the last element and working backwards. -*/ -static int mkpath(const char *path, mode_t mode) -{ - char *pp; - char *sp; - int status; - char *copypath = strdup(path); - - status = 0; - pp = copypath; - - while (status == 0 && (sp = strchr(pp, '/')) != 0) { - if (sp != pp) { - /* Neither root nor double slash in path */ - *sp = '\0'; - status = do_mkdir(copypath, mode); - *sp = '/'; - } - - pp = sp + 1; - } - - if (status == 0) { - status = do_mkdir(path, mode); - } - - free(copypath); - return (status); -} - -static string pwd() -{ - char temp[path_max_len]; - return (getcwd(temp, path_max_len) ? string(temp) : string("")); -} - static void print_prompt() { cout.flush(); @@ -231,13 +134,12 @@ static void run_cmd(const vector &appargs, bool exit_on_fail, bool silen static void usage() { - cout << "./px4 [-d] data_directory startup_config [-h]" << endl; + cout << "./px4 [-d] [startup_config] -h" << std::endl; cout << " -d - Optional flag to run the app in daemon mode and does not listen for user input." << - endl; - cout << " This is needed if px4 is intended to be run as a upstart job on linux" << endl; - cout << " - directory where romfs and posix-configs are located" << endl; - cout << " - config file for starting/stopping px4 modules" << endl; - cout << " -h - help/usage information" << endl; + std::endl; + cout << " This is needed if px4 is intended to be run as a upstart job on linux" << std::endl; + cout << " - config file for starting/stopping px4 modules" << std::endl; + cout << " -h - help/usage information" << std::endl; } static void process_line(string &line, bool exit_on_fail) @@ -300,131 +202,52 @@ int main(int argc, char **argv) set_cpu_scaling(); int index = 1; - string commands_file = ""; - int positional_arg_count = 0; - string data_path = ""; - string node_name = ""; + char *commands_file = nullptr; - // parse arguments while (index < argc) { - //cout << "arg: " << index << " : " << argv[index] << endl; - if (argv[index][0] == '-') { // the arg starts with - - if (strncmp(argv[index], "-d", 2) == 0) { + if (strcmp(argv[index], "-d") == 0) { daemon_mode = true; - } else if (strncmp(argv[index], "-h", 2) == 0) { + } else if (strcmp(argv[index], "-h") == 0) { usage(); return 0; - } else if (strncmp(argv[index], "-c", 2) == 0) { + } else if (strcmp(argv[index], "-c") == 0) { chroot_on = true; } else { - PX4_ERR("Unknown/unhandled parameter: %s", argv[index]); + PX4_WARN("Unknown/unhandled parameter: %s", argv[index]); return 1; } - } else if (!strncmp(argv[index], "__", 2)) { - //cout << "ros argument" << endl; - - // ros arguments - if (!strncmp(argv[index], "__name:=", 8)) { - string name_arg = argv[index]; - node_name = name_arg.substr(8); - cout << "node name: " << node_name << endl; - } - } else { - //cout << "positional argument" << endl; + // this is an argument that does not have '-' prefix; treat it like a file name + ifstream infile(argv[index]); - positional_arg_count += 1; - - if (positional_arg_count == 1) { - data_path = argv[index]; - cout << "data path: " << data_path << endl; - - } else if (positional_arg_count == 2) { + if (infile.good()) { + infile.close(); commands_file = argv[index]; - cout << "commands file: " << commands_file << endl; + + } else { + PX4_WARN("Error opening file: %s", argv[index]); + return -1; } } ++index; } - if (positional_arg_count != 2) { - PX4_ERR("Error expected 2 position arguments, got %d", positional_arg_count); - usage(); - return -1; - } - if (commands_file.size() < 1) { - PX4_ERR("Error commands file not specified"); - return -1; - } - - if (!fileExists(commands_file)) { - PX4_ERR("Error opening commands file, does not exist: %s", commands_file.c_str()); - return -1; - } - - // create sym-links - vector path_sym_links; - path_sym_links.push_back("ROMFS"); - path_sym_links.push_back("posix-configs"); - path_sym_links.push_back("src"); - - for (int i = 0; i < path_sym_links.size(); i++) { - string path_sym_link = path_sym_links[i]; - //cout << "path sym link: " << path_sym_link << endl; - string src_path = data_path + "/" + path_sym_link; - string dest_path = pwd() + "/" + path_sym_link; - - PX4_DEBUG("Creating symlink %s -> %s", src_path.c_str(), dest_path.c_str()); - - if (dirExists(path_sym_link)) { continue; } - - // create sym-links - int ret = symlink(src_path.c_str(), dest_path.c_str()); - - if (ret != 0) { - PX4_ERR("Error creating symlink %s -> %s", - src_path.c_str(), dest_path.c_str()); - return ret; - - } else { - PX4_DEBUG("Successfully created symlink %s -> %s", - src_path.c_str(), dest_path.c_str()); - } - } - - // setup rootfs - const string eeprom_path = "./rootfs/eeprom/"; - const string microsd_path = "./rootfs/fs/microsd/"; - - if (!fileExists(eeprom_path + "parameters")) { - cout << "creating new parameters file" << endl; - mkpath(eeprom_path.c_str(), S_IRUSR | S_IWUSR | S_IXUSR); - touch(eeprom_path + "parameters"); - } - - if (!fileExists(microsd_path + "dataman")) { - cout << "creating new dataman file" << endl; - mkpath(microsd_path.c_str(), S_IRUSR | S_IWUSR | S_IXUSR); - touch(microsd_path + "dataman"); - } - - // initialize DriverFramework::Framework::initialize(); px4::init_once(); px4::init(argc, argv, "px4"); // if commandfile is present, process the commands from the file - if (commands_file.size() != 0) { - ifstream infile(commands_file.c_str()); + if (commands_file != nullptr) { + ifstream infile(commands_file); if (infile.is_open()) { for (string line; getline(infile, line, '\n');) { @@ -438,7 +261,7 @@ int main(int argc, char **argv) } } else { - PX4_ERR("Error opening commands file: %s", commands_file.c_str()); + PX4_WARN("Error opening file: %s", commands_file); } } @@ -447,6 +270,12 @@ int main(int argc, char **argv) // this is not an attempt to secure the environment, // rather, to replicate a deployed file system. +#ifdef PATH_MAX + const unsigned path_max_len = PATH_MAX; +#else + const unsigned path_max_len = 1024; +#endif + char pwd_path[path_max_len]; const char *folderpath = "/rootfs/"; @@ -590,5 +419,3 @@ int main(int argc, char **argv) return OK; } - -/* vim: set noet fenc=utf-8 ff=unix sts=0 sw=4 ts=4 : */ diff --git a/src/platforms/posix/px4_layer/CMakeLists.txt b/src/platforms/posix/px4_layer/CMakeLists.txt index fa1eed4ffc..344621c694 100644 --- a/src/platforms/posix/px4_layer/CMakeLists.txt +++ b/src/platforms/posix/px4_layer/CMakeLists.txt @@ -32,10 +32,10 @@ ############################################################################ if("${CONFIG_SHMEM}" STREQUAL "1") - set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PX4_SOURCE_DIR}/cmake/cmake_hexagon") + set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/cmake_hexagon") include(hexagon_sdk) - include_directories(${PX4_BINARY_DIR}/src/firmware/posix) + include_directories(${CMAKE_BINARY_DIR}/src/firmware/posix) include_directories(${HEXAGON_SDK_INCLUDES}) list(APPEND SHMEM_SRCS shmem_posix.c diff --git a/src/platforms/qurt/px4_layer/CMakeLists.txt b/src/platforms/qurt/px4_layer/CMakeLists.txt index ed6e56790a..38dbd8a46f 100644 --- a/src/platforms/qurt/px4_layer/CMakeLists.txt +++ b/src/platforms/qurt/px4_layer/CMakeLists.txt @@ -30,7 +30,7 @@ # POSSIBILITY OF SUCH DAMAGE. # ############################################################################ -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PX4_SOURCE_DIR}/cmake/cmake_hexagon") +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/cmake_hexagon") include(hexagon_sdk) include_directories(${HEXAGON_8074_INCLUDES}) diff --git a/src/systemcmds/tests/test_mixer.cpp b/src/systemcmds/tests/test_mixer.cpp index da2cff5d5a..88c37d6e9c 100644 --- a/src/systemcmds/tests/test_mixer.cpp +++ b/src/systemcmds/tests/test_mixer.cpp @@ -90,7 +90,7 @@ int test_mixer(int argc, char *argv[]) #if !defined(CONFIG_ARCH_BOARD_SITL) const char *filename = "/etc/mixers/IO_pass.mix"; #else - const char *filename = "ROMFS/px4fmu_test/mixers/IO_pass.mix"; + const char *filename = "../../../../ROMFS/px4fmu_test/mixers/IO_pass.mix"; #endif //PX4_INFO("loading: %s", filename); @@ -400,7 +400,7 @@ int test_mixer(int argc, char *argv[]) #if !defined(CONFIG_ARCH_BOARD_SITL) filename = "/etc/mixers/quad_test.mix"; #else - filename = "ROMFS/px4fmu_test/mixers/quad_test.mix"; + filename = "../../../../ROMFS/px4fmu_test/mixers/quad_test.mix"; #endif load_mixer_file(filename, &buf[0], sizeof(buf)); diff --git a/src/systemcmds/topic_listener/CMakeLists.txt b/src/systemcmds/topic_listener/CMakeLists.txt index bb955490bc..0984e546e3 100644 --- a/src/systemcmds/topic_listener/CMakeLists.txt +++ b/src/systemcmds/topic_listener/CMakeLists.txt @@ -32,14 +32,14 @@ ############################################################################ add_custom_command(OUTPUT topic_listener.cpp - COMMAND ${PYTHON_EXECUTABLE} ${PX4_SOURCE_DIR}/Tools/generate_listener.py ${PX4_SOURCE_DIR} > topic_listener.cpp + COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/Tools/generate_listener.py ${CMAKE_SOURCE_DIR} > topic_listener.cpp DEPENDS msg_gen ) add_custom_target(generate_topic_listener DEPENDS topic_listener.cpp - ${PX4_SOURCE_DIR}/Tools/generate_listener.py) + ${CMAKE_SOURCE_DIR}/Tools/generate_listener.py) px4_add_module( MODULE systemcmds__topic_listener diff --git a/unittests/CMakeLists.txt b/unittests/CMakeLists.txt index b6664b26e8..9df3adcce3 100644 --- a/unittests/CMakeLists.txt +++ b/unittests/CMakeLists.txt @@ -13,19 +13,15 @@ enable_testing() set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Werror -std=gnu99 -g") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror -std=c++11 -g -fno-exceptions -fno-rtti -fno-threadsafe-statics") -if (NOT PX4_SOURCE_DIR) - set(PX4_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/..") -endif() - -set(GTEST_DIR ${PX4_SOURCE_DIR}/unittests/googletest) +set(GTEST_DIR ${CMAKE_SOURCE_DIR}/googletest) add_subdirectory(${GTEST_DIR}) include_directories(${GTEST_DIR}/include) -set(PX4_SRC ${PX4_SOURCE_DIR}/src) +set(PX4_SRC ${CMAKE_SOURCE_DIR}/../src) set(PX4_SITL_BUILD ${PX4_SRC}/../build_posix_sitl_default) -include_directories(${PX4_SOURCE_DIR}) +include_directories(${CMAKE_SOURCE_DIR}) include_directories(${PX4_SITL_BUILD}/src) include_directories(${PX4_SITL_BUILD}/src/modules) include_directories(${PX4_SITL_BUILD}/src/modules/param) @@ -98,7 +94,7 @@ target_include_directories(px4_platform PUBLIC ${PX4_SRC}/platforms/posix/work_q # check add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} -j2 --output-on-failure - WORKING_DIR ${PX4_BINARY_DIR} + WORKING_DIR ${CMAKE_BINARY_DIR} USES_TERMINAL) # add_gtest @@ -109,7 +105,7 @@ function(add_gtest) else() target_link_libraries(${test_name} gtest_main pthread rt px4_platform) endif() - add_test(NAME ${test_name} COMMAND ${test_name} WORKING_DIRECTORY ${PX4_SOURCE_DIR}) + add_test(NAME ${test_name} COMMAND ${test_name} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) add_dependencies(check ${test_name}) endforeach() endfunction()