From 29aefe2ba8941211bddc4e2ec95c36edf2226f1b Mon Sep 17 00:00:00 2001 From: Mateo de Mayo Date: Thu, 26 May 2022 14:28:37 -0300 Subject: [PATCH] misc: Use pretty printers and remove stale matrix print functions Use u_pp_matrix_* instead. --- src/xrt/auxiliary/math/m_api.h | 18 ----------- src/xrt/auxiliary/math/m_base.cpp | 24 -------------- src/xrt/auxiliary/tracking/t_data_utils.c | 39 ++++++++++++++++------- 3 files changed, 27 insertions(+), 54 deletions(-) diff --git a/src/xrt/auxiliary/math/m_api.h b/src/xrt/auxiliary/math/m_api.h index 83870a651..c9b25ef75 100644 --- a/src/xrt/auxiliary/math/m_api.h +++ b/src/xrt/auxiliary/math/m_api.h @@ -426,15 +426,6 @@ math_matrix_3x3_identity(struct xrt_matrix_3x3 *mat); void math_matrix_3x3_f64_identity(struct xrt_matrix_3x3_f64 *mat); -/*! - * Print a 3x3 (col-major) matrix to stdout - * - * @see xrt_matrix_3x3 - * @ingroup aux_math - */ -void -math_matrix_3x3_print(const struct xrt_matrix_3x3 *mat); - /*! * Transform a vec3 by a 3x3 matrix * @@ -519,15 +510,6 @@ math_matrix_3x3_rotation_from_isometry(const struct xrt_matrix_4x4 *isometry, st void math_matrix_4x4_identity(struct xrt_matrix_4x4 *result); -/*! - * Prints a Matrix4x4 (col-major). - * - * @relates xrt_matrix_4x4 - * @ingroup aux_math - */ -void -math_matrix_4x4_print(const struct xrt_matrix_4x4 *mat); - /*! * Multiply Matrix4x4. * diff --git a/src/xrt/auxiliary/math/m_base.cpp b/src/xrt/auxiliary/math/m_base.cpp index f15e82be0..142e79fe9 100644 --- a/src/xrt/auxiliary/math/m_base.cpp +++ b/src/xrt/auxiliary/math/m_base.cpp @@ -12,7 +12,6 @@ #include "math/m_api.h" #include "math/m_eigen_interop.hpp" -#include "util/u_logging.h" #include #include @@ -419,17 +418,6 @@ math_matrix_3x3_f64_identity(struct xrt_matrix_3x3_f64 *mat) map_matrix_3x3_f64(*mat) = Eigen::Matrix3d::Identity(); } -extern "C" void -math_matrix_3x3_print(const struct xrt_matrix_3x3 *mat) -{ - const auto &m = mat->v; - U_LOG_RAW("[\n"); - U_LOG_RAW("\t%f, %f, %f,\n", m[0], m[3], m[6]); - U_LOG_RAW("\t%f, %f, %f,\n", m[1], m[4], m[7]); - U_LOG_RAW("\t%f, %f, %f \n", m[2], m[5], m[8]); - U_LOG_RAW("]\n"); -} - extern "C" void math_matrix_3x3_f64_transform_vec3_f64(const struct xrt_matrix_3x3_f64 *left, const struct xrt_vec3_f64 *right, @@ -525,18 +513,6 @@ math_matrix_4x4_identity(struct xrt_matrix_4x4 *result) map_matrix_4x4(*result) = Eigen::Matrix4f::Identity(); } -extern "C" void -math_matrix_4x4_print(const struct xrt_matrix_4x4 *mat) -{ - const auto &m = mat->v; - U_LOG_RAW("[\n"); - U_LOG_RAW("\t%f, %f, %f, %f,\n", m[0], m[4], m[8], m[12]); - U_LOG_RAW("\t%f, %f, %f, %f,\n", m[1], m[5], m[9], m[13]); - U_LOG_RAW("\t%f, %f, %f, %f,\n", m[2], m[6], m[10], m[14]); - U_LOG_RAW("\t%f, %f, %f, %f \n", m[3], m[7], m[11], m[15]); - U_LOG_RAW("]\n"); -} - extern "C" void math_matrix_4x4_multiply(const struct xrt_matrix_4x4 *left, const struct xrt_matrix_4x4 *right, diff --git a/src/xrt/auxiliary/tracking/t_data_utils.c b/src/xrt/auxiliary/tracking/t_data_utils.c index c2c1cc4c8..4ee2ef54f 100644 --- a/src/xrt/auxiliary/tracking/t_data_utils.c +++ b/src/xrt/auxiliary/tracking/t_data_utils.c @@ -12,6 +12,7 @@ #include "util/u_config_json.h" #include "util/u_misc.h" #include "util/u_logging.h" +#include "util/u_pretty_print.h" #include #include @@ -357,24 +358,38 @@ t_calibration_gui_params_load_or_default(struct t_calibration_params *p) } } +static void +t_inertial_calibration_dump_pp(u_pp_delegate_t dg, struct t_inertial_calibration *c) +{ + u_pp(dg, "t_inertial_calibration {"); + u_pp_array2d_f64(dg, &c->transform[0][0], 3, 3, "transform", "\t"); + u_pp_array_f64(dg, c->offset, 3, "offset", "\t"); + u_pp_array_f64(dg, c->bias_std, 3, "bias_std", "\t"); + u_pp_array_f64(dg, c->noise_std, 3, "noise_std", "\t"); + u_pp(dg, "}"); +} + void t_inertial_calibration_dump(struct t_inertial_calibration *c) { - U_LOG_RAW("t_inertial_calibration {"); - dump_mat("transform", c->transform); - dump_vector("offset", c->offset); - dump_vector("bias_std", c->bias_std); - dump_vector("noise_std", c->noise_std); - U_LOG_RAW("}"); + struct u_pp_sink_stack_only sink; + u_pp_delegate_t dg = u_pp_sink_stack_only_init(&sink); + t_inertial_calibration_dump_pp(dg, c); + U_LOG(U_LOGGING_DEBUG, "%s", sink.buffer); } void t_imu_calibration_dump(struct t_imu_calibration *c) { - U_LOG_RAW("t_imu_calibration {"); - U_LOG_RAW("accel = "); - t_inertial_calibration_dump(&c->accel); - U_LOG_RAW("gyro = "); - t_inertial_calibration_dump(&c->gyro); - U_LOG_RAW("}"); + struct u_pp_sink_stack_only sink; + u_pp_delegate_t dg = u_pp_sink_stack_only_init(&sink); + + u_pp(dg, "t_imu_calibration {\n"); + u_pp(dg, "accel = "); + t_inertial_calibration_dump_pp(dg, &c->accel); + u_pp(dg, "gyro = "); + t_inertial_calibration_dump_pp(dg, &c->gyro); + u_pp(dg, "}"); + + U_LOG(U_LOGGING_DEBUG, "%s", sink.buffer); }