Closed prihex closed 2 years ago
in /uav_dynamics/inno_vtol_dynamics/src/dynamics/vtolDynamicsSim.cpp:701
void InnoVtolDynamicsSim::calculatePolynomialUsingTable(const Eigen::MatrixXd& table,
double airSpeedMod,
Eigen::VectorXd& polynomialCoeffs) const{
size_t prevRowIdx = findRow(table, airSpeedMod);
if(prevRowIdx + 2 <= table.rows()){
size_t nextRowIdx = prevRowIdx + 1;
Eigen::MatrixXd prevRow = table.row(prevRowIdx);
Eigen::MatrixXd nextRow = table.row(nextRowIdx);
double t = (airSpeedMod - prevRow(0, 0)) / (nextRow(0, 0) - prevRow(0, 0));
for(size_t idx = 0; idx < 7; idx++){
polynomialCoeffs[idx] = lerp(prevRow(0, idx + 1), nextRow(0, idx + 1), t); // This line
}
}else{
for(size_t idx = 0; idx < 7; idx++){
polynomialCoeffs[idx] = 0;
}
}
}
nextRow(0, idx + 1)
couldn't be calculated because in function
EIGEN_DEVICE_FUNC
EIGEN_STRONG_INLINE Scalar& coeffRef(Index row, Index col)
{
eigen_internal_assert(row >= 0 && row < rows()
&& col >= 0 && col < cols()); // This assertion fails
return internal::evaluator<Derived>(derived()).coeffRef(row,col);
}
Both col
and cols()
returns 6** when armed in debug mode. Release and RelWithDebInfo doesn't evaluate assertions. Thus they never crash.
#define EIGEN_NO_DEBUG
before
#include "vtolDynamicsSim.hpp"
in vtolDynamicsSim.cpp
solved the problem
@hdbalyozsht Hi. Thanks for the issue. I tried it with DEBUG build type and I got the same error. I modified tests a little bit and reproduce the problem in test workflow. Then I fixed it in the next commit, so now it should be ok.
#define EIGEN_NO_DEBUG
is not the solution. The actual problem was related to the fact that CDPolynomial
matrix has the size (8, 6) less than other similar matrices (8, 8). calculatePolynomialUsingTable was hardcoded to handle only the (8, 8) size case. Now it is more robust.
I made fixes here: #12
CMAKE_BUILD_TYPE
is currently set asRelWithDebInfo
ininno_vtol_dynamics
project.CMakeLists.txt:9
SET(CMAKE_BUILD_TYPE RelWithDebInfo)
If I set it to
Debug
and arm the vehicle. Program exits.