Directory: | ./ |
---|---|
File: | src/path/hermite.cc |
Date: | 2024-12-13 16:14:03 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 49 | 57 | 86.0% |
Branches: | 71 | 156 | 45.5% |
Line | Branch | Exec | Source |
---|---|---|---|
1 | // Copyright (c) 2016, Joseph Mirabel | ||
2 | // Authors: Joseph Mirabel (joseph.mirabel@laas.fr) | ||
3 | // | ||
4 | |||
5 | // Redistribution and use in source and binary forms, with or without | ||
6 | // modification, are permitted provided that the following conditions are | ||
7 | // met: | ||
8 | // | ||
9 | // 1. Redistributions of source code must retain the above copyright | ||
10 | // notice, this list of conditions and the following disclaimer. | ||
11 | // | ||
12 | // 2. Redistributions in binary form must reproduce the above copyright | ||
13 | // notice, this list of conditions and the following disclaimer in the | ||
14 | // documentation and/or other materials provided with the distribution. | ||
15 | // | ||
16 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
17 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
18 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
19 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
20 | // HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
21 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
22 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
23 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
24 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
25 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
26 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH | ||
27 | // DAMAGE. | ||
28 | |||
29 | #include <hpp/core/config-projector.hh> | ||
30 | #include <hpp/core/path/hermite.hh> | ||
31 | #include <hpp/core/projection-error.hh> | ||
32 | #include <hpp/pinocchio/configuration.hh> | ||
33 | #include <hpp/pinocchio/device.hh> | ||
34 | #include <hpp/pinocchio/liegroup.hh> | ||
35 | #include <hpp/util/debug.hh> | ||
36 | |||
37 | namespace hpp { | ||
38 | namespace core { | ||
39 | namespace path { | ||
40 | 1852569 | Hermite::Hermite(const DevicePtr_t& device, ConfigurationIn_t init, | |
41 | 1852569 | ConfigurationIn_t end, ConstraintSetPtr_t constraints) | |
42 | ✗ | : parent_t(device, interval_t(0, 1), constraints), | |
43 |
1/2✓ Branch 1 taken 1852569 times.
✗ Branch 2 not taken.
|
1852569 | init_(init), |
44 |
1/2✓ Branch 1 taken 1852569 times.
✗ Branch 2 not taken.
|
1852569 | end_(end), |
45 |
1/2✓ Branch 2 taken 1852569 times.
✗ Branch 3 not taken.
|
3705138 | hermiteLength_(-1) { |
46 |
2/4✓ Branch 3 taken 1852569 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 1852569 times.
|
1852569 | assert(init.size() == robot_->configSize()); |
47 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1852569 times.
|
1852569 | assert(device); |
48 | |||
49 |
2/4✓ Branch 1 taken 1852569 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1852569 times.
✗ Branch 5 not taken.
|
1852569 | base(init); |
50 |
2/4✓ Branch 1 taken 1852569 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1852569 times.
✗ Branch 5 not taken.
|
1852569 | parameters_.row(0).setZero(); |
51 |
4/8✓ Branch 1 taken 1852569 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1852569 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1852569 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1852569 times.
✗ Branch 11 not taken.
|
1852569 | pinocchio::difference<hpp::pinocchio::RnxSOnLieGroupMap>(robot_, end, init, |
52 |
1/2✓ Branch 1 taken 1852569 times.
✗ Branch 2 not taken.
|
1852569 | parameters_.row(3)); |
53 | |||
54 |
3/6✓ Branch 1 taken 1852569 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1852569 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1852569 times.
✗ Branch 8 not taken.
|
1852569 | projectVelocities(init, end); |
55 | 1852569 | } | |
56 | |||
57 | 1852592 | Hermite::Hermite(const Hermite& path) | |
58 |
2/4✓ Branch 3 taken 1852592 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 1852592 times.
✗ Branch 7 not taken.
|
1852592 | : parent_t(path), init_(path.init_), end_(path.end_), hermiteLength_(-1) {} |
59 | |||
60 | ✗ | Hermite::Hermite(const Hermite& path, const ConstraintSetPtr_t& constraints) | |
61 | : parent_t(path, constraints), | ||
62 | ✗ | init_(path.init_), | |
63 | ✗ | end_(path.end_), | |
64 | ✗ | hermiteLength_(-1) { | |
65 | ✗ | projectVelocities(init_, end_); | |
66 | } | ||
67 | |||
68 | 3705161 | void Hermite::init(HermitePtr_t self) { | |
69 |
1/2✓ Branch 2 taken 3705161 times.
✗ Branch 3 not taken.
|
3705161 | parent_t::init(self); |
70 | 3705161 | weak_ = self; | |
71 | 3705161 | checkPath(); | |
72 | 3705161 | } | |
73 | |||
74 | // void Hermite::computeVelocities (ConfigurationIn_t qi, ConfigurationIn_t qe) | ||
75 | 1852569 | void Hermite::projectVelocities(ConfigurationIn_t qi, ConfigurationIn_t qe) { | |
76 | // vector_t v_i2e (outputDerivativeSize()); | ||
77 | // pinocchio::difference<hpp::pinocchio::LieGroupTpl> (robot_, qe, qi, v_i2e); | ||
78 |
7/12✓ Branch 2 taken 1852569 times.
✗ Branch 3 not taken.
✓ Branch 7 taken 1852569 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1852568 times.
✓ Branch 11 taken 1 times.
✓ Branch 12 taken 1852569 times.
✗ Branch 13 not taken.
✓ Branch 15 taken 1852568 times.
✓ Branch 16 taken 1 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
|
1852569 | if (constraints() && constraints()->configProjector()) { |
79 |
1/2✓ Branch 3 taken 1852568 times.
✗ Branch 4 not taken.
|
1852568 | ConfigProjectorPtr_t proj = constraints()->configProjector(); |
80 |
1/2✓ Branch 2 taken 1852568 times.
✗ Branch 3 not taken.
|
1852568 | vector_t v(outputDerivativeSize()); |
81 | // Compute v0 | ||
82 | // proj->projectVectorOnKernel (qi, v_i2e, v); | ||
83 |
5/10✓ Branch 2 taken 1852568 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 1852568 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 1852568 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 1852568 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 1852568 times.
✗ Branch 15 not taken.
|
1852568 | proj->projectVectorOnKernel(qi, parameters_.row(3), v); |
84 |
2/4✓ Branch 1 taken 1852568 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1852568 times.
✗ Branch 5 not taken.
|
1852568 | v0(v); |
85 | // Compute v1 | ||
86 |
5/10✓ Branch 2 taken 1852568 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 1852568 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 1852568 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 1852568 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 1852568 times.
✗ Branch 15 not taken.
|
1852568 | proj->projectVectorOnKernel(qe, parameters_.row(3), v); |
87 |
2/4✓ Branch 1 taken 1852568 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1852568 times.
✗ Branch 5 not taken.
|
1852568 | v1(v); |
88 | 1852568 | } else { | |
89 |
2/4✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
|
1 | v0(parameters_.row(3)); |
90 |
2/4✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
|
1 | v1(parameters_.row(3)); |
91 | } | ||
92 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1852569 times.
|
1852569 | assert(!parameters_.hasNaN()); |
93 | 1852569 | } | |
94 | |||
95 | 3705168 | void Hermite::computeHermiteLength() { | |
96 |
2/4✓ Branch 2 taken 3705168 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 3705168 times.
✗ Branch 6 not taken.
|
3705168 | hermiteLength_ = (parameters_.bottomRows<3>() - parameters_.topRows<3>()) |
97 |
1/2✓ Branch 1 taken 3705168 times.
✗ Branch 2 not taken.
|
3705168 | .rowwise() |
98 |
1/2✓ Branch 1 taken 3705168 times.
✗ Branch 2 not taken.
|
3705168 | .norm() |
99 |
1/2✓ Branch 1 taken 3705168 times.
✗ Branch 2 not taken.
|
3705168 | .sum(); |
100 | 3705168 | } | |
101 | |||
102 | 926268 | vector_t Hermite::velocity(const value_type& param) const { | |
103 |
1/2✓ Branch 2 taken 926268 times.
✗ Branch 3 not taken.
|
926268 | vector_t v(outputDerivativeSize()); |
104 |
2/4✓ Branch 1 taken 926268 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 926268 times.
✗ Branch 5 not taken.
|
926268 | derivative(v, param, 1); |
105 |
5/12✓ Branch 2 taken 926268 times.
✗ Branch 3 not taken.
✓ Branch 7 taken 926268 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 926268 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 926268 times.
✗ Branch 13 not taken.
✓ Branch 15 taken 926268 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
|
926268 | if (constraints() && constraints()->configProjector()) { |
106 |
1/2✓ Branch 3 taken 926268 times.
✗ Branch 4 not taken.
|
926268 | ConfigProjectorPtr_t proj = constraints()->configProjector(); |
107 |
1/2✓ Branch 2 taken 926268 times.
✗ Branch 3 not taken.
|
926268 | Configuration_t q(outputSize()); |
108 |
3/6✓ Branch 1 taken 926268 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 926268 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 926268 times.
|
926268 | if (!eval(q, param)) |
109 | ✗ | throw projection_error("Configuration does not satisfy the constraints"); | |
110 |
4/8✓ Branch 2 taken 926268 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 926268 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 926268 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 926268 times.
✗ Branch 12 not taken.
|
926268 | proj->projectVectorOnKernel(q, v, v); |
111 | 926268 | } | |
112 | 926268 | return v; | |
113 | } | ||
114 | |||
115 | ✗ | DevicePtr_t Hermite::device() const { return robot_; } | |
116 | } // namespace path | ||
117 | } // namespace core | ||
118 | } // namespace hpp | ||
119 |