diff --git a/.gitmodules b/.gitmodules index d84bccbd9f..c84cfc5a09 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,6 @@ -[submodule "mavlink/include/mavlink/v2.0"] - path = mavlink/include/mavlink/v2.0 - url = https://github.com/mavlink/c_library_v2.git +[submodule "src/modules/mavlink/mavlink"] + path = src/modules/mavlink/mavlink + url = https://github.com/mavlink/mavlink.git branch = master [submodule "src/drivers/uavcan/libuavcan"] path = src/drivers/uavcan/libuavcan @@ -65,7 +65,7 @@ url = https://github.com/mavlink/libevents.git [submodule "Tools/simulation-ignition"] path = Tools/simulation-ignition - url = https://github.com/Auterion/px4-simulation-ignition.git + url = https://github.com/PX4/px4-simulation-ignition.git [submodule "src/lib/crypto/libtomcrypt"] path = src/lib/crypto/libtomcrypt url = https://github.com/PX4/libtomcrypt.git diff --git a/Tools/astyle/files_to_check_code_style.sh b/Tools/astyle/files_to_check_code_style.sh index 9098b500e9..f9033e35ca 100755 --- a/Tools/astyle/files_to_check_code_style.sh +++ b/Tools/astyle/files_to_check_code_style.sh @@ -21,6 +21,7 @@ exec find boards msg src platforms test \ -path src/lib/parameters/uthash -prune -o \ -path src/modules/ekf2/EKF -prune -o \ -path src/modules/gyro_fft/CMSIS_5 -prune -o \ + -path src/modules/mavlink/mavlink -prune -o \ -path src/modules/micrortps_bridge/micro-CDR -prune -o \ -path src/modules/micrortps_bridge/microRTPS_client -prune -o \ -path test/mavsdk_tests/catch2 -prune -o \ diff --git a/Tools/flightgear_bridge b/Tools/flightgear_bridge index 7c2c623da9..ea9b6cb5b9 160000 --- a/Tools/flightgear_bridge +++ b/Tools/flightgear_bridge @@ -1 +1 @@ -Subproject commit 7c2c623da9f5dcb3f01d32830af1a2ed958de363 +Subproject commit ea9b6cb5b93365928190864a6592c0a280e101ea diff --git a/Tools/jsbsim_bridge b/Tools/jsbsim_bridge index e070c50d59..68de2cc63d 160000 --- a/Tools/jsbsim_bridge +++ b/Tools/jsbsim_bridge @@ -1 +1 @@ -Subproject commit e070c50d591541d440510b65c9da5cad1db5aa9a +Subproject commit 68de2cc63ded9a0d6641d45e9eb3ed2b43454cba diff --git a/Tools/setup/requirements.txt b/Tools/setup/requirements.txt index 00a5a79956..dc7b822f12 100644 --- a/Tools/setup/requirements.txt +++ b/Tools/setup/requirements.txt @@ -6,6 +6,7 @@ empy>=3.3 jinja2>=2.8 jsonschema kconfiglib +lxml matplotlib>=3.0.* numpy>=1.13 nunavut>=1.1.0 diff --git a/Tools/setup/ubuntu.sh b/Tools/setup/ubuntu.sh index 88d27581de..6223018f6d 100755 --- a/Tools/setup/ubuntu.sh +++ b/Tools/setup/ubuntu.sh @@ -86,6 +86,8 @@ sudo DEBIAN_FRONTEND=noninteractive apt-get -y --quiet --no-install-recommends i gdb \ git \ lcov \ + libxml2-dev \ + libxml2-utils \ make \ ninja-build \ python3 \ diff --git a/Tools/simulation-ignition b/Tools/simulation-ignition index e78ad94a4f..0ea4dbe2c3 160000 --- a/Tools/simulation-ignition +++ b/Tools/simulation-ignition @@ -1 +1 @@ -Subproject commit e78ad94a4f41bbc202fd7fc1acb728b09cb1dbaf +Subproject commit 0ea4dbe2c3dac84f5927a59b1caf5e5561cf942e diff --git a/Tools/sitl_gazebo b/Tools/sitl_gazebo index d8366bf238..1c8c919710 160000 --- a/Tools/sitl_gazebo +++ b/Tools/sitl_gazebo @@ -1 +1 @@ -Subproject commit d8366bf2389eae6106d1dbfaac72ebfdf23a5d2d +Subproject commit 1c8c9197103e746a21f2d2d2c844dd2f7e2b036b diff --git a/cmake/px4_add_module.cmake b/cmake/px4_add_module.cmake index aa75a00d4d..7c3ef5df37 100644 --- a/cmake/px4_add_module.cmake +++ b/cmake/px4_add_module.cmake @@ -125,7 +125,7 @@ function(px4_add_module) # as well as interface include and libraries foreach(dep ${DEPENDS}) get_target_property(dep_type ${dep} TYPE) - if (${dep_type} STREQUAL "STATIC_LIBRARY") + if((${dep_type} STREQUAL "STATIC_LIBRARY") OR (${dep_type} STREQUAL "INTERFACE_LIBRARY")) target_link_libraries(${MODULE}_original PRIVATE ${dep}) else() add_dependencies(${MODULE}_original ${dep}) @@ -205,7 +205,7 @@ function(px4_add_module) # as well as interface include and libraries foreach(dep ${DEPENDS}) get_target_property(dep_type ${dep} TYPE) - if (${dep_type} STREQUAL "STATIC_LIBRARY") + if((${dep_type} STREQUAL "STATIC_LIBRARY") OR (${dep_type} STREQUAL "INTERFACE_LIBRARY")) target_link_libraries(${MODULE} PRIVATE ${dep}) else() add_dependencies(${MODULE} ${dep}) diff --git a/mavlink/include/mavlink/v2.0 b/mavlink/include/mavlink/v2.0 deleted file mode 160000 index 5571ffbcd6..0000000000 --- a/mavlink/include/mavlink/v2.0 +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 5571ffbcd67e19ee6c6301fe13712856906525c2 diff --git a/src/lib/version/px_update_git_header.py b/src/lib/version/px_update_git_header.py index e9372ff36b..2d8da490ac 100755 --- a/src/lib/version/px_update_git_header.py +++ b/src/lib/version/px_update_git_header.py @@ -135,9 +135,9 @@ if (os.path.exists('src/lib/ecl/.git')): # Mavlink -if (os.path.exists('mavlink/include/mavlink/v2.0/.git')): +if (os.path.exists('src/modules/mavlink/mavlink/.git')): mavlink_git_version = subprocess.check_output('git rev-parse --verify HEAD'.split(), - cwd='mavlink/include/mavlink/v2.0', stderr=subprocess.STDOUT).decode('utf-8').strip() + cwd='src/modules/mavlink/mavlink', stderr=subprocess.STDOUT).decode('utf-8').strip() mavlink_git_version_short = mavlink_git_version[0:16] header += f""" diff --git a/src/modules/mavlink/CMakeLists.txt b/src/modules/mavlink/CMakeLists.txt index cd7135338b..f57186d52d 100644 --- a/src/modules/mavlink/CMakeLists.txt +++ b/src/modules/mavlink/CMakeLists.txt @@ -1,6 +1,6 @@ ############################################################################ # -# Copyright (c) 2015-2017 PX4 Development Team. All rights reserved. +# Copyright (c) 2015-2021 PX4 Development Team. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions @@ -31,18 +31,51 @@ # ############################################################################ -px4_add_git_submodule(TARGET git_mavlink_v2 PATH "${PX4_SOURCE_DIR}/mavlink/include/mavlink/v2.0") +set(MAVLINK_DIALECT "development") # standard, development, etc + +# force mavlink dialect to standard if flash constrained +if(px4_constrained_flash_build) + set(MAVLINK_DIALECT "standard") +endif() + +set(MAVLINK_GIT_DIR "${CMAKE_CURRENT_LIST_DIR}/mavlink") +set(MAVLINK_LIBRARY_DIR "${CMAKE_BINARY_DIR}/mavlink") +file(RELATIVE_PATH MAVLINK_GIT_DIR_RELATIVE ${CMAKE_SOURCE_DIR} ${MAVLINK_GIT_DIR}) + +px4_add_git_submodule(TARGET git_mavlink_v2 PATH "${MAVLINK_GIT_DIR}") + +add_custom_command( + OUTPUT ${MAVLINK_LIBRARY_DIR}/${MAVLINK_DIALECT}/${MAVLINK_DIALECT}.h + COMMAND + ${PYTHON_EXECUTABLE} ${MAVLINK_GIT_DIR}/pymavlink/tools/mavgen.py + --lang C --wire-protocol 2.0 + #--no-validate + #--strict-units + --output ${MAVLINK_LIBRARY_DIR} + ${MAVLINK_GIT_DIR}/message_definitions/v1.0/${MAVLINK_DIALECT}.xml + DEPENDS + git_mavlink_v2 + ${MAVLINK_GIT_DIR}/pymavlink/tools/mavgen.py + ${MAVLINK_GIT_DIR}/message_definitions/v1.0/${MAVLINK_DIALECT}.xml + COMMENT "Generating Mavlink ${MAVLINK_DIALECT}: ${MAVLINK_GIT_DIR_RELATIVE}/message_definitions/v1.0/${MAVLINK_DIALECT}.xml" + USES_TERMINAL +) +add_custom_target(mavlink_c_generate DEPENDS ${MAVLINK_LIBRARY_DIR}/${MAVLINK_DIALECT}/${MAVLINK_DIALECT}.h) + +# mavlink header only library +add_library(mavlink_c INTERFACE) +target_sources(mavlink_c INTERFACE ${MAVLINK_LIBRARY_DIR}/${MAVLINK_DIALECT}/${MAVLINK_DIALECT}.h) +set_source_files_properties(${MAVLINK_LIBRARY_DIR}/${MAVLINK_DIALECT}/${MAVLINK_DIALECT}.h PROPERTIES GENERATED true) +target_include_directories(mavlink_c INTERFACE ${MAVLINK_LIBRARY_DIR} ${MAVLINK_LIBRARY_DIR}/${MAVLINK_DIALECT}) +target_compile_options(mavlink_c INTERFACE -Wno-address-of-packed-member -Wno-cast-align) + px4_add_module( MODULE modules__mavlink MAIN mavlink COMPILE_FLAGS - -Wno-cast-align # TODO: fix and enable - -Wno-address-of-packed-member # TODO: fix in c_library_v2 -Wno-enum-compare # ROTATION <-> MAV_SENSOR_ROTATION #-DDEBUG_BUILD - INCLUDES - ${PX4_SOURCE_DIR}/mavlink/include/mavlink SRCS mavlink.c mavlink_command_sender.cpp @@ -70,9 +103,9 @@ px4_add_module( drivers_barometer drivers_gyroscope drivers_magnetometer - git_mavlink_v2 conversion geo + mavlink_c version UNITY_BUILD ) diff --git a/src/modules/mavlink/mavlink b/src/modules/mavlink/mavlink new file mode 160000 index 0000000000..3718ee300b --- /dev/null +++ b/src/modules/mavlink/mavlink @@ -0,0 +1 @@ +Subproject commit 3718ee300bef7a8e7a25314e25e03c11d9f0b180 diff --git a/src/modules/mavlink/mavlink_bridge_header.h b/src/modules/mavlink/mavlink_bridge_header.h index e4811f5628..6d3a0152a4 100644 --- a/src/modules/mavlink/mavlink_bridge_header.h +++ b/src/modules/mavlink/mavlink_bridge_header.h @@ -61,7 +61,7 @@ # define MAVLINK_COMM_5 static_cast(5) #endif -#include +#include #include __BEGIN_DECLS @@ -92,7 +92,7 @@ void mavlink_end_uart_send(mavlink_channel_t chan, int length); extern mavlink_status_t *mavlink_get_channel_status(uint8_t chan); extern mavlink_message_t *mavlink_get_channel_buffer(uint8_t chan); -#include +#include __END_DECLS diff --git a/src/modules/mavlink/mavlink_ftp.cpp b/src/modules/mavlink/mavlink_ftp.cpp index ee5e4dc348..0ed2649f4d 100644 --- a/src/modules/mavlink/mavlink_ftp.cpp +++ b/src/modules/mavlink/mavlink_ftp.cpp @@ -48,7 +48,7 @@ #ifndef MAVLINK_FTP_UNIT_TEST #include "mavlink_main.h" #else -#include +#include #endif using namespace time_literals; diff --git a/src/modules/mavlink/mavlink_ftp.h b/src/modules/mavlink/mavlink_ftp.h index a3ac52be93..3a92690278 100644 --- a/src/modules/mavlink/mavlink_ftp.h +++ b/src/modules/mavlink/mavlink_ftp.h @@ -46,7 +46,7 @@ #ifndef MAVLINK_FTP_UNIT_TEST #include "mavlink_bridge_header.h" #else -#include +#include #endif class MavlinkFtpTest; diff --git a/src/modules/mavlink/mavlink_tests/CMakeLists.txt b/src/modules/mavlink/mavlink_tests/CMakeLists.txt index da27da0f20..5ea4b8a854 100644 --- a/src/modules/mavlink/mavlink_tests/CMakeLists.txt +++ b/src/modules/mavlink/mavlink_tests/CMakeLists.txt @@ -31,12 +31,13 @@ # ############################################################################ -include_directories(${PX4_SOURCE_DIR}/mavlink/include/mavlink) - px4_add_module( MODULE modules__mavlink__mavlink_tests MAIN mavlink_tests STACK_MAIN 8192 + INCLUDES + ${CMAKE_BINARY_DIR}/mavlink + ${CMAKE_BINARY_DIR}/mavlink/common COMPILE_FLAGS -DMAVLINK_FTP_UNIT_TEST #-DMAVLINK_FTP_DEBUG diff --git a/src/modules/mavlink/mavlink_tests/mavlink_ftp_test.h b/src/modules/mavlink/mavlink_tests/mavlink_ftp_test.h index 8d2868af76..30f9fcc110 100644 --- a/src/modules/mavlink/mavlink_tests/mavlink_ftp_test.h +++ b/src/modules/mavlink/mavlink_tests/mavlink_ftp_test.h @@ -40,7 +40,7 @@ #ifndef MAVLINK_FTP_UNIT_TEST #include "../mavlink_bridge_header.h" #else -#include +#include #endif #include "../mavlink_ftp.h" diff --git a/src/modules/simulator/CMakeLists.txt b/src/modules/simulator/CMakeLists.txt index d19927f47f..af52383c3c 100644 --- a/src/modules/simulator/CMakeLists.txt +++ b/src/modules/simulator/CMakeLists.txt @@ -55,12 +55,13 @@ px4_add_module( -Wno-cast-align -Wno-address-of-packed-member # TODO: fix in c_library_v2 INCLUDES - ${PX4_SOURCE_DIR}/mavlink/include/mavlink + ${CMAKE_BINARY_DIR}/mavlink + ${CMAKE_BINARY_DIR}/mavlink/development SRCS simulator.cpp simulator_mavlink.cpp DEPENDS - git_mavlink_v2 + mavlink_c_generate conversion geo drivers_accelerometer @@ -68,6 +69,6 @@ px4_add_module( drivers_gyroscope drivers_magnetometer ) -target_include_directories(modules__simulator INTERFACE ${PX4_SOURCE_DIR}/mavlink/include/mavlink) +target_include_directories(modules__simulator INTERFACE ${CMAKE_BINARY_DIR}/mavlink) add_subdirectory(battery_simulator) diff --git a/src/modules/simulator/simulator.h b/src/modules/simulator/simulator.h index 56176d1a8f..525a89b7d1 100644 --- a/src/modules/simulator/simulator.h +++ b/src/modules/simulator/simulator.h @@ -76,8 +76,8 @@ #include -#include -#include +#include +#include using namespace time_literals;