hpp-rbprm  4.11.0
Implementation of RB-PRM planner using hpp.
timed-parabola-path.hh
Go to the documentation of this file.
1 //
2 // Copyright (c) 2017 CNRS
3 // Authors: Pierre Fernbach
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_TIMED_PARABOLA_PATH_HH
20 #define HPP_RBPRM_TIMED_PARABOLA_PATH_HH
21 
23 
24 namespace hpp {
25 namespace rbprm {
26 
27 // forward declaration of class
28 HPP_PREDEF_CLASS(TimedParabolaPath);
29 // Planner objects are manipulated only via shared pointers
30 typedef std::shared_ptr<TimedParabolaPath> TimedParabolaPathPtr_t;
31 
36  public:
39  virtual ~TimedParabolaPath() {}
40 
45  static TimedParabolaPathPtr_t create(const core::DevicePtr_t& device, core::ConfigurationIn_t init,
46  core::ConfigurationIn_t end, ParabolaPathPtr_t parabolaPath) {
47  TimedParabolaPath* ptr = new TimedParabolaPath(device, init, end, parabolaPath);
48  TimedParabolaPathPtr_t shPtr(ptr);
49  ptr->init(shPtr);
50  return shPtr;
51  }
52 
57  static TimedParabolaPathPtr_t create(const core::DevicePtr_t& device, core::ConfigurationIn_t init,
58  core::ConfigurationIn_t end, core::value_type length,
59  core::vector_t coefficients) {
60  TimedParabolaPath* ptr = new TimedParabolaPath(device, init, end, length, coefficients);
61  TimedParabolaPathPtr_t shPtr(ptr);
62  ptr->init(shPtr);
63  return shPtr;
64  }
65 
72  static TimedParabolaPathPtr_t create(const core::DevicePtr_t& device, core::ConfigurationIn_t init,
73  core::ConfigurationIn_t end, core::value_type length,
74  core::vector_t coefficients, core::vector_t V0, core::vector_t Vimp,
75  std::vector<std::string> initialROMnames,
76  std::vector<std::string> endROMnames) {
77  TimedParabolaPath* ptr =
78  new TimedParabolaPath(device, init, end, length, coefficients, V0, Vimp, initialROMnames, endROMnames);
79  TimedParabolaPathPtr_t shPtr(ptr);
80  ptr->init(shPtr);
81  return shPtr;
82  }
83 
86  static TimedParabolaPathPtr_t createCopy(const TimedParabolaPathPtr_t& path) {
87  TimedParabolaPath* ptr = new TimedParabolaPath(*path);
88  TimedParabolaPathPtr_t shPtr(ptr);
89  ptr->init(shPtr);
90  return shPtr;
91  }
92 
97  static TimedParabolaPathPtr_t createCopy(const TimedParabolaPathPtr_t& path,
98  const core::ConstraintSetPtr_t& /*constraints*/) {
99  // TimedParabolaPath* ptr = new TimedParabolaPath (*path, constraints);
100  TimedParabolaPath* ptr = new TimedParabolaPath(*path);
101  TimedParabolaPathPtr_t shPtr(ptr);
102  ptr->init(shPtr);
103  return shPtr;
104  }
105 
110  virtual core::PathPtr_t copy() const { return createCopy(weak_.lock()); }
111 
116  virtual core::PathPtr_t copy(const core::ConstraintSetPtr_t& constraints) const {
117  return createCopy(weak_.lock(), constraints);
118  }
119 
124  virtual core::PathPtr_t extract(const core::interval_t& subInterval) const;
125 
128  virtual core::PathPtr_t reverse() const;
129 
134  void initialConfig(core::ConfigurationIn_t initial) {
135  assert(initial.size() == initial_.size());
136  initial_ = initial;
137  }
138 
143  void endConfig(core::ConfigurationIn_t end) {
144  assert(end.size() == end_.size());
145  end_ = end;
146  }
147 
149  core::DevicePtr_t device() const;
150 
152  core::Configuration_t initial() const { return initial_; }
153 
155  core::Configuration_t end() const { return end_; }
156 
158  virtual core::value_type length() const { return length_; }
159 
160  protected:
162  TimedParabolaPath(const core::DevicePtr_t& robot, core::ConfigurationIn_t init, core::ConfigurationIn_t end,
163  ParabolaPathPtr_t parabolaPath);
164 
166  TimedParabolaPath(const core::DevicePtr_t& robot, core::ConfigurationIn_t init, core::ConfigurationIn_t end,
167  core::value_type length, core::vector_t coefficients);
168 
170  TimedParabolaPath(const core::DevicePtr_t& robot, core::ConfigurationIn_t init, core::ConfigurationIn_t end,
171  core::value_type length, core::vector_t coefs, core::vector_t V0, core::vector_t Vimp,
172  std::vector<std::string> initialROMnames, std::vector<std::string> endROMnames);
173 
176 
177  void init(TimedParabolaPathPtr_t self) {
178  parent_t::init(self);
179  weak_ = self;
180  }
181 
183  virtual bool impl_compute(core::ConfigurationOut_t result, core::value_type t) const;
184 
185  virtual double computeTimedLength(double x_theta, double v0, double alpha0);
186  virtual double computeTimedLength(ParabolaPathPtr_t parabolaPath);
187 
189  virtual std::ostream& print(std::ostream& os) const {
190  os << "TimedParabolaPath:" << std::endl;
191  os << "interval: [ " << timeRange().first << ", " << timeRange().second << " ]" << std::endl;
192  os << "initial configuration: " << initial_.transpose() << std::endl;
193  os << "final configuration: " << end_.transpose() << std::endl;
194  return os;
195  }
196 
197  private:
198  core::DevicePtr_t device_;
199  core::Configuration_t initial_;
200  core::Configuration_t end_;
201  TimedParabolaPathWkPtr_t weak_;
202  ParabolaPathPtr_t parabolaPath_;
203  mutable core::value_type length_;
204 
205 }; // class TimedParabolaPath
206 } // namespace rbprm
207 } // namespace hpp
208 
209 #endif // HPP_RBPRM_TIMED_PARABOLA_PATH_HH
void init(TimedParabolaPathPtr_t self)
Definition: timed-parabola-path.hh:177
static TimedParabolaPathPtr_t create(const core::DevicePtr_t &device, core::ConfigurationIn_t init, core::ConfigurationIn_t end, ParabolaPathPtr_t parabolaPath)
Definition: timed-parabola-path.hh:45
std::shared_ptr< ParabolaPath > ParabolaPathPtr_t
Definition: parabola-path.hh:33
static TimedParabolaPathPtr_t create(const core::DevicePtr_t &device, core::ConfigurationIn_t init, core::ConfigurationIn_t end, core::value_type length, core::vector_t coefficients)
Definition: timed-parabola-path.hh:57
core::Configuration_t end() const
Get the final configuration.
Definition: timed-parabola-path.hh:155
Definition: algorithm.hh:27
core::Configuration_t initial() const
Get the initial configuration.
Definition: timed-parabola-path.hh:152
Definition: parabola-path.hh:44
static TimedParabolaPathPtr_t create(const core::DevicePtr_t &device, core::ConfigurationIn_t init, core::ConfigurationIn_t end, core::value_type length, core::vector_t coefficients, core::vector_t V0, core::vector_t Vimp, std::vector< std::string > initialROMnames, std::vector< std::string > endROMnames)
Definition: timed-parabola-path.hh:72
TimedParabolaPath(const core::DevicePtr_t &robot, core::ConfigurationIn_t init, core::ConfigurationIn_t end, ParabolaPathPtr_t parabolaPath)
Constructor.
void initialConfig(core::ConfigurationIn_t initial)
Definition: timed-parabola-path.hh:134
static TimedParabolaPathPtr_t createCopy(const TimedParabolaPathPtr_t &path)
Definition: timed-parabola-path.hh:86
virtual core::PathPtr_t copy() const
Definition: timed-parabola-path.hh:110
virtual core::PathPtr_t copy(const core::ConstraintSetPtr_t &constraints) const
Definition: timed-parabola-path.hh:116
std::shared_ptr< TimedParabolaPath > TimedParabolaPathPtr_t
Definition: timed-parabola-path.hh:30
HPP_PREDEF_CLASS(RbPrmFullBody)
void init(ParabolaPathPtr_t self)
Definition: parabola-path.hh:200
void endConfig(core::ConfigurationIn_t end)
Definition: timed-parabola-path.hh:143
virtual std::ostream & print(std::ostream &os) const
Print path in a stream.
Definition: timed-parabola-path.hh:189
Definition: timed-parabola-path.hh:35
virtual double computeTimedLength(double x_theta, double v0, double alpha0)
virtual core::PathPtr_t extract(const core::interval_t &subInterval) const
static TimedParabolaPathPtr_t createCopy(const TimedParabolaPathPtr_t &path, const core::ConstraintSetPtr_t &)
Definition: timed-parabola-path.hh:97
core::DevicePtr_t device() const
Return the internal robot.
virtual ~TimedParabolaPath()
Destructor.
Definition: timed-parabola-path.hh:39
core::vector_t coefficients() const
Get path coefficients.
Definition: parabola-path.hh:160
virtual core::PathPtr_t reverse() const
virtual core::value_type length() const
Get previously computed length.
Definition: timed-parabola-path.hh:158
virtual bool impl_compute(core::ConfigurationOut_t result, core::value_type t) const
Param is the time.
ParabolaPath parent_t
Definition: timed-parabola-path.hh:37