| Line |
Branch |
Exec |
Source |
| 1 |
|
|
// Copyright (c) 2018, CNRS |
| 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 |
|
|
#ifndef HPP_PINOCCHIO_SRC_DINTEGRATE_VISITOR_HH |
| 30 |
|
|
#define HPP_PINOCCHIO_SRC_DINTEGRATE_VISITOR_HH |
| 31 |
|
|
|
| 32 |
|
|
#include <hpp/pinocchio/liegroup/vector-space.hh> |
| 33 |
|
|
|
| 34 |
|
|
namespace hpp { |
| 35 |
|
|
namespace pinocchio { |
| 36 |
|
|
namespace liegroupType { |
| 37 |
|
|
template <int arg, DerivativeProduct side> |
| 38 |
|
|
struct dIntegrateVisitor : public boost::static_visitor<> { |
| 39 |
|
✗ |
dIntegrateVisitor(const vectorIn_t& q, vectorIn_t& v, matrixOut_t& Jq, |
| 40 |
|
|
size_type& row, size_type& configRow) |
| 41 |
|
✗ |
: q_(q), v_(v), Jq_(Jq), row_(row), configRow_(configRow) {} |
| 42 |
|
|
|
| 43 |
|
|
template <typename LgT> |
| 44 |
|
✗ |
void operator()(const LgT& lg) { |
| 45 |
|
|
// TODO add static asserts |
| 46 |
|
|
assert(arg == 0 || arg == 1); |
| 47 |
|
✗ |
typename LgT::JacobianMatrix_t JInt(lg.nv(), lg.nv()); |
| 48 |
|
|
if (arg == 0) |
| 49 |
|
✗ |
lg.dIntegrate_dq(q_.segment<LgT::NQ>(configRow_, lg.nq()), |
| 50 |
|
✗ |
v_.segment<LgT::NV>(row_, lg.nv()), JInt); |
| 51 |
|
|
else |
| 52 |
|
✗ |
lg.dIntegrate_dv(q_.segment<LgT::NQ>(configRow_, lg.nq()), |
| 53 |
|
✗ |
v_.segment<LgT::NV>(row_, lg.nv()), JInt); |
| 54 |
|
|
if (side == DerivativeTimesInput) |
| 55 |
|
✗ |
Jq_.middleRows<LgT::NV>(row_, lg.nv()).applyOnTheLeft(JInt); |
| 56 |
|
|
else |
| 57 |
|
✗ |
Jq_.middleCols<LgT::NV>(row_, lg.nv()).applyOnTheRight(JInt); |
| 58 |
|
✗ |
row_ += lg.nv(); |
| 59 |
|
✗ |
configRow_ += lg.nq(); |
| 60 |
|
|
} |
| 61 |
|
|
|
| 62 |
|
|
template <int N, bool rot> |
| 63 |
|
✗ |
void operator()(const liegroup::VectorSpaceOperation<N, rot>& lg) { |
| 64 |
|
✗ |
row_ += lg.nv(); |
| 65 |
|
✗ |
configRow_ += lg.nq(); |
| 66 |
|
|
} |
| 67 |
|
|
|
| 68 |
|
|
const vectorIn_t& q_; |
| 69 |
|
|
vectorIn_t& v_; |
| 70 |
|
|
matrixOut_t& Jq_; |
| 71 |
|
|
size_type& row_; |
| 72 |
|
|
size_type& configRow_; |
| 73 |
|
|
}; // struct dIntegrateVisitor |
| 74 |
|
|
} // namespace liegroupType |
| 75 |
|
|
} // namespace pinocchio |
| 76 |
|
|
} // namespace hpp |
| 77 |
|
|
|
| 78 |
|
|
#endif // HPP_PINOCCHIO_SRC_JINTEGRATE_VISITOR_HH |
| 79 |
|
|
|