mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-11-22 22:50:49 +08:00
* fix(mc_nn_control): reject a model the module cannot feed The documentation tells users to swap the model array in control_net.cpp, and the module then wrote 15 floats into whatever input tensor came back and read 4 outputs from whatever output tensor came back, with no check of either. A model with a different input width would write past the tensor in the arena with no diagnostic. Reported in #28417. Check the schema version before the interpreter is built on the model, then the number of input and output tensors and the element count and type of each, and refuse to start with the reason in the log when they do not match. The checks live in a header without module dependencies so they can be unit tested, and the operator registration moves to a header so a test can load the shipped model through the real interpreter. Assisted-by: Claude:claude-fable-5 Signed-off-by: Saibernard Yogendran <bernie97@seas.upenn.edu> * fix(mc_nn_control): guard the observations and the network output The network was fed whatever the position and attitude topics last held, with no check of the validity flags, the age or finiteness, and its output went to the motors with any non finite channel mapped to a stopped motor while the other three kept thrusting. Reported in #28417. Check the observations on every cycle, in the mode or not: the position validity flags, the age of position, attitude and angular velocity against the same limits the raptor module uses, and finiteness. The network is not run on observations that fail, and a non finite output is not sent. In both cases the last command of this session is repeated, which is what the mixer would apply anyway, and the arming check reply says the mode cannot run, so the commander leaves it through its own fallback within one of its external check intervals. The repeat keeps the actuator topic and the lockstep simulators going, which wait for an output on every step. The first fault of an outage is reported once. A non finite output is reported once and the network is not trusted again until the mode has been left. The module runs on angular velocity updates, so a lost angular velocity stream would never have woken it. It is now a scheduled work item that re-arms a delayed run on every cycle, which keeps it registering, checking and answering the commander when the updates stop. The trajectory setpoint starts unset and is reset to the current position when the mode is entered without one. Before, the member was never initialized and the reset only happened when a position update landed on the same cycle as the first angular velocity update. In SIH, a GPS loss while flying the neural mode produced the fault event the same instant the position validity dropped, inference stopped, and the commander was in Descend within its next check. A gyro loss on a real time build produced the fault event 20 ms after the last sample and the commander was in failsafe 150 ms later. Assisted-by: Claude:claude-fable-5 Signed-off-by: Saibernard Yogendran <bernie97@seas.upenn.edu> * test(mc_nn_control): cover the model, observation and output checks Eleven cases on the checks the module runs before trusting its model, its observations and its output: every position validity flag, each staleness limit at its boundary and pinned to the raptor module's values, never set and future stamps, non finite values in each observation, the order in which faults are reported, every channel of the output, and every way a model can fail the layout check. One more loads the shipped model through the real interpreter and runs the module's layout check on it, so a swapped model array the module cannot feed fails here before it fails on a vehicle. Assisted-by: Claude:claude-fable-5 Signed-off-by: Saibernard Yogendran <bernie97@seas.upenn.edu> * fix(mc_nn_control): start the observation caches empty The three cached observations were plain members, so the first observation check read whatever the memory held before any of the topics had published, and a stream that had not arrived could pass that first check by chance. They start empty now, which the first check reports as an invalid position. A functional test builds the module in storage filled beforehand and runs the check with nothing published. Assisted-by: Claude:claude-fable-5-1 Signed-off-by: Saibernard Yogendran <bernie97@seas.upenn.edu> * ci(tests): run every mc_nn_control test in tests_neural The default filter of the target only matched the first test of the module. It now selects every test of the module, and it is quoted so the shell does not read the alternation as a pipe. Assisted-by: Claude:claude-fable-5-1 Signed-off-by: Saibernard Yogendran <bernie97@seas.upenn.edu> --------- Signed-off-by: Saibernard Yogendran <bernie97@seas.upenn.edu>
PX4 User Guide
This repo contains the source code for the PX4 User Guide.
Note
Contributions and Translations to this guide are very welcome!