Neural Control Mode (#24366)

* Add tflm to px4 with module

 - Add TensorFlow Lite Micro(TFLM) as a library in px4
 - Make a module that uses neural network inference for control, which uses TFLM for inference
 - Make board config files for PX4 with neural module

* Added neural flight mode

* Add posibility to read of inference times

* Fix comments from review:

- Switch ssh link to https link in submodule
- Remove mc_nn_control from startup

* Add tflm to px4 with module

 - Add TensorFlow Lite Micro(TFLM) as a library in px4
 - Make a module that uses neural network inference for control, which uses TFLM for inference
 - Make board config files for PX4 with neural module

* Added neural flight mode

* Add posibility to read of inference times

* Remove auto start

* Add logging from neural control module

* Fix automatic startup to only be when module is included

* Switch to flight mode registration

* Add docs

* Change min/max/coeff to actual parameters

* add figures to neural network docs

* Switch to e2e network

* Remove toolchain changes and replace with instructions in docs

* Get ready for merge after toolchain upgrade

* switch back to submodule

* Try to figure out cmake

* Get CI working with new toolchain

* Remove fork dependency

* Finalize PR

* fix toolchain inclusion

* Fix ctype_base.h include

* Cleanup includes for TFLM

* Remove redundant std

* Update FW module names in board files

* Fix docs

* Remove cstdlib copy

* Copy header from nuttx

* Prettier, markup, layout

* NeuralControl.msg - update uorb comments to current standard

* Add description to neural topic

* Fix typo

* Typo

* TFLM and Module utitlities

* Neural networks top level

* Update docs

* Add manual control

* Update docs

* Revert the manual control attempt

* Update docs/en/advanced/nn_module_utilities.md

* Add posibility to set trajectory setpoint with manual control

---------

Co-authored-by: Pedro Roque <padr@kth.se>
Co-authored-by: Hamish Willee <hamishwillee@gmail.com>
Co-authored-by: Ramon Roche <mrpollo@gmail.com>
This commit is contained in:
Sindre Meyer Hegre
2025-07-25 19:42:12 +02:00
committed by GitHub
parent 132f7e9e0d
commit 3be0cb077c
29 changed files with 2944 additions and 3 deletions

View File

@@ -52,10 +52,26 @@ function(px4_os_add_flags)
include_directories(BEFORE SYSTEM
${PX4_SOURCE_DIR}/platforms/nuttx/NuttX/nuttx/include
${PX4_SOURCE_DIR}/platforms/nuttx/NuttX/nuttx/include/cxx
${PX4_SOURCE_DIR}/platforms/nuttx/NuttX/include/cxx # custom new
)
if(CONFIG_LIB_TFLM) # Since TFLM uses the standard C++ library, we need to exclude the NuttX C++ include path
add_custom_target(copy_header ALL
COMMAND ${CMAKE_COMMAND} -E copy # One of the header files from nuttx is needed
${PX4_SOURCE_DIR}/platforms/nuttx/NuttX/nuttx/include/cxx/cstdlib
${PX4_SOURCE_DIR}/src/lib/tensorflow_lite_micro/include/cstdlib
)
include_directories(BEFORE SYSTEM
${PX4_SOURCE_DIR}/src/lib/tensorflow_lite_micro/include
)
else()
include_directories(BEFORE SYSTEM
${PX4_SOURCE_DIR}/platforms/nuttx/NuttX/nuttx/include/cxx
${PX4_SOURCE_DIR}/platforms/nuttx/NuttX/include/cxx # custom new
)
endif()
include_directories(
${PX4_SOURCE_DIR}/platforms/nuttx/NuttX/nuttx/arch/${CONFIG_ARCH}/src/${CONFIG_ARCH_FAMILY}
${PX4_SOURCE_DIR}/platforms/nuttx/NuttX/nuttx/arch/${CONFIG_ARCH}/src/chip
@@ -71,9 +87,12 @@ function(px4_os_add_flags)
-fno-rtti
-fno-sized-deallocation
-fno-threadsafe-statics
-nostdinc++ # prevent using the toolchain's std c++ library
)
if(NOT CONFIG_LIB_TFLM)
list(APPEND cxx_flags -nostdinc++) # prevent using the toolchain's std c++ library if building for anything else than TFLM
endif()
foreach(flag ${cxx_flags})
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:${flag}>)
endforeach()