Skip to content

Commit

Permalink
passing bias jacobian tests on Imu3D
Browse files Browse the repository at this point in the history
  • Loading branch information
superjax committed Jan 8, 2019
1 parent 2d0f4b0 commit 761e12e
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 12 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "lib/geometry"]
path = lib/geometry
url = https://github.com/superjax/geometry
[submodule "lib/multirotor_sim"]
path = lib/multirotor_sim
url = [email protected]:superjax/multirotor_sim
10 changes: 9 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,33 @@ find_package(Eigen3 REQUIRED)
find_package(GTest REQUIRED)

add_subdirectory(lib/geometry)
add_subdirectory(lib/multirotor_sim)

include_directories(include
lib/geometry/include
lib/multirotor_sim/include
lib/multirotor_sim/lib/nanoflann_eigen/include
lib/multirotor_sim/lib/lin_alg_tools/include
lib/utils/include
${EIGEN3_INCLUDE_DIRS}
${GTEST_INCLUDE_DIRS})

add_library(utils
lib/utils/src/robot1d.cpp)
lib/utils/src/robot1d.cpp
lib/utils/src/jac.cpp)

add_executable(nano_mhe_test
src/test_imu1d.cpp
src/test_imu3d.cpp
src/test_mhe1d.cpp
src/test_mhe3d.cpp
src/test_autodiff.cpp
src/test_lm.cpp)
target_link_libraries(nano_mhe_test
utils
gtest
gtest_main
multirotor_sim
${GTEST_LIBRARIES}
pthread)
#add_custom_command(
Expand Down
1 change: 1 addition & 0 deletions lib/multirotor_sim
Submodule multirotor_sim added at 598fed
2 changes: 1 addition & 1 deletion lib/utils/include/utils/jac.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ Eigen::MatrixXd calc_jac(std::function<Eigen::MatrixXd(const Eigen::MatrixXd &)>
std::function<Eigen::MatrixXd(const Eigen::MatrixXd&, const Eigen::MatrixXd&)>f_boxminus=nullptr,
std::function<Eigen::MatrixXd(const Eigen::MatrixXd&, const Eigen::MatrixXd&)>f_boxplus=nullptr,
std::function<Eigen::MatrixXd(const Eigen::MatrixXd &, const Eigen::MatrixXd &)> f_boxminus2=nullptr,
std::function<Eigen::MatrixXd(const Eigen::MatrixXd &, const Eigen::MatrixXd &)> f_boxplus2=nullptr);
std::function<Eigen::MatrixXd(const Eigen::MatrixXd &, const Eigen::MatrixXd &)> f_boxplus2=nullptr, double step_size=1e-8);
7 changes: 4 additions & 3 deletions lib/utils/src/jac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ Eigen::MatrixXd calc_jac(std::function<Eigen::MatrixXd(const Eigen::MatrixXd&)>
std::function<Eigen::MatrixXd(const Eigen::MatrixXd&, const Eigen::MatrixXd&)>f_boxminus,
std::function<Eigen::MatrixXd(const Eigen::MatrixXd&, const Eigen::MatrixXd&)>f_boxplus,
std::function<Eigen::MatrixXd(const Eigen::MatrixXd&, const Eigen::MatrixXd&)>f_boxminus2,
std::function<Eigen::MatrixXd(const Eigen::MatrixXd&, const Eigen::MatrixXd&)>f_boxplus2)
std::function<Eigen::MatrixXd(const Eigen::MatrixXd&, const Eigen::MatrixXd&)>f_boxplus2,
double step_size)
{
if (f_boxminus == nullptr)
{
Expand Down Expand Up @@ -48,7 +49,7 @@ Eigen::MatrixXd calc_jac(std::function<Eigen::MatrixXd(const Eigen::MatrixXd&)>
I.resize(cols, cols);
I.setZero(cols, cols);
for (int i = 0; i < cols; i++)
I(i,i) = 1e-8;
I(i,i) = step_size;

Eigen::MatrixXd JFD;
JFD.setZero(rows, cols);
Expand All @@ -61,7 +62,7 @@ Eigen::MatrixXd calc_jac(std::function<Eigen::MatrixXd(const Eigen::MatrixXd&)>
Eigen::MatrixXd ym = fun(xm);
Eigen::MatrixXd dy = f_boxminus2(yp,ym);

JFD.col(i) = dy/(2*1e-8);
JFD.col(i) = dy/(2*step_size);
}
return JFD;
}
10 changes: 4 additions & 6 deletions src/test_autodiff.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@

#include "test_common.h"

using namespace quat;

TEST (CostFunctorAutoDiff, CompileNormalVecs)
{
typedef Matrix<double, 2, 1> OT;
Expand Down Expand Up @@ -192,8 +190,8 @@ struct QuatPlus
typedef typename Derived1::Scalar T;
typedef Matrix<T, 4, 1> Vec4;
typedef Matrix<T, 3, 1> Vec3;
Quat<T> qp(_qp);
Quat<T> q(_q);
quat::Quat<T> qp(_qp);
quat::Quat<T> q(_q);
Vec4 qpdebug= _qp;
Vec4 qdebug= _q;
Vec3 ddebug = delta;
Expand All @@ -206,9 +204,9 @@ typedef CostFunctorAutoDiff<double, QuatPlus, 4, 4, 3> QuatParam;

TEST (Autodiff, Quaternion)
{
Quatd q1 = Quatd::from_euler(10.0*M_PI/180.0, -45.0*M_PI/180.0, 20.0*M_PI/180.0);
quat::Quatd q1 = quat::Quatd::from_euler(10.0*M_PI/180.0, -45.0*M_PI/180.0, 20.0*M_PI/180.0);
Vector3d delta = (Vector3d() << 0.01, 0.02, -0.01).finished();
Quatd qp;
quat::Quatd qp;
Matrix<double, 4, 4> dqp_dq1;
Matrix<double, 4, 3> dqp_ddelta;

Expand Down
2 changes: 1 addition & 1 deletion src/test_mhe1d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "utils/logger.h"


TEST (nano_mhe_1d, init)
TEST (nano_mhe_1d, compile)
{
MHE_1D<double, 5> mhe;
}
Expand Down

0 comments on commit 761e12e

Please sign in to comment.