Kindr
Kinematics and Dynamics for Robotics
gtest_eigen.hpp File Reference
#include <type_traits>
#include <gtest/gtest.h>
#include "source_file_pos.hpp"
#include "assert_macros_eigen.hpp"
#include <Eigen/Core>
Include dependency graph for gtest_eigen.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

 kindr
 

Macros

#define KINDR_ASSERT_DOUBLE_MX_EQ_ZT(A, B, PERCENT_TOLERANCE, MSG, ZERO_THRESHOLD)
 
#define KINDR_ASSERT_DOUBLE_MX_EQ(A, B, PERCENT_TOLERANCE, MSG)
 
#define KINDR_ASSERT_DOUBLE_MX_EQ_ABS_REL(M_TRUE, M_MEAS, ATOL, RTOL, MSG)
 Matrix comparison with absolute and relative tolerance |M_MEAS - M_TRUE| <= |M_TRUE|*RTOL + ATOL. More...
 
#define KINDR_ASSERT_DOUBLE_MX_EQ_PERIODIC(A, B, PERIODLENGTH, PERCENT_TOLERANCE, MSG)
 

Functions

template<typename T >
double kindr::calcRotationQuatDisparityAngleToIdentity (const T &quat)
 
template<typename T >
double kindr::calcRotationQuatDisparityAngle (const T &q1, const T &q2)
 
template<typename M1 , typename M2 >
void kindr::assertEqual (const M1 &A, const M2 &B, kindr::internal::source_file_pos const &sfp, std::string const &message="")
 
template<typename M1 , typename M2 , typename T >
void kindr::assertNear (const M1 &A, const M2 &B, T tolerance, kindr::internal::source_file_pos const &sfp, std::string const &message="")
 
template<typename M1 , typename M2 , typename T >
void kindr::expectNear (const M1 &A, const M2 &B, T tolerance, kindr::internal::source_file_pos const &sfp, std::string const &message="")
 
template<typename M1 >
void kindr::assertFinite (const M1 &A, kindr::internal::source_file_pos const &sfp, std::string const &message="")
 

Macro Definition Documentation

#define KINDR_ASSERT_DOUBLE_MX_EQ (   A,
  B,
  PERCENT_TOLERANCE,
  MSG 
)
Value:
ASSERT_EQ((size_t)(A).rows(), (size_t)(B).rows()) << MSG << "\nMatrix " << #A << ":\n" << A << "\nand matrix " << #B << "\n" << B << "\nare not the same size"; \
ASSERT_EQ((size_t)(A).cols(), (size_t)(B).cols()) << MSG << "\nMatrix " << #A << ":\n" << A << "\nand matrix " << #B << "\n" << B << "\nare not the same size"; \
for(int r = 0; r < (A).rows(); r++) \
{ \
for(int c = 0; c < (A).cols(); c++) \
{ \
typedef typename std::remove_reference<decltype(A)>::type::Scalar Scalar; \
Scalar percentError = static_cast<Scalar>(0.0); \
ASSERT_TRUE(kindr::compareRelative( (A)(r,c), (B)(r,c), PERCENT_TOLERANCE, &percentError)) \
<< MSG << "\nComparing:\n" \
<< #A << "(" << r << "," << c << ") = " << (A)(r,c) << std::endl \
<< #B << "(" << r << "," << c << ") = " << (B)(r,c) << std::endl \
<< "Error was " << percentError << "% > " << PERCENT_TOLERANCE << "%\n" \
<< "\nMatrix " << #A << ":\n" << A << "\nand matrix " << #B << "\n" << B; \
} \
}
bool compareRelative(SCALAR a, SCALAR2 b, SCALAR3 percentTolerance, SCALAR *percentError=NULL, SCALAR bothZeroThreshold=SCALAR(1.0e-15))

Definition at line 141 of file gtest_eigen.hpp.

