Skip to content

Commit

Permalink
changed debug assert for ctest.c, sparse quaternion roundtrip test fo…
Browse files Browse the repository at this point in the history
…r time save
  • Loading branch information
kenjihiranabe committed Dec 25, 2024
1 parent f9f5338 commit 42044eb
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 10 deletions.
2 changes: 0 additions & 2 deletions drone_physics/ctest.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#include "drone_physics_debug.h"
#include "drone_physics_osdep.h"

#undef NDEBUG // force assert to work even if release bulid.

const double PI = M_PI;

void static test_frame_all_unit_vectors_with_some_angles() {
Expand Down
5 changes: 1 addition & 4 deletions drone_physics/drone_physics_debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,7 @@ static double diff_a(const dp_euler_t* a, const dp_euler_t* b) {
static int AssertCount = 0;

#define assert_almost_equal(a, b) \
assert((++AssertCount && diff(&(a), &(b)) <almost_tolerance) || (print_vec(a), fprintf(stderr, " <-?-> "), print_vec(b), fprintf(stderr, "!!\n"), 0))

#define assert_almost_equal_euler(a, b) \
assert((++AssertCount && diff_e(&(a), &(b)) <almost_tolerance) || (print_ang(a), fprintf(stderr, " <-?-> "), print_ang(b), fprintf(stderr, "!!\n"), 0))
(++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)

#define print_vec(v) \
fprintf(stderr, "%s=(%g,%g,%g)", #v, v.x, v.y, v.z)
Expand Down
6 changes: 2 additions & 4 deletions drone_physics/utest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

using namespace hako::drone_physics;

#undef NDEBUG // force assert to work even if release bulid.

const double PI = M_PI;

void test_frame_all_unit_vectors_with_angle0() {
Expand Down Expand Up @@ -648,8 +646,8 @@ void sub_test_two_quaternion_velocity(double i, double j, double k, double l, co
void test_quaternion_velocity_roundtrip() {
for (double i = -10; i < 10; i += .5) {
for (double j = -10; j < 10; j += .5) {
for (double k = -10; k < 10; k += .5) {
for (double l = -10; l < 10; l += .5) {
for (double k = -10; k < 10; k += 1.5) {
for (double l = -10; l < 10; l += 1.5) {
if (i == 0 && j == 0 && k == 0 && l == 0) continue;
// note dt = 0.01 will fail. 12/10/2024, too big. or av is too big.
sub_test_two_quaternion_velocity(i, j, k, l, {0.1, 0.1, 0.1}, 0.001);
Expand Down

0 comments on commit 42044eb

Please sign in to comment.