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

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

Loading...
Searching...
No Matches
path-vector.hh
Go to the documentation of this file.
1//
2// Copyright (c) 2014 CNRS
3// Authors: Florent Lamiraux
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_PATH_VECTOR_HH
31#define HPP_CORE_PATH_VECTOR_HH
32
33#include <hpp/core/fwd.hh>
34#include <hpp/core/path.hh>
35#include <hpp/pinocchio/device.hh>
36
37namespace hpp {
38namespace core {
41
43 class HPP_CORE_DLLAPI PathVector : public Path {
44 public:
45 typedef Path parent_t;
48
50 static PathVectorPtr_t create(size_type outputSize,
51 size_type outputDerivativeSize) {
52 PathVector* ptr = new PathVector(outputSize, outputDerivativeSize);
53 PathVectorPtr_t shPtr(ptr);
54 ptr->init(shPtr);
55 return shPtr;
56 }
57
59 static PathVectorPtr_t create(size_type outputSize,
60 size_type outputDerivativeSize,
61 const ConstraintSetPtr_t& constraint) {
62 PathVector* ptr =
63 new PathVector(outputSize, outputDerivativeSize, constraint);
64 PathVectorPtr_t shPtr(ptr);
65 ptr->init(shPtr);
66 return shPtr;
67 }
68
70 static PathVectorPtr_t createCopy(const PathVectorPtr_t& original) {
71 PathVector* ptr = new PathVector(*original);
72 PathVectorPtr_t shPtr(ptr);
73 ptr->init(shPtr);
74 return shPtr;
75 }
76
78 static PathVectorPtr_t createCopy(const PathVectorPtr_t& original,
79 const ConstraintSetPtr_t& constraints) {
80 PathVector* ptr = new PathVector(*original, constraints);
81 PathVectorPtr_t shPtr(ptr);
82 ptr->init(shPtr);
83 return shPtr;
84 }
85
87 virtual PathPtr_t copy() const { return createCopy(weak_.lock()); }
88
92 virtual PathPtr_t copy(const ConstraintSetPtr_t& constraints) const {
93 return createCopy(weak_.lock(), constraints);
94 }
95
97 virtual ~PathVector() {}
99
101 std::size_t numberPaths() const { return paths_.size(); }
102
109 PathPtr_t pathAtRank(std::size_t rank) const;
110
116 std::size_t rankAtParam(const value_type& param,
117 value_type& localParam) const;
118
120 void appendPath(const PathPtr_t& path);
121
126 void concatenate(const PathVectorPtr_t& path);
127
129 virtual Configuration_t initial() const { return paths_.front()->initial(); }
130
132 virtual Configuration_t end() const { return paths_.back()->end(); }
133
136 void flatten(PathVectorPtr_t flattenedPath) const;
137
138 protected:
140 virtual std::ostream& print(std::ostream& os) const;
142 PathVector(std::size_t outputSize, std::size_t outputDerivativeSize)
143 : parent_t(std::make_pair(0, 0), outputSize, outputDerivativeSize),
144 paths_() {}
146 PathVector(std::size_t outputSize, std::size_t outputDerivativeSize,
147 const ConstraintSetPtr_t& constraint)
148 : parent_t(std::make_pair(0, 0), outputSize, outputDerivativeSize,
149 constraint),
150 paths_() {}
152 PathVector(const PathVector& path) : parent_t(path), paths_() {
153 assert(timeRange() == path.timeRange());
154 for (Paths_t::const_iterator it = path.paths_.begin();
155 it != path.paths_.end(); it++) {
156 paths_.push_back((*it)->copy());
157 }
158 }
159
161 PathVector(const PathVector& path, const ConstraintSetPtr_t& constraints)
162 : parent_t(path, constraints), paths_() {
163 assert(timeRange() == path.timeRange());
164 for (Paths_t::const_iterator it = path.paths_.begin();
165 it != path.paths_.end(); it++) {
166 paths_.push_back((*it)->copy());
167 }
168 }
169
170 void init(PathVectorPtr_t self) {
171 parent_t::init(self);
172 weak_ = self;
173 }
174 virtual bool impl_compute(ConfigurationOut_t result, value_type t) const;
176 virtual void impl_derivative(vectorOut_t result, const value_type& t,
177 size_type order) const;
180 virtual PathPtr_t impl_extract(const interval_t& subInterval) const;
181
183 virtual void impl_velocityBound(vectorOut_t bound, const value_type& param0,
184 const value_type& param1) const;
185
186 private:
187 Paths_t paths_;
188 PathVectorWkPtr_t weak_;
189
190 protected:
191 PathVector() {}
192
193 private:
194 HPP_SERIALIZABLE();
195}; // class PathVector
197} // namespace core
198} // namespace hpp
199
200BOOST_CLASS_EXPORT_KEY(hpp::core::PathVector)
201
202#endif // HPP_CORE_PATH_VECTOR_HH
hpp::core::PathVector
Concatenation of several paths.
Definition path-vector.hh:43
hpp::core::PathVector::numberPaths
std::size_t numberPaths() const
Get the number of sub paths.
Definition path-vector.hh:101
hpp::core::PathVector::create
static PathVectorPtr_t create(size_type outputSize, size_type outputDerivativeSize, const ConstraintSetPtr_t &constraint)
Create instance and return shared pointer.
Definition path-vector.hh:59
hpp::core::PathVector::impl_velocityBound
virtual void impl_velocityBound(vectorOut_t bound, const value_type &param0, const value_type &param1) const
Virtual implementation of velocity bound.
hpp::core::PathVector::concatenate
void concatenate(const PathVectorPtr_t &path)
hpp::core::PathVector::PathVector
PathVector(const PathVector &path, const ConstraintSetPtr_t &constraints)
Copy constructor with constraints.
Definition path-vector.hh:161
hpp::core::PathVector::pathAtRank
PathPtr_t pathAtRank(std::size_t rank) const
hpp::core::PathVector::impl_derivative
virtual void impl_derivative(vectorOut_t result, const value_type &t, size_type order) const
Virtual implementation of derivative.
hpp::core::PathVector::PathVector
PathVector(std::size_t outputSize, std::size_t outputDerivativeSize, const ConstraintSetPtr_t &constraint)
Constructor.
Definition path-vector.hh:146
hpp::core::PathVector::impl_compute
virtual bool impl_compute(ConfigurationOut_t result, value_type t) const
Function evaluation without applying constraints.
hpp::core::PathVector::createCopy
static PathVectorPtr_t createCopy(const PathVectorPtr_t &original, const ConstraintSetPtr_t &constraints)
Create instance and return shared pointer.
Definition path-vector.hh:78
hpp::core::PathVector::copy
virtual PathPtr_t copy() const
Return a shared pointer to a copy of this.
Definition path-vector.hh:87
hpp::core::PathVector::copy
virtual PathPtr_t copy(const ConstraintSetPtr_t &constraints) const
Definition path-vector.hh:92
hpp::core::PathVector::PathVector
PathVector(std::size_t outputSize, std::size_t outputDerivativeSize)
Constructor.
Definition path-vector.hh:142
hpp::core::PathVector::init
void init(PathVectorPtr_t self)
Definition path-vector.hh:170
hpp::core::PathVector::PathVector
PathVector()
Definition path-vector.hh:191
hpp::core::PathVector::parent_t
Path parent_t
Definition path-vector.hh:45
hpp::core::PathVector::initial
virtual Configuration_t initial() const
Get the initial configuration.
Definition path-vector.hh:129
hpp::core::PathVector::print
virtual std::ostream & print(std::ostream &os) const
Print path in a stream.
hpp::core::PathVector::appendPath
void appendPath(const PathPtr_t &path)
Append a path at the end of the vector.
hpp::core::PathVector::createCopy
static PathVectorPtr_t createCopy(const PathVectorPtr_t &original)
Create instance and return shared pointer.
Definition path-vector.hh:70
hpp::core::PathVector::PathVector
PathVector(const PathVector &path)
Copy constructor.
Definition path-vector.hh:152
hpp::core::PathVector::impl_extract
virtual PathPtr_t impl_extract(const interval_t &subInterval) const
hpp::core::PathVector::end
virtual Configuration_t end() const
Get the final configuration.
Definition path-vector.hh:132
hpp::core::PathVector::flatten
void flatten(PathVectorPtr_t flattenedPath) const
hpp::core::PathVector::rankAtParam
std::size_t rankAtParam(const value_type &param, value_type &localParam) const
hpp::core::PathVector::~PathVector
virtual ~PathVector()
Destructor.
Definition path-vector.hh:97
hpp::core::PathVector::create
static PathVectorPtr_t create(size_type outputSize, size_type outputDerivativeSize)
Create instance and return shared pointer.
Definition path-vector.hh:50
hpp::core::Path
Definition path.hh:71
hpp::core::Path::timeRange
const interval_t & timeRange() const
Get interval of definition.
Definition path.hh:190
HPP_CORE_DLLAPI
#define HPP_CORE_DLLAPI
Definition config.hh:88
device.hh
fwd.hh
hpp
hpp::core::value_type
pinocchio::value_type value_type
Definition fwd.hh:174
hpp::core::PathVectorPtr_t
shared_ptr< PathVector > PathVectorPtr_t
Definition fwd.hh:193
hpp::core::vectorOut_t
pinocchio::vectorOut_t vectorOut_t
Definition fwd.hh:222
hpp::core::ConfigurationOut_t
pinocchio::ConfigurationOut_t ConfigurationOut_t
Definition fwd.hh:109
hpp::core::interval_t
std::pair< value_type, value_type > interval_t
Definition fwd.hh:175
hpp::core::size_type
pinocchio::size_type size_type
Definition fwd.hh:173
hpp::core::Paths_t
std::vector< PathPtr_t > Paths_t
Definition fwd.hh:214
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
std
path.hh
HPP_SERIALIZABLE
#define HPP_SERIALIZABLE()