#define KINDR_ASSERT_DOUBLE_MX_EQ_ABS_REL (   M_TRUE,
  M_MEAS,
  ATOL,
  RTOL,
  MSG 
)
Value:
ASSERT_EQ((size_t)(M_TRUE).rows(), (size_t)(M_MEAS).rows()) << MSG << "\nMatrix " << #M_TRUE << ":\n" << M_TRUE << "\nand matrix " << #M_MEAS << "\n" << M_MEAS << "\nare not the same size"; \
ASSERT_EQ((size_t)(M_TRUE).cols(), (size_t)(M_MEAS).cols()) << MSG << "\nMatrix " << #M_TRUE << ":\n" << M_TRUE << "\nand matrix " << #M_MEAS << "\n" << M_MEAS << "\nare not the same size"; \
for(int r = 0; r < (M_TRUE).rows(); r++) \
{ \
for(int c = 0; c < (M_TRUE).cols(); c++) \
{ \
typedef typename std::remove_reference<decltype(M_TRUE)>::type::Scalar Scalar; \
ASSERT_TRUE(fabs((M_MEAS)(r,c) - (M_TRUE)(r,c)) <= (fabs((M_TRUE)(r,c))*RTOL + ATOL)) \
<< MSG << "\nComparing:\n" \
<< #M_TRUE << "(" << r << "," << c << ") = " << (M_TRUE)(r,c) << std::endl \
<< #M_MEAS << "(" << r << "," << c << ") = " << (M_MEAS)(r,c) << std::endl \
<< "Absolute error was " << fabs((M_MEAS)(r,c) - (M_TRUE)(r,c)) << " > " << ATOL << "\n" \
<< "Relative error was " << fabs((M_MEAS)(r,c) - (M_TRUE)(r,c))/fabs((M_TRUE)(r,c)) << " > " << RTOL << "\n" \
<< "\nMatrix " << #M_TRUE << ":\n" << M_TRUE << "\nand matrix " << #M_MEAS << "\n" << M_MEAS; \
} \
}

Matrix comparison with absolute and relative tolerance |M_MEAS - M_TRUE| <= |M_TRUE|*RTOL + ATOL.

Definition at line 160 of file gtest_eigen.hpp.

#define KINDR_ASSERT_DOUBLE_MX_EQ_PERIODIC (   A,
  B,
  PERIODLENGTH,
  PERCENT_TOLERANCE,
  MSG 
)
Value:
ASSERT_EQ((size_t)(A).rows(), (size_t)(B).rows()) << MSG << "\nMatrix " << #A << ":\n" << A << "\nand matrix " << #B << "\n" << B << "\nare not the same size"; \
ASSERT_EQ((size_t)(A).cols(), (size_t)(B).cols()) << MSG << "\nMatrix " << #A << ":\n" << A << "\nand matrix " << #B << "\n" << B << "\nare not the same size"; \
for(int r = 0; r < (A).rows(); r++) \
{ \
for(int c = 0; c < (A).cols(); c++) \
{ \
typedef typename std::remove_reference<decltype(A)>::type::Scalar Scalar; \
Scalar percentError = static_cast<Scalar>(0.0); \
ASSERT_TRUE(kindr::compareRelativePeriodic( (A)(r,c), (B)(r,c), PERIODLENGTH, PERCENT_TOLERANCE, &percentError)) \
<< MSG << "\nComparing:\n" \
<< #A << "(" << r << "," << c << ") = " << (A)(r,c) << std::endl \
<< #B << "(" << r << "," << c << ") = " << (B)(r,c) << std::endl \
<< "Error was " << percentError << "% > " << PERCENT_TOLERANCE << "%\n" \
<< "\nMatrix " << #A << ":\n" << A << "\nand matrix " << #B << "\n" << B; \
} \
}
bool compareRelativePeriodic(SCALAR a, SCALAR b, double periodlength, double percentTolerance, SCALAR *percentError=NULL)

Definition at line 178 of file gtest_eigen.hpp.

#define KINDR_ASSERT_DOUBLE_MX_EQ_ZT (   A,
  B,
  PERCENT_TOLERANCE,
  MSG,
  ZERO_THRESHOLD 
)
Value:
ASSERT_EQ((size_t)(A).rows(), (size_t)(B).rows()) << MSG << "\nMatrix " << #A << ":\n" << A << "\nand matrix " << #B << "\n" << B << "\nare not the same size"; \
ASSERT_EQ((size_t)(A).cols(), (size_t)(B).cols()) << MSG << "\nMatrix " << #A << ":\n" << A << "\nand matrix " << #B << "\n" << B << "\nare not the same size"; \
for(int r = 0; r < (A).rows(); r++) \
{ \
for(int c = 0; c < (A).cols(); c++) \
{ \
typedef typename std::remove_reference<decltype(A)>::type::Scalar Scalar; \
Scalar percentError = static_cast<Scalar>(0.0); \
ASSERT_TRUE(kindr::compareRelative( (A)(r,c), (B)(r,c), PERCENT_TOLERANCE, &percentError, ZERO_THRESHOLD)) \
<< MSG << "\nComparing:\n" \
<< #A << "(" << r << "," << c << ") = " << (A)(r,c) << std::endl \
<< #B << "(" << r << "," << c << ") = " << (B)(r,c) << std::endl \
<< "Error was " << percentError << "% > " << PERCENT_TOLERANCE << "%\n" \
<< "\nMatrix " << #A << ":\n" << A << "\nand matrix " << #B << "\n" << B; \
} \
}
bool compareRelative(SCALAR a, SCALAR2 b, SCALAR3 percentTolerance, SCALAR *percentError=NULL, SCALAR bothZeroThreshold=SCALAR(1.0e-15))

Definition at line 123 of file gtest_eigen.hpp.