-
Notifications
You must be signed in to change notification settings - Fork 13.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Neural Control Mode #24366
base: main
Are you sure you want to change the base?
Neural Control Mode #24366
Conversation
This pull request has been mentioned on Discussion Forum for PX4, Pixhawk, QGroundControl, MAVSDK, MAVLink. There might be relevant details there: |
This pull request has been mentioned on Discussion Forum for PX4, Pixhawk, QGroundControl, MAVSDK, MAVLink. There might be relevant details there: |
f5cefaa
to
33189a3
Compare
600755d
to
2eb97f2
Compare
- 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
2eb97f2
to
ff4254a
Compare
- 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
51ae6ae
to
4ceaaa9
Compare
# if(NOT ${TOOL}) | ||
# message(FATAL_ERROR "could not find ${tool}") | ||
# endif() | ||
# endforeach() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not needed?
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++) | ||
set(CMAKE_CXX_COMPILER_TARGET ${triple}) | ||
# Define the path to the new toolchain | ||
set(NEW_TOOLCHAIN_PATH "/home/sindre/Dropbox/Studier/2025_Var/dev/PX4-Autopilot-public/src/lib/tflm/tflite_micro/tensorflow/lite/micro/tools/make/downloads/gcc_embedded/bin") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has your local user name in the path
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I change it to use a variable like ${PX4_SOURCE_DIR}
, I get errors when building uxrce_dds_client. Not sure how to fix unless the standard toolchain downloaded when calling
bash ./Tools/setup/ubuntu.sh
is upgraded.
- Switch ssh link to https link in submodule - Remove mc_nn_control from startup
…4-Autopilot-public into neural_control_with_tflm
@@ -0,0 +1,2 @@ | |||
control_net.cpp | |||
allocation_net.cpp |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There should be no gitignore here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's there temporarily as I don't own the network I'm currently flying it, so I can't publish it in a public repo yet. But I'm in the process of fixing this
@@ -0,0 +1,138 @@ | |||
/**************************************************************************** | |||
* | |||
* Copyright (c) 2013-2025 PX4 Development Team. All rights reserved. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* Copyright (c) 2013-2025 PX4 Development Team. All rights reserved. | |
* Copyright (c) 2025 PX4 Development Team. All rights reserved. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
@@ -89,3 +89,7 @@ | |||
[submodule "src/drivers/uavcan/libdronecan/libuavcan/dsdl_compiler/pydronecan"] | |||
path = src/drivers/uavcan/libdronecan/libuavcan/dsdl_compiler/pydronecan | |||
url = https://github.com/dronecan/pydronecan | |||
[submodule "src/lib/tflm/tflite_micro"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice if this wasn't pulled for all builds.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how do I fix this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@SindreMHegre Why do you even need the submodule?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Jaeyoung-Lim I have no idea, it just seemed like the standard way to include a big library. What other options do I have? Just adding the needed parts of the lib directly in the code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@SindreMHegre Can we install it on the system? submodules only make sense if you need to compile the library with the source
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the part of this PR where I'm the least experienced. What do you mean installing it on the system? I'm unsure if the library needs to compile on it's own first
fe9ca99
to
aa83e4e
Compare
This pull request has been mentioned on Discussion Forum for PX4, Pixhawk, QGroundControl, MAVSDK, MAVLink. There might be relevant details there: https://discuss.px4.io/t/how-to-integrate-eigen-library-with-px4-firmware/44065/2 |
This pull request has been mentioned on Discussion Forum for PX4, Pixhawk, QGroundControl, MAVSDK, MAVLink. There might be relevant details there: https://discuss.px4.io/t/adding-an-external-flight-mode-from-the-fcu/44137/1 |
aa83e4e
to
b08dba2
Compare
b08dba2
to
2243d9b
Compare
Solved Problem
Using neural networks for various tasks on UAVs in research is becoming more and more commonplace. My aim is to provide a module that can be used to replace the MC controller with NN to lower the barrier for using RL and NN on UAVs in general, and give researchers and hobbyist a place to start for NN use.
Solution
Changelog Entry
For release notes:
Alternatives
We could also look into using Eigen or executorch
Test coverage
https://review.px4.io/plot_app?log=52502d02-009e-4d1f-baac-a49dd51cfdef (check neural_control topic)
https://review.px4.io/plot_app?log=43d2ba6c-3d05-4d7f-a31b-490a57b3e647
Context
Docs:
PX4/PX4-user_guide#3617
Help:
Other feature requests:
Info:
The networks I'm flying with right now is not mine and is being used for research, so they will be open sourced at some point, but can't give them away at the moment
Inference times on the pixracer pro:
control net: 70 microseconds
allocation net: 13 microseconds
Full NN controller: 141 microseconds