GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: tests/robot-wrapper.cpp Lines: 22 22 100.0 %
Date: 2024-05-10 01:36:27 Branches: 75 150 50.0 %

Line Branch Exec Source
1
//
2
// Copyright (c) 2017 CNRS
3
//
4
// This file is part of tsid
5
// tsid is free software: you can redistribute it
6
// and/or modify it under the terms of the GNU Lesser General Public
7
// License as published by the Free Software Foundation, either version
8
// 3 of the License, or (at your option) any later version.
9
// tsid is distributed in the hope that it will be
10
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
11
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
// General Lesser Public License for more details. You should have
13
// received a copy of the GNU Lesser General Public License along with
14
// tsid If not, see
15
// <http://www.gnu.org/licenses/>.
16
//
17
18
#include <iostream>
19
20
#include <boost/test/unit_test.hpp>
21
#include <boost/utility/binary.hpp>
22
23
#include "tsid/robots/robot-wrapper.hpp"
24
#include <pinocchio/algorithm/joint-configuration.hpp>
25
26
using namespace tsid;
27
using namespace tsid::math;
28
using namespace tsid::robots;
29
30
BOOST_AUTO_TEST_SUITE(BOOST_TEST_MODULE)
31
32
















4
BOOST_AUTO_TEST_CASE(test_robot_wrapper) {
33
  using namespace std;
34
  using namespace pinocchio;
35
36
4
  const string romeo_model_path = TSID_SOURCE_DIR "/models/romeo";
37
38
4
  vector<string> package_dirs;
39
2
  package_dirs.push_back(romeo_model_path);
40
4
  string urdfFileName = package_dirs[0] + "/urdf/romeo.urdf";
41
42
  RobotWrapper robot(urdfFileName, package_dirs,
43

4
                     pinocchio::JointModelFreeFlyer(), false);
44
45
2
  const Model& model = robot.model();
46
47
  // Update default config bounds to take into account the Free Flyer
48
4
  Vector lb(model.lowerPositionLimit);
49

2
  lb.head<3>().fill(-10.);
50

2
  lb.segment<4>(3).fill(-1.);
51
52
4
  Vector ub(model.upperPositionLimit);
53

2
  ub.head<3>().fill(10.);
54

2
  ub.segment<4>(3).fill(1.);
55
56
4
  Vector q = pinocchio::randomConfiguration(model, lb, ub);
57

4
  Vector v = Vector::Ones(robot.nv());
58

4
  Data data(robot.model());
59
2
  robot.computeAllTerms(data, q, v);
60
61

2
  Vector3 com = robot.com(data);
62

2
  std::cout << com << std::endl;
63



2
  BOOST_CHECK(robot.nq() == 38);
64



2
  BOOST_CHECK(robot.nv() == 37);
65
2
}
66
67
BOOST_AUTO_TEST_SUITE_END()