Skip to content

Commit 42044eb

Browse files
committed
changed debug assert for ctest.c, sparse quaternion roundtrip test for time save
1 parent f9f5338 commit 42044eb

File tree

3 files changed

+3
-10
lines changed

3 files changed

+3
-10
lines changed

drone_physics/ctest.c

-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
#include "drone_physics_debug.h"
22
#include "drone_physics_osdep.h"
33

4-
#undef NDEBUG // force assert to work even if release bulid.
5-
64
const double PI = M_PI;
75

86
void static test_frame_all_unit_vectors_with_some_angles() {

drone_physics/drone_physics_debug.h

+1-4
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,7 @@ static double diff_a(const dp_euler_t* a, const dp_euler_t* b) {
7676
static int AssertCount = 0;
7777

7878
#define assert_almost_equal(a, b) \
79-
assert((++AssertCount && diff(&(a), &(b)) <almost_tolerance) || (print_vec(a), fprintf(stderr, " <-?-> "), print_vec(b), fprintf(stderr, "!!\n"), 0))
80-
81-
#define assert_almost_equal_euler(a, b) \
82-
assert((++AssertCount && diff_e(&(a), &(b)) <almost_tolerance) || (print_ang(a), fprintf(stderr, " <-?-> "), print_ang(b), fprintf(stderr, "!!\n"), 0))
79+
(++AssertCount, (diff(&(a), &(b)) <almost_tolerance) ? 1 : (print_vec(a), fprintf(stderr, " <-?-> "), print_vec(b), fprintf(stderr, "!!\n"), 0), assert ((diff(&(a), &(b)) <almost_tolerance)), 0)
8380

8481
#define print_vec(v) \
8582
fprintf(stderr, "%s=(%g,%g,%g)", #v, v.x, v.y, v.z)

drone_physics/utest.cpp

+2-4
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44

55
using namespace hako::drone_physics;
66

7-
#undef NDEBUG // force assert to work even if release bulid.
8-
97
const double PI = M_PI;
108

119
void test_frame_all_unit_vectors_with_angle0() {
@@ -648,8 +646,8 @@ void sub_test_two_quaternion_velocity(double i, double j, double k, double l, co
648646
void test_quaternion_velocity_roundtrip() {
649647
for (double i = -10; i < 10; i += .5) {
650648
for (double j = -10; j < 10; j += .5) {
651-
for (double k = -10; k < 10; k += .5) {
652-
for (double l = -10; l < 10; l += .5) {
649+
for (double k = -10; k < 10; k += 1.5) {
650+
for (double l = -10; l < 10; l += 1.5) {
653651
if (i == 0 && j == 0 && k == 0 && l == 0) continue;
654652
// note dt = 0.01 will fail. 12/10/2024, too big. or av is too big.
655653
sub_test_two_quaternion_velocity(i, j, k, l, {0.1, 0.1, 0.1}, 0.001);

0 commit comments

Comments
 (0)