| Directory: | ./ |
|---|---|
| File: | tests/set_gravity.cpp |
| Date: | 2025-05-10 01:12:46 |
| Exec | Total | Coverage | |
|---|---|---|---|
| Lines: | 12 | 12 | 100.0% |
| Branches: | 52 | 104 | 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/math/utils.hpp> | ||
| 24 | #include "tsid/robots/robot-wrapper.hpp" | ||
| 25 | |||
| 26 | using namespace tsid; | ||
| 27 | using namespace tsid::robots; | ||
| 28 | using namespace std; | ||
| 29 | using namespace pinocchio; | ||
| 30 | |||
| 31 | typedef pinocchio::Motion Motion; | ||
| 32 | |||
| 33 | BOOST_AUTO_TEST_SUITE(BOOST_TEST_MODULE) | ||
| 34 | |||
| 35 |
33/66✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 1 times.
✗ Branch 15 not taken.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
✓ Branch 23 taken 1 times.
✗ Branch 24 not taken.
✓ Branch 27 taken 1 times.
✗ Branch 28 not taken.
✓ Branch 30 taken 1 times.
✗ Branch 31 not taken.
✓ Branch 33 taken 1 times.
✗ Branch 34 not taken.
✓ Branch 36 taken 1 times.
✗ Branch 37 not taken.
✓ Branch 41 taken 1 times.
✗ Branch 42 not taken.
✓ Branch 45 taken 1 times.
✗ Branch 46 not taken.
✓ Branch 48 taken 1 times.
✗ Branch 49 not taken.
✓ Branch 52 taken 1 times.
✗ Branch 53 not taken.
✓ Branch 55 taken 1 times.
✗ Branch 56 not taken.
✓ Branch 58 taken 1 times.
✗ Branch 59 not taken.
✓ Branch 61 taken 1 times.
✗ Branch 62 not taken.
✓ Branch 66 taken 1 times.
✗ Branch 67 not taken.
✓ Branch 70 taken 1 times.
✗ Branch 71 not taken.
✓ Branch 73 taken 1 times.
✗ Branch 74 not taken.
✓ Branch 77 taken 1 times.
✗ Branch 78 not taken.
✓ Branch 80 taken 1 times.
✗ Branch 81 not taken.
✓ Branch 83 taken 1 times.
✗ Branch 84 not taken.
✓ Branch 86 taken 1 times.
✗ Branch 87 not taken.
✓ Branch 91 taken 1 times.
✗ Branch 92 not taken.
✓ Branch 95 taken 1 times.
✗ Branch 96 not taken.
✓ Branch 98 taken 1 times.
✗ Branch 99 not taken.
✓ Branch 102 taken 1 times.
✗ Branch 103 not taken.
✓ Branch 105 taken 1 times.
✗ Branch 106 not taken.
✓ Branch 108 taken 1 times.
✗ Branch 109 not taken.
✓ Branch 111 taken 1 times.
✗ Branch 112 not taken.
✓ Branch 116 taken 1 times.
✗ Branch 117 not taken.
|
4 | BOOST_AUTO_TEST_CASE(test_set_gravity) { |
| 36 |
1/2✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
2 | const string romeo_model_path = TSID_SOURCE_DIR "/models/romeo"; |
| 37 | |||
| 38 | 2 | vector<string> package_dirs; | |
| 39 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | package_dirs.push_back(romeo_model_path); |
| 40 |
1/2✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
2 | string urdfFileName = package_dirs[0] + "/urdf/romeo.urdf"; |
| 41 | RobotWrapper robot(urdfFileName, package_dirs, | ||
| 42 |
3/6✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
|
2 | pinocchio::JointModelFreeFlyer(), false); |
| 43 | |||
| 44 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Motion g = pinocchio::Motion::Zero(); |
| 45 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
2 | Motion init_gravity = robot.model().gravity; |
| 46 | |||
| 47 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | robot.setGravity(g); |
| 48 | |||
| 49 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
2 | Motion no_gravity = robot.model().gravity; |
| 50 | |||
| 51 |
7/14✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 1 times.
✗ Branch 15 not taken.
✓ Branch 17 taken 1 times.
✗ Branch 18 not taken.
✓ Branch 20 taken 1 times.
✗ Branch 21 not taken.
✗ Branch 25 not taken.
✓ Branch 26 taken 1 times.
|
2 | BOOST_CHECK(no_gravity != init_gravity); |
| 52 | 2 | } | |
| 53 | |||
| 54 | BOOST_AUTO_TEST_SUITE_END() | ||
| 55 |