hpp-rbprm  4.11.0
Implementation of RB-PRM planner using hpp.
time-constraint-path.hh
Go to the documentation of this file.
1 //
2 // Copyright (c) 2014 CNRS
3 // Authors: Florent Lamiraux
4 //
5 // This file is part of hpp-core
6 // hpp-core is free software: you can redistribute it
7 // and/or modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation, either version
9 // 3 of the License, or (at your option) any later version.
10 //
11 // hpp-core is distributed in the hope that it will be
12 // useful, but WITHOUT ANY WARRANTY; without even the implied warranty
13 // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // General Lesser Public License for more details. You should have
15 // received a copy of the GNU Lesser General Public License along with
16 // hpp-core If not, see
17 // <http://www.gnu.org/licenses/>.
18 
19 #ifndef HPP_RBPRM_TIMECONSTRAINT_PATH_HH
20 #define HPP_RBPRM_TIMECONSTRAINT_PATH_HH
21 
22 #include <hpp/core/fwd.hh>
23 #include <hpp/core/config.hh>
24 #include <hpp/core/path.hh>
26 
27 namespace hpp {
28 namespace rbprm {
29 namespace interpolation {
30 HPP_PREDEF_CLASS(TimeConstraintPath);
31 typedef std::shared_ptr<TimeConstraintPath> TimeConstraintPathPtr_t;
41 class HPP_CORE_DLLAPI TimeConstraintPath : public core::Path {
42  public:
43  typedef Path parent_t;
45  virtual ~TimeConstraintPath() {}
46 
51  static TimeConstraintPathPtr_t create(const core::DevicePtr_t& device, core::ConfigurationIn_t init,
52  core::ConfigurationIn_t end, core::value_type length,
53  const std::size_t pathDofRank, const T_TimeDependant& tds) {
54  TimeConstraintPath* ptr = new TimeConstraintPath(device, init, end, length, pathDofRank, tds);
55  TimeConstraintPathPtr_t shPtr(ptr);
56  ptr->init(shPtr);
57  ptr->checkPath();
58  return shPtr;
59  }
60 
66  static TimeConstraintPathPtr_t create(const core::DevicePtr_t& device, core::ConfigurationIn_t init,
67  core::ConfigurationIn_t end, core::value_type length,
68  core::ConstraintSetPtr_t constraints, const std::size_t pathDofRank,
69  const T_TimeDependant& tds) {
70  TimeConstraintPath* ptr = new TimeConstraintPath(device, init, end, length, constraints, pathDofRank, tds);
71  TimeConstraintPathPtr_t shPtr(ptr);
72  ptr->init(shPtr);
73  ptr->checkPath();
74  return shPtr;
75  }
76 
79  static TimeConstraintPathPtr_t createCopy(const TimeConstraintPathPtr_t& path) {
80  TimeConstraintPath* ptr = new TimeConstraintPath(*path);
81  TimeConstraintPathPtr_t shPtr(ptr);
82  ptr->initCopy(shPtr);
83  ptr->checkPath();
84  return shPtr;
85  }
86 
90  static TimeConstraintPathPtr_t createCopy(const TimeConstraintPathPtr_t& path,
91  const core::ConstraintSetPtr_t& constraints) {
92  TimeConstraintPath* ptr = new TimeConstraintPath(*path, constraints);
93  TimeConstraintPathPtr_t shPtr(ptr);
94  ptr->initCopy(shPtr);
95  ptr->checkPath();
96  return shPtr;
97  }
98 
103  virtual core::PathPtr_t copy() const { return createCopy(weak_.lock()); }
104 
109  virtual core::PathPtr_t copy(const core::ConstraintSetPtr_t& constraints) const {
110  return createCopy(weak_.lock(), constraints);
111  }
112 
117  virtual core::PathPtr_t extract(const core::interval_t& subInterval) const;
118 
123  void initialConfig(core::ConfigurationIn_t initial) {
124  assert(initial.size() == initial_.size());
125  pinocchio::value_type dof = initial_[pathDofRank_];
126  initial_ = initial;
127  initial_[pathDofRank_] = dof;
128  }
129 
134  void endConfig(core::ConfigurationIn_t end) {
135  assert(end.size() == end_.size());
136  pinocchio::value_type dof = end_[pathDofRank_];
137  end_ = end;
138  end_[pathDofRank_] = dof;
139  }
140 
142  core::DevicePtr_t device() const;
143 
145  core::Configuration_t initial() const { return initial_; }
146 
148  core::Configuration_t end() const { return end_; }
149 
150  virtual void checkPath() const;
151 
152  protected:
154  virtual std::ostream& print(std::ostream& os) const {
155  os << "TimeConstraintPath:" << std::endl;
156  os << "interval: [ " << timeRange().first << ", " << timeRange().second << " ]" << std::endl;
157  os << "initial configuration: " << initial_.transpose() << std::endl;
158  os << "final configuration: " << end_.transpose() << std::endl;
159  return os;
160  }
162  TimeConstraintPath(const core::DevicePtr_t& robot, core::ConfigurationIn_t init, core::ConfigurationIn_t end,
163  core::value_type length, const std::size_t pathDofRank, const T_TimeDependant& tds);
164 
166  TimeConstraintPath(const core::DevicePtr_t& robot, core::ConfigurationIn_t init, core::ConfigurationIn_t end,
167  core::value_type length, core::ConstraintSetPtr_t constraints, const std::size_t pathDofRank,
168  const T_TimeDependant& tds);
169 
172 
174  TimeConstraintPath(const TimeConstraintPath& path, const core::ConstraintSetPtr_t& constraints);
175 
176  void init(TimeConstraintPathPtr_t self) {
177  parent_t::init(self);
178  weak_ = self;
179  }
180 
181  void initCopy(TimeConstraintPathPtr_t self) {
182  parent_t::init(self);
183  weak_ = self;
184  }
185 
186  virtual bool impl_compute(core::ConfigurationOut_t result, core::value_type param) const;
187 
188  private:
189  void updateConstraints(core::ConfigurationOut_t configuration) const;
190 
191  private:
192  core::DevicePtr_t device_;
193  core::Configuration_t initial_;
194  core::Configuration_t end_;
195 
196  public:
197  const std::size_t pathDofRank_;
199 
200  private:
201  TimeConstraintPathWkPtr_t weak_;
202 }; // class TimeConstraintPath
203 } // namespace interpolation
204 } // namespace rbprm
205 } // namespace hpp
206 #endif // HPP_RBPRM_TIMECONSTRAINT_PATH_HH
static TimeConstraintPathPtr_t create(const core::DevicePtr_t &device, core::ConfigurationIn_t init, core::ConfigurationIn_t end, core::value_type length, const std::size_t pathDofRank, const T_TimeDependant &tds)
Definition: time-constraint-path.hh:51
virtual ~TimeConstraintPath()
Destructor.
Definition: time-constraint-path.hh:45
void initialConfig(core::ConfigurationIn_t initial)
Definition: time-constraint-path.hh:123
Definition: time-constraint-path.hh:41
Definition: algorithm.hh:27
std::shared_ptr< TimeConstraintPath > TimeConstraintPathPtr_t
Definition: time-constraint-path.hh:31
const std::size_t pathDofRank_
Definition: time-constraint-path.hh:197
Path parent_t
Definition: time-constraint-path.hh:43
void endConfig(core::ConfigurationIn_t end)
Definition: time-constraint-path.hh:134
virtual core::PathPtr_t copy() const
Definition: time-constraint-path.hh:103
void initCopy(TimeConstraintPathPtr_t self)
Definition: time-constraint-path.hh:181
virtual core::PathPtr_t copy(const core::ConstraintSetPtr_t &constraints) const
Definition: time-constraint-path.hh:109
const T_TimeDependant tds_
Definition: time-constraint-path.hh:198
static TimeConstraintPathPtr_t createCopy(const TimeConstraintPathPtr_t &path, const core::ConstraintSetPtr_t &constraints)
Definition: time-constraint-path.hh:90
static TimeConstraintPathPtr_t create(const core::DevicePtr_t &device, core::ConfigurationIn_t init, core::ConfigurationIn_t end, core::value_type length, core::ConstraintSetPtr_t constraints, const std::size_t pathDofRank, const T_TimeDependant &tds)
Definition: time-constraint-path.hh:66
virtual std::ostream & print(std::ostream &os) const
Print path in a stream.
Definition: time-constraint-path.hh:154
void init(TimeConstraintPathPtr_t self)
Definition: time-constraint-path.hh:176
core::Configuration_t end() const
Get the final configuration.
Definition: time-constraint-path.hh:148
std::vector< TimeDependant > T_TimeDependant
Definition: time-dependant.hh:68
HPP_PREDEF_CLASS(ComTrajectory)
core::Configuration_t initial() const
Get the initial configuration.
Definition: time-constraint-path.hh:145
static TimeConstraintPathPtr_t createCopy(const TimeConstraintPathPtr_t &path)
Definition: time-constraint-path.hh:79