26 float roll, pitch, yaw;
32 for(int16_t i = 0; i < 90; i++ ) {
39 small_rotation =
Vector3f(rot_angle, 0.0
f, 0.0
f);
42 attitude.
rotate(small_rotation);
45 attitude.
to_euler(&roll, &pitch, &yaw);
51 attitude = r2 * attitude;
53 float roll2, pitch2, yaw2;
54 attitude.
to_euler(&roll2, &pitch2, &yaw2);
57 hal.
console->
printf(
"actual angle: %d angle1:%4.2f angle2:%4.2f\n",
60 (
double)
ToDeg(roll2));
64 for(int16_t i = 0; i < 90; i++ ) {
71 small_rotation =
Vector3f(0.0
f ,rot_angle, 0.0
f);
74 attitude.
rotate(small_rotation);
77 attitude.
to_euler(&roll, &pitch, &yaw);
83 attitude = r2 * attitude;
85 float roll2, pitch2, yaw2;
86 attitude.
to_euler(&roll2, &pitch2, &yaw2);
89 hal.
console->
printf(
"actual angle: %d angle1:%4.2f angle2:%4.2f\n",
92 (
double)
ToDeg(pitch2));
97 for(int16_t i = 0; i < 90; i++ ) {
103 rot_angle =
ToRad(i);
104 small_rotation =
Vector3f(0.0
f, 0.0
f, rot_angle);
107 attitude.
rotate(small_rotation);
110 attitude.
to_euler(&roll, &pitch, &yaw);
116 attitude = r2 * attitude;
118 float roll2, pitch2, yaw2;
119 attitude.
to_euler(&roll2, &pitch2, &yaw2);
122 hal.
console->
printf(
"actual angle: %d angle1:%4.2f angle2:%4.2f\n",
125 (
double)
ToDeg(yaw2));
133 const float accuracy = 1.0e-6
f;
147 if (diff.
length() > accuracy) {
148 hal.
console->
printf(
"euler test %u failed : yaw:%d roll:%d pitch:%d\n",
163 hal.
console->
printf(
"\nrotate inverse test(Vector (1,1,1)):\n");
167 r = (
enum Rotation)((uint8_t)r+1)) {
173 vec.rotate_inverse(r);
175 if ((vec - cmp_vec).length() > 1e-5) {
176 hal.
console->
printf(
"Rotation Test Failed!!! %.8f\n", (
double)(vec - cmp_vec).length());
230 r = (
enum Rotation)((uint8_t)(r + 1))) {
235 if ((v2 - v).length() < 0.01
f) {
245 for (uint16_t yaw = 0; yaw < 360; yaw += 90)
246 for (uint16_t pitch = 0; pitch < 360; pitch += 90)
247 for (uint16_t roll = 0; roll < 360; roll += 90) {
251 hal.
console->
printf(
"Missing rotation (%u, %u, %u)\n", roll, pitch, yaw);
260 r = (
enum Rotation)((uint8_t)r+1)) {
270 if ((vec - vec2).length() > 1e-5) {
271 hal.
console->
printf(
"Rotation Test Failed!!! %.8f\n", (
double)(vec - vec2).length());
void to_euler(float *roll, float *pitch, float *yaw) const
static void missing_rotations(void)
Vector3< float > Vector3f
const AP_HAL::HAL & hal
-*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*-
AP_HAL::UARTDriver * console
virtual void begin(uint32_t baud)=0
void from_axis_angle(const Vector3< T > &v, float theta)
void from_euler(float roll, float pitch, float yaw)
static void test_rotate_inverse(void)
Matrix3< T > transposed(void) const
virtual void printf(const char *,...) FMT_PRINTF(2
void from_rotation(enum Rotation rotation)
static void test_eulers(void)
void rotate(enum Rotation rotation)
static void test_rotate_matrix(void)
static constexpr float radians(float deg)
static bool have_rotation(const Matrix3f &m)
static void print_vector(Vector3f &v)
static void test_rotation_accuracy(void)
void rotate(const Vector3< T > &g)
static void test_euler(enum Rotation rotation, float roll, float pitch, float yaw)