hpp-core: include/hpp/core/subchain-path.hh Source File

hpp-core 9.0.2 Implement basic classes for canonical path planning for kinematic chains.

Loading...
Searching...
No Matches
subchain-path.hh
Go to the documentation of this file.
1//
2// Copyright (c) 2016 CNRS
3// Authors: Joseph Mirabel
4//
5
6// Redistribution and use in source and binary forms, with or without
7// modification, are permitted provided that the following conditions are
8// met:
9//
10// 1. Redistributions of source code must retain the above copyright
11// notice, this list of conditions and the following disclaimer.
12//
13// 2. Redistributions in binary form must reproduce the above copyright
14// notice, this list of conditions and the following disclaimer in the
15// documentation and/or other materials provided with the distribution.
16//
17// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21// HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
28// DAMAGE.
29
30#ifndef HPP_CORE_DOF_EXTRACTED_PATH_HH
31#define HPP_CORE_DOF_EXTRACTED_PATH_HH
32
33#include <hpp/constraints/matrix-view.hh>
34#include <hpp/core/path.hh>
35
36namespace hpp {
37namespace core {
40
44 class SubchainPath : public Path {
45 public:
46 typedef Path parent_t;
47
48 virtual ~SubchainPath() {}
49
51 virtual PathPtr_t copy() const { return createCopy(weak_.lock()); }
52
57 virtual PathPtr_t copy(const ConstraintSetPtr_t& constraints) const {
58 return createCopy(weak_.lock(), constraints);
59 }
60
62 static SubchainPathPtr_t create(const PathPtr_t& original,
63 const segments_t& confIntervals,
64 const segments_t& velIntervals) {
65 SubchainPath* ptr = new SubchainPath(original, confIntervals, velIntervals);
66 SubchainPathPtr_t shPtr(ptr);
67 ptr->init(shPtr);
68 return shPtr;
69 }
70
71 static SubchainPathPtr_t createCopy(const SubchainPathPtr_t& path) {
72 SubchainPath* ptr = new SubchainPath(*path);
73 SubchainPathPtr_t shPtr(ptr);
74 ptr->init(shPtr);
75 return shPtr;
76 }
77
78 static SubchainPathPtr_t createCopy(const SubchainPathPtr_t& path,
79 const ConstraintSetPtr_t& constraints) {
80 SubchainPath* ptr = new SubchainPath(*path, constraints);
81 SubchainPathPtr_t shPtr(ptr);
82 ptr->init(shPtr);
83 return shPtr;
84 }
85
86 virtual bool impl_compute(ConfigurationOut_t result, value_type param) const {
87 bool success = original_->eval(q_, param);
88 if (success) dofExtract(q_, result);
89 return success;
90 }
91
93 inline Configuration_t initial() const {
94 Configuration_t q(outputSize());
95 dofExtract(original_->initial(), q);
96 return q;
97 }
98
100 inline Configuration_t end() const {
101 Configuration_t q(outputSize());
102 dofExtract(original_->end(), q);
103 return q;
104 }
105
106 void dofExtract(ConfigurationIn_t qin, ConfigurationOut_t qout) const {
107 qout = configView_.rview(qin);
108 }
109
110 protected:
112 virtual std::ostream& print(std::ostream& os) const {
113 os << "Dof Extracted Path:" << std::endl;
114 os << "intervals: " << configView_ << std::endl;
115 os << "original path:" << std::endl;
116 os << *original_ << std::endl;
117 return os;
118 }
119
125 SubchainPath(const PathPtr_t& original, const segments_t& confIntervals,
126 const segments_t& velIntervals)
127 : Path(original->timeRange(), Eigen::BlockIndex::cardinal(confIntervals),
128 Eigen::BlockIndex::cardinal(velIntervals)),
129 original_(original),
130 configView_(confIntervals),
131 q_(Configuration_t::Zero(original->outputSize())) {}
132
133 SubchainPath(const SubchainPath& path)
134 : Path(path),
135 original_(path.original_),
136 configView_(path.configView_),
137 q_(path.q_),
138 weak_() {}
139
140 SubchainPath(const SubchainPath& path, const ConstraintSetPtr_t& constraints)
141 : Path(path, constraints),
142 original_(path.original_),
143 configView_(path.configView_),
144 weak_() {}
145
146 void init(SubchainPathPtr_t self) {
147 parent_t::init(self);
148 weak_ = self;
149 }
150
151 private:
152 PathPtr_t original_;
153 Eigen::RowBlockIndices configView_, velView_;
154 mutable Configuration_t q_;
155 SubchainPathWkPtr_t weak_;
156}; // SubchainPath
158} // namespace core
159} // namespace hpp
160#endif // HPP_CORE_DOF_EXTRACTED_PATH_HH
Eigen::MatrixBlocksBase::rview
EIGEN_STRONG_INLINE View< constMatrixType >::type rview(const MatrixBase< MatrixType > &other) const
Eigen::MatrixBlocks< false, true >
hpp::core::Path
Definition path.hh:71
hpp::core::Path::outputSize
size_type outputSize() const
Get size of configuration space.
Definition path.hh:184
hpp::core::Path::init
void init(const PathWkPtr_t &self)
hpp::core::Path::timeRange
const interval_t & timeRange() const
Get interval of definition.
Definition path.hh:190
hpp::core::Path::constraints
const ConstraintSetPtr_t & constraints() const
Get constraints the path is subject to.
Definition path.hh:204
hpp::core::SubchainPath
Definition subchain-path.hh:44
hpp::core::SubchainPath::copy
virtual PathPtr_t copy() const
Return a shared pointer to a copy of this.
Definition subchain-path.hh:51
hpp::core::SubchainPath::end
Configuration_t end() const
Get the final configuration.
Definition subchain-path.hh:100
hpp::core::SubchainPath::createCopy
static SubchainPathPtr_t createCopy(const SubchainPathPtr_t &path)
Definition subchain-path.hh:71
hpp::core::SubchainPath::dofExtract
void dofExtract(ConfigurationIn_t qin, ConfigurationOut_t qout) const
Definition subchain-path.hh:106
hpp::core::SubchainPath::createCopy
static SubchainPathPtr_t createCopy(const SubchainPathPtr_t &path, const ConstraintSetPtr_t &constraints)
Definition subchain-path.hh:78
hpp::core::SubchainPath::impl_compute
virtual bool impl_compute(ConfigurationOut_t result, value_type param) const
Function evaluation without applying constraints.
Definition subchain-path.hh:86
hpp::core::SubchainPath::~SubchainPath
virtual ~SubchainPath()
Definition subchain-path.hh:48
hpp::core::SubchainPath::SubchainPath
SubchainPath(const SubchainPath &path, const ConstraintSetPtr_t &constraints)
Definition subchain-path.hh:140
hpp::core::SubchainPath::create
static SubchainPathPtr_t create(const PathPtr_t &original, const segments_t &confIntervals, const segments_t &velIntervals)
Definition subchain-path.hh:62
hpp::core::SubchainPath::SubchainPath
SubchainPath(const SubchainPath &path)
Definition subchain-path.hh:133
hpp::core::SubchainPath::parent_t
Path parent_t
Definition subchain-path.hh:46
hpp::core::SubchainPath::SubchainPath
SubchainPath(const PathPtr_t &original, const segments_t &confIntervals, const segments_t &velIntervals)
Definition subchain-path.hh:125
hpp::core::SubchainPath::copy
virtual PathPtr_t copy(const ConstraintSetPtr_t &constraints) const
Definition subchain-path.hh:57
hpp::core::SubchainPath::print
virtual std::ostream & print(std::ostream &os) const
Print path in a stream.
Definition subchain-path.hh:112
hpp::core::SubchainPath::init
void init(SubchainPathPtr_t self)
Definition subchain-path.hh:146
hpp::core::SubchainPath::initial
Configuration_t initial() const
Get the initial configuration.
Definition subchain-path.hh:93
matrix-view.hh
Eigen
hpp
hpp::core::value_type
pinocchio::value_type value_type
Definition fwd.hh:174
hpp::core::SubchainPathPtr_t
shared_ptr< SubchainPath > SubchainPathPtr_t
Definition fwd.hh:147
hpp::core::segments_t
constraints::segments_t segments_t
Definition fwd.hh:179
hpp::core::ConfigurationOut_t
pinocchio::ConfigurationOut_t ConfigurationOut_t
Definition fwd.hh:109
hpp::core::ConfigurationIn_t
pinocchio::ConfigurationIn_t ConfigurationIn_t
Definition fwd.hh:108
hpp::core::Configuration_t
pinocchio::Configuration_t Configuration_t
Definition fwd.hh:107
hpp::core::ConstraintSetPtr_t
shared_ptr< ConstraintSet > ConstraintSetPtr_t
Definition fwd.hh:130
hpp::core::PathPtr_t
shared_ptr< Path > PathPtr_t
Definition fwd.hh:187
path.hh
Eigen::BlockIndex