mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-05-14 17:57:35 +08:00
Features and fixes
* added the trace function for a SquareMatrix * added Vector3.hat() and it's counterpart Dcm.vee() for skewsymskew symmetric matrix operations in relation to the cross product see https://en.wikipedia.org/wiki/Hat_operator * Matrix::write_string produced runtime errors when I used it in PX4 posix simulation, i simplified it * a Matrix3f is a SquareMatrix * added tests for SquareMatrix.trace, Vector3.hat and Dcm.vee * added a test for quaternion initialisation from array * preventing buffer overflows in Matrix.write_string method
This commit is contained in:
committed by
James Goppert
parent
07fba8322a
commit
65679fbcbb
@@ -15,6 +15,7 @@ set(tests
|
||||
integration
|
||||
squareMatrix
|
||||
helper
|
||||
hatvee
|
||||
)
|
||||
|
||||
add_custom_target(test_build)
|
||||
|
||||
@@ -231,6 +231,12 @@ int main()
|
||||
TEST(fabsf(q(2) - q_true(2)) < eps);
|
||||
TEST(fabsf(q(3) - q_true(3)) < eps);
|
||||
|
||||
// Quaternion initialisation per array
|
||||
float q_array[] = {0.9833f, -0.0343f, -0.1060f, -0.1436f};
|
||||
Quaternion<float>q_from_array(q_array);
|
||||
for(int i = 0; i < 4; i++)
|
||||
TEST(fabsf(q_from_array(i) - q_array[i]) < eps);
|
||||
|
||||
};
|
||||
|
||||
/* vim: set et fenc=utf-8 ff=unix sts=0 sw=4 ts=4 : */
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
#include <stdio.h>
|
||||
#include "test_macros.hpp"
|
||||
|
||||
#include <matrix/math.hpp>
|
||||
|
||||
using namespace matrix;
|
||||
|
||||
template class SquareMatrix<float, 3>;
|
||||
|
||||
int main()
|
||||
{
|
||||
Euler<float> euler(0.1f, 0.2f, 0.3f);
|
||||
Dcm<float> R(euler);
|
||||
Dcm<float> skew = R - R.T();
|
||||
Vector3<float> w = skew.vee();
|
||||
Vector3<float> w_check(0.1348f, 0.4170f, 0.5647f);
|
||||
|
||||
TEST(isEqual(w, w_check));
|
||||
TEST(isEqual(skew, w.hat()));
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* vim: set et fenc=utf-8 ff=unix sts=0 sw=4 ts=4 : */
|
||||
@@ -17,6 +17,7 @@ int main()
|
||||
Vector3<float> diag_check(1, 5, 10);
|
||||
|
||||
TEST(isEqual(A.diag(), diag_check));
|
||||
TEST(A.trace() - 16 < 1e-3);
|
||||
|
||||
float data_check[9] = {
|
||||
1.01158503f, 0.02190432f, 0.03238144f,
|
||||
|
||||
Reference in New Issue
Block a user