AP_NavEKF3: derivation: pin generator library versions

Document exactly which versions were used when generating the code.
Sympy is the most important so it is explicitly checked.

Also add an alternate generate script which uses `nix-shell` to make it
convenient to automatically use these versions.
This commit is contained in:
Thomas Watson 2024-08-11 14:02:05 -05:00 committed by Andrew Tridgell
parent 57082257fd
commit 4184980537
2 changed files with 19 additions and 0 deletions

View File

@ -1,10 +1,16 @@
#!/usr/bin/env python3
# Copied from https://github.com/PX4/ecl/commit/264c8c4e8681704e4719d0a03b848df8617c0863
# and modified for ArduPilot
from sympy import __version__ as __sympy__version__
from sympy import *
from code_gen import *
import numpy as np
# version required to generate the exact code currently present in ArduPilot.
# sympy version upgrades must ensure generated code doesn't pose any problems
# and must not have any other changes to the generator.
assert __sympy__version__ == "1.9", "expected sympy version 1.9, not "+__sympy__version__
# q: quaternion describing rotation from frame 1 to frame 2
# returns a rotation matrix derived form q which describes the same
# rotation

View File

@ -0,0 +1,13 @@
#!/usr/bin/env nix-shell
#! nix-shell --pure -i bash -p "python3.withPackages (p: [ p.numpy p.sympy ])"
#! nix-shell -I nixpkgs=https://github.com/NixOS/nixpkgs/archive/eabc38219184cc3e04a974fe31857d8e0eac098d.tar.gz
# above pins Python 3.9.13, Numpy 1.21.2, and Sympy 1.9 (and deps)
# using the last nixos-21.11 branch commit
cd "$(dirname "$0")"
rm -rf generated # ensure generated directory exists and is empty
mkdir -p generated
# explicitly invoke python3 to use interpreter from nix-shell
python3 ./generate_1.py