mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-18 01:03:33 +08:00
Added runge kutta integration.
This commit is contained in:
@@ -11,6 +11,7 @@ set(tests
|
||||
vector3
|
||||
attitude
|
||||
filter
|
||||
integration
|
||||
squareMatrix
|
||||
)
|
||||
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@ int main()
|
||||
|
||||
// euler default ctor
|
||||
Eulerf e;
|
||||
Eulerf e_zero = zero<float, 3, 1>();
|
||||
Eulerf e_zero = zeros<float, 3, 1>();
|
||||
assert(e == e_zero);
|
||||
assert(e == e);
|
||||
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <matrix/integration.hpp>
|
||||
|
||||
using namespace matrix;
|
||||
|
||||
Vector<float, 6> f(float t, Vector<float, 6> y);
|
||||
|
||||
Vector<float, 6> f(float t, Vector<float, 6> y) {
|
||||
return ones<float, 6, 1>();
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
Vector<float, 6> y = ones<float, 6, 1>();
|
||||
float h = 1;
|
||||
float t = 1;
|
||||
y.T().print();
|
||||
integrate_rk4(f, y, t, h);
|
||||
y.T().print();
|
||||
assert(y == (ones<float, 6, 1>()*2));
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* vim: set et fenc=utf-8 ff=unix sts=0 sw=4 ts=4 : */
|
||||
+1
-1
@@ -40,7 +40,7 @@ int main()
|
||||
assert(A_large == A_large_I);
|
||||
}
|
||||
|
||||
SquareMatrix<float, 3> zero_test = zero<float, 3, 3>();
|
||||
SquareMatrix<float, 3> zero_test = zeros<float, 3, 3>();
|
||||
inv(zero_test);
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -65,6 +65,7 @@ int main()
|
||||
|
||||
Matrix3f m4(data);
|
||||
|
||||
assert(-m4 == m4*(-1));
|
||||
|
||||
m4.swapCols(0, 2);
|
||||
assert(m4 == Matrix3f(data_col_02_swap));
|
||||
@@ -72,6 +73,11 @@ int main()
|
||||
m4.swapRows(0, 2);
|
||||
assert(m4 == Matrix3f(data_row_02_swap));
|
||||
assert(fabs(m4.min() - 1) < 1e-5);
|
||||
|
||||
Scalar<float> s;
|
||||
s = 1;
|
||||
assert(fabs(s - 1) < 1e-5);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,6 @@ int main()
|
||||
assert(fabs(v1.norm() - 7.416198487095663f) < 1e-5);
|
||||
Vector<float, 5> v2(data2);
|
||||
assert(fabs(v1.dot(v2) - 130.0f) < 1e-5);
|
||||
assert(fabs(v1*v2 - 130.0f) < 1e-5);
|
||||
v2.normalize();
|
||||
Vector<float, 5> v3(v2);
|
||||
assert(v2 == v3);
|
||||
|
||||
Reference in New Issue
Block a user