misc: Use pretty printers and remove stale matrix print functions

Use u_pp_matrix_* instead.
This commit is contained in:
Mateo de Mayo 2022-05-26 14:28:37 -03:00
parent 7d80729358
commit 29aefe2ba8
3 changed files with 27 additions and 54 deletions

View file

@ -426,15 +426,6 @@ math_matrix_3x3_identity(struct xrt_matrix_3x3 *mat);
void void
math_matrix_3x3_f64_identity(struct xrt_matrix_3x3_f64 *mat); 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 * 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 void
math_matrix_4x4_identity(struct xrt_matrix_4x4 *result); 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. * Multiply Matrix4x4.
* *

View file

@ -12,7 +12,6 @@
#include "math/m_api.h" #include "math/m_api.h"
#include "math/m_eigen_interop.hpp" #include "math/m_eigen_interop.hpp"
#include "util/u_logging.h"
#include <Eigen/Core> #include <Eigen/Core>
#include <Eigen/Geometry> #include <Eigen/Geometry>
@ -419,17 +418,6 @@ math_matrix_3x3_f64_identity(struct xrt_matrix_3x3_f64 *mat)
map_matrix_3x3_f64(*mat) = Eigen::Matrix3d::Identity(); 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 extern "C" void
math_matrix_3x3_f64_transform_vec3_f64(const struct xrt_matrix_3x3_f64 *left, math_matrix_3x3_f64_transform_vec3_f64(const struct xrt_matrix_3x3_f64 *left,
const struct xrt_vec3_f64 *right, 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(); 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 extern "C" void
math_matrix_4x4_multiply(const struct xrt_matrix_4x4 *left, math_matrix_4x4_multiply(const struct xrt_matrix_4x4 *left,
const struct xrt_matrix_4x4 *right, const struct xrt_matrix_4x4 *right,

View file

@ -12,6 +12,7 @@
#include "util/u_config_json.h" #include "util/u_config_json.h"
#include "util/u_misc.h" #include "util/u_misc.h"
#include "util/u_logging.h" #include "util/u_logging.h"
#include "util/u_pretty_print.h"
#include <stdio.h> #include <stdio.h>
#include <assert.h> #include <assert.h>
@ -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 void
t_inertial_calibration_dump(struct t_inertial_calibration *c) t_inertial_calibration_dump(struct t_inertial_calibration *c)
{ {
U_LOG_RAW("t_inertial_calibration {"); struct u_pp_sink_stack_only sink;
dump_mat("transform", c->transform); u_pp_delegate_t dg = u_pp_sink_stack_only_init(&sink);
dump_vector("offset", c->offset); t_inertial_calibration_dump_pp(dg, c);
dump_vector("bias_std", c->bias_std); U_LOG(U_LOGGING_DEBUG, "%s", sink.buffer);
dump_vector("noise_std", c->noise_std);
U_LOG_RAW("}");
} }
void void
t_imu_calibration_dump(struct t_imu_calibration *c) t_imu_calibration_dump(struct t_imu_calibration *c)
{ {
U_LOG_RAW("t_imu_calibration {"); struct u_pp_sink_stack_only sink;
U_LOG_RAW("accel = "); u_pp_delegate_t dg = u_pp_sink_stack_only_init(&sink);
t_inertial_calibration_dump(&c->accel);
U_LOG_RAW("gyro = "); u_pp(dg, "t_imu_calibration {\n");
t_inertial_calibration_dump(&c->gyro); u_pp(dg, "accel = ");
U_LOG_RAW("}"); 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);
} }