GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: tests/test_dependencies_usage.cpp Lines: 68 68 100.0 %
Date: 2023-12-03 14:15:28 Branches: 435 870 50.0 %

Line Branch Exec Source
1
#include <boost/test/unit_test.hpp>
2
#include <sstream>
3
4
#include "aig/unittests/pyrene_settings.hpp"
5
#include "pinocchio/algorithm/center-of-mass.hpp"
6
#include "pinocchio/parsers/srdf.hpp"
7
#include "pinocchio/parsers/urdf.hpp"
8
9
BOOST_AUTO_TEST_SUITE(BOOST_TEST_MODULE)
10
11
















4
BOOST_AUTO_TEST_CASE(test_load_talos_model) {
12
4
  pinocchio::Model model;
13
  pinocchio::urdf::buildModel(aig::unittests::urdf,
14

2
                              pinocchio::JointModelFreeFlyer(), model);
15


2
  BOOST_CHECK_EQUAL(model.name, "talos");
16
2
}
17
18
















4
BOOST_AUTO_TEST_CASE(test_load_talos_model_from_xml) {
19
4
  pinocchio::Model model;
20
21
  // Read file as XML
22
4
  std::ifstream file(aig::unittests::urdf.c_str());
23
4
  std::stringstream buffer;
24

2
  buffer << file.rdbuf();
25
4
  pinocchio::urdf::buildModelFromXML(buffer.str(),
26

6
                                     pinocchio::JointModelFreeFlyer(), model);
27


2
  BOOST_CHECK_EQUAL(model.name, "talos");
28
2
}
29
30
















4
BOOST_AUTO_TEST_CASE(test_get_reference_config_from_xml) {
31
4
  pinocchio::Model model;
32
  pinocchio::urdf::buildModel(aig::unittests::urdf,
33

2
                              pinocchio::JointModelFreeFlyer(), model);
34
  // creating the srdf file stream
35
4
  std::ifstream srdf_file(aig::unittests::srdf.c_str());
36
37
  // Load the srdf
38
4
  std::stringstream buffer;
39

2
  buffer << srdf_file.rdbuf();
40
2
  pinocchio::srdf::loadReferenceConfigurationsFromXML(model, buffer, false);
41

6
  Eigen::VectorXd q = model.referenceConfigurations["half_sitting"];
42



2
  BOOST_CHECK_EQUAL(q.size(), model.nq);
43
2
}
44
45
















4
BOOST_AUTO_TEST_CASE(test_get_reference_config) {
46
4
  pinocchio::Model model;
47
  pinocchio::urdf::buildModel(aig::unittests::urdf,
48

2
                              pinocchio::JointModelFreeFlyer(), model);
49
2
  pinocchio::srdf::loadReferenceConfigurations(model, aig::unittests::srdf,
50
                                               false);
51

6
  Eigen::VectorXd q = model.referenceConfigurations["half_sitting"];
52



2
  BOOST_CHECK_EQUAL(q.size(), model.nq);
53
2
}
54
55
















4
BOOST_AUTO_TEST_CASE(test_compute_joint_placement) {
56
4
  pinocchio::Model model;
57
  pinocchio::urdf::buildModel(aig::unittests::urdf,
58

2
                              pinocchio::JointModelFreeFlyer(), model);
59
2
  pinocchio::srdf::loadReferenceConfigurations(model, aig::unittests::srdf,
60
                                               false);
61

6
  Eigen::VectorXd q = model.referenceConfigurations["half_sitting"];
62
63
2
  Eigen::Vector3d test;
64

2
  test << -0.02, 0.085, -0.27105;
65



2
  BOOST_CHECK_EQUAL(test, model.jointPlacements[2].translation());
66
2
}
67
68
















4
BOOST_AUTO_TEST_CASE(test_compute_com) {
69
4
  pinocchio::Model model;
70
  pinocchio::urdf::buildModel(aig::unittests::urdf,
71

2
                              pinocchio::JointModelFreeFlyer(), model);
72
2
  pinocchio::srdf::loadReferenceConfigurations(model, aig::unittests::srdf,
73
                                               false);
74

6
  Eigen::VectorXd q = model.referenceConfigurations["half_sitting"];
75
4
  pinocchio::Data data(model);
76

2
  Eigen::Vector3d com = pinocchio::centerOfMass(model, data, q);
77
78
2
  Eigen::Vector3d test;
79

2
  test << -0.0031639, 0.00123738, 0.876681;
80



2
  BOOST_CHECK(test.isApprox(com, 1e-5));
81
2
}
82
83
















4
BOOST_AUTO_TEST_CASE(test_eigen_norms) {
84
2
  Eigen::Vector3d x(3, 4, 0);
85



2
  BOOST_CHECK_EQUAL(x.norm(), 5.0);
86
2
}
87
88
















4
BOOST_AUTO_TEST_CASE(test_se3) {
89
2
  pinocchio::SE3 se3;
90
2
  se3.setIdentity();
91



2
  BOOST_CHECK_EQUAL(se3.rotation(), Eigen::Matrix3d::Identity());
92



2
  BOOST_CHECK_EQUAL(se3.translation(), Eigen::Vector3d::Zero());
93
2
}
94
95
















4
BOOST_AUTO_TEST_CASE(test_skew) {
96
2
  Eigen::Vector3d v;
97

2
  v << 2, 3, 4;
98
2
  Eigen::Matrix3d skew_mat;
99




2
  skew_mat << 0, -4, 3, 4, 0, -2, -3, 2, 0;
100



2
  BOOST_CHECK_EQUAL(pinocchio::skew(v), skew_mat);
101
2
}
102
103
BOOST_AUTO_TEST_SUITE_END()