Skip to content
Snippets Groups Projects
Commit 4b5411e8 authored by Randy Mackay's avatar Randy Mackay
Browse files

AP_Math: add new rotation to example rotation sketch

parent 6b0e636a
No related branches found
No related tags found
No related merge requests found
...@@ -37,11 +37,10 @@ const AP_HAL::HAL& hal = AP_HAL_BOARD_DRIVER; ...@@ -37,11 +37,10 @@ const AP_HAL::HAL& hal = AP_HAL_BOARD_DRIVER;
static void print_vector(Vector3f &v) static void print_vector(Vector3f &v)
{ {
hal.console->printf("[%.2f %.2f %.2f]\n", hal.console->printf("[%.4f %.4f %.4f]\n",
v.x, v.y, v.z); v.x, v.y, v.z);
} }
// test rotation method accuracy // test rotation method accuracy
static void test_rotation_accuracy(void) static void test_rotation_accuracy(void)
{ {
...@@ -94,10 +93,16 @@ static void test_euler(enum Rotation rotation, float roll, float pitch, float ya ...@@ -94,10 +93,16 @@ static void test_euler(enum Rotation rotation, float roll, float pitch, float ya
diff = (v2 - v1); diff = (v2 - v1);
if (diff.length() > accuracy) { if (diff.length() > accuracy) {
hal.console->printf("euler test %u incorrect\n", (unsigned)rotation); hal.console->printf("euler test %u failed : yaw:%d roll:%d pitch:%d\n",
print_vector(v); (unsigned)rotation,
(int)yaw,
(int)roll,
(int)pitch);
hal.console->printf("fast rotated: ");
print_vector(v1); print_vector(v1);
hal.console->printf("slow rotated: ");
print_vector(v2); print_vector(v2);
hal.console->printf("\n");
} }
} }
...@@ -141,7 +146,8 @@ static void test_eulers(void) ...@@ -141,7 +146,8 @@ static void test_eulers(void)
test_euler(ROTATION_ROLL_180_PITCH_270,180,270, 0); test_euler(ROTATION_ROLL_180_PITCH_270,180,270, 0);
test_euler(ROTATION_ROLL_270_PITCH_270,270,270, 0); test_euler(ROTATION_ROLL_270_PITCH_270,270,270, 0);
test_euler(ROTATION_ROLL_90_PITCH_180_YAW_90, 90, 180, 90); test_euler(ROTATION_ROLL_90_PITCH_180_YAW_90, 90, 180, 90);
test_euler(ROTATION_ROLL_90_YAW_270, 90, 0, 270); test_euler(ROTATION_ROLL_90_YAW_270, 90, 0, 270);
test_euler(ROTATION_YAW_293_PITCH_68_ROLL_180,180,68.8,293.3);
} }
static bool have_rotation(const Matrix3f &m) static bool have_rotation(const Matrix3f &m)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment