Directory: | ./ |
---|---|
File: | tests/control/test_control_admittance.cpp |
Date: | 2024-12-13 12:22:33 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 27 | 27 | 100.0% |
Branches: | 100 | 200 | 50.0% |
Line | Branch | Exec | Source |
---|---|---|---|
1 | /* | ||
2 | * Copyright 2019, | ||
3 | * Noƫlie Ramuzat, | ||
4 | * | ||
5 | * | ||
6 | */ | ||
7 | |||
8 | #include <iostream> | ||
9 | #include <sot/core/debug.hh> | ||
10 | |||
11 | #ifndef WIN32 | ||
12 | #include <unistd.h> | ||
13 | #endif | ||
14 | |||
15 | using namespace std; | ||
16 | |||
17 | #include <dynamic-graph/entity.h> | ||
18 | #include <dynamic-graph/factory.h> | ||
19 | |||
20 | #include <sot/core/admittance-control-op-point.hh> | ||
21 | #include <sstream> | ||
22 | |||
23 | using namespace dynamicgraph; | ||
24 | using namespace dynamicgraph::sot; | ||
25 | |||
26 | #define BOOST_TEST_MODULE debug - control - admittance | ||
27 | |||
28 | #include <boost/test/output_test_stream.hpp> | ||
29 | #include <boost/test/unit_test.hpp> | ||
30 | |||
31 |
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(control_admittance) { |
32 | sot::core::AdmittanceControlOpPoint *aControlAdm = | ||
33 |
3/6✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
|
2 | new sot::core::AdmittanceControlOpPoint("acontrol_admittance"); |
34 | |||
35 |
2/4✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
|
4 | std::istringstream Kp("[6](10.0,10.0,10.0,10.0,10.0,10.0)"); |
36 |
2/4✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
|
4 | std::istringstream Kd("[6](0.0,0.0,0.0,0.0,0.0,0.0)"); |
37 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | aControlAdm->m_KpSIN.set(Kp); |
38 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | aControlAdm->m_KdSIN.set(Kd); |
39 |
2/4✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
|
4 | std::istringstream dqSaturation("[6](10.0,10.0,10.0,10.0,10.0,10.0)"); |
40 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | aControlAdm->m_dqSaturationSIN.set(dqSaturation); |
41 |
2/4✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
|
4 | std::istringstream w_forceDes("[6](100.0,0.0,0.0,0.0,0.0,0.0)"); |
42 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | aControlAdm->m_w_forceDesSIN.set(w_forceDes); |
43 |
2/4✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
|
4 | std::istringstream force("[6](10.0,0.0,10.0,0.0,0.0,0.0)"); |
44 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | aControlAdm->m_forceSIN.set(force); |
45 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | MatrixHomogeneous opPose; |
46 |
4/8✓ 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.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
|
2 | opPose.translation() << 0.3, 0.0, 0.0; |
47 |
10/20✓ 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.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 1 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 1 times.
✗ Branch 23 not taken.
✓ Branch 25 taken 1 times.
✗ Branch 26 not taken.
✓ Branch 28 taken 1 times.
✗ Branch 29 not taken.
|
2 | opPose.linear() << 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0; |
48 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | aControlAdm->m_opPoseSIN = opPose; |
49 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | MatrixHomogeneous sensorPose; |
50 |
4/8✓ 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.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
|
2 | sensorPose.translation() << 0.3, 0.0, 0.0; |
51 |
10/20✓ 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.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 1 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 1 times.
✗ Branch 23 not taken.
✓ Branch 25 taken 1 times.
✗ Branch 26 not taken.
✓ Branch 28 taken 1 times.
✗ Branch 29 not taken.
|
2 | sensorPose.linear() << 0.0, 0.0, -1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0; |
52 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | aControlAdm->m_sensorPoseSIN = sensorPose; |
53 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | aControlAdm->init(0.001); |
54 | |||
55 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | aControlAdm->m_dqSOUT.recompute(0); |
56 | { | ||
57 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | dynamicgraph::Vector expected(6); |
58 |
6/12✓ 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.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 1 times.
✗ Branch 17 not taken.
|
2 | expected << 1.1, 0.0, -0.109, 0.0, 0.03, 0.0; |
59 |
8/16✓ 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 18 taken 1 times.
✗ Branch 19 not taken.
✓ Branch 21 taken 1 times.
✗ Branch 22 not taken.
✓ Branch 24 taken 1 times.
✗ Branch 25 not taken.
✗ Branch 29 not taken.
✓ Branch 30 taken 1 times.
|
2 | BOOST_CHECK(aControlAdm->m_dqSOUT(0).isApprox(expected)); |
60 | 2 | } | |
61 | 2 | } | |
62 |