wind_estimator: cmake add symforce generation helper target (wind_estimator_generate_airspeed_fusion)

This commit is contained in:
Daniel Agar 2022-07-11 11:39:09 -04:00
parent 26190a7799
commit 38c02ea29a
5 changed files with 13 additions and 3 deletions

View File

@ -17,6 +17,7 @@ exec find boards msg src platforms test \
-path src/lib/crypto/monocypher -prune -o \
-path src/lib/events/libevents -prune -o \
-path src/lib/parameters/uthash -prune -o \
-path src/lib/wind_estimator/python/generated -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 \

View File

@ -36,3 +36,12 @@ add_library(wind_estimator
WindEstimator.hpp
)
add_dependencies(wind_estimator prebuild_targets)
add_custom_target(wind_estimator_generate_airspeed_fusion
COMMAND ${PYTHON_EXECUTABLE} derivation.py
#DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/python/derivation.py
#BYPRODUCTS ${CMAKE_CURRENT_SOURCE_DIR}/python/generated/fuse_airspeed.h
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/python
COMMENT "Generating fuse_airspeed"
USES_TERMINAL
)

View File

@ -44,7 +44,6 @@ import fileinput
with fileinput.FileInput(os.path.abspath(metadata.generated_files[0]), inplace=True, backup='.bak') as file:
for line in file:
line = line.replace("std::max", "math::max")
line = line.replace("std", "matrix")
line = line.replace("Eigen", "matrix")
line = line.replace("matrix/Dense", "matrix/math.hpp")
print(line, end='')

View File

@ -0,0 +1 @@
*.bak

View File

@ -43,8 +43,8 @@ void FuseAirspeed(const matrix::Matrix<Scalar, 3, 1>& v_local,
// Intermediate terms (11)
const Scalar _tmp0 = -state(0, 0) + v_local(0, 0);
const Scalar _tmp1 = -state(1, 0) + v_local(1, 0);
const Scalar _tmp2 = matrix::sqrt(Scalar(matrix::pow(_tmp0, Scalar(2)) + matrix::pow(_tmp1, Scalar(2)) +
epsilon + matrix::pow(v_local(2, 0), Scalar(2))));
const Scalar _tmp2 = std::sqrt(Scalar(std::pow(_tmp0, Scalar(2)) + std::pow(_tmp1, Scalar(2)) +
epsilon + std::pow(v_local(2, 0), Scalar(2))));
const Scalar _tmp3 = state(2, 0) / _tmp2;
const Scalar _tmp4 = _tmp0 * _tmp3;
const Scalar _tmp5 = _tmp1 * _tmp3;