hpp-core  6.0.0
Implement basic classes for canonical path planning for kinematic chains.
kinodynamic-path.hh
Go to the documentation of this file.
1 // Copyright (c) 2016, LAAS-CNRS
2 // Authors: Pierre Fernbach (pierre.fernbach@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_CORE_KINODYNAMIC_PATH_HH
30 #define HPP_CORE_KINODYNAMIC_PATH_HH
31 
32 #include <hpp/core/config.hh>
33 #include <hpp/core/fwd.hh>
35 #include <hpp/pinocchio/configuration.hh>
36 
37 namespace hpp {
38 namespace core {
41 
60  public:
63  virtual ~KinodynamicPath() {}
64 
69  static KinodynamicPathPtr_t create(const DevicePtr_t& device,
70  ConfigurationIn_t init,
71  ConfigurationIn_t end, value_type length,
75  ConfigurationIn_t vLim) {
76  KinodynamicPath* ptr = new KinodynamicPath(device, init, end, length, a1,
77  t0, t1, tv, t2, vLim);
78  KinodynamicPathPtr_t shPtr(ptr);
79  ptr->init(shPtr);
80  ptr->checkPath();
81  return shPtr;
82  }
83 
90  const DevicePtr_t& device, ConfigurationIn_t init, ConfigurationIn_t end,
93  ConfigurationIn_t vLim, ConstraintSetPtr_t constraints) {
95  device, init, end, length, a1, t0, t1, tv, t2, vLim, constraints);
96  KinodynamicPathPtr_t shPtr(ptr);
97  ptr->init(shPtr);
98  ptr->checkPath();
99  return shPtr;
100  }
101 
105  KinodynamicPath* ptr = new KinodynamicPath(*path);
106  KinodynamicPathPtr_t shPtr(ptr);
107  ptr->init(shPtr);
108  ptr->checkPath();
109  return shPtr;
110  }
111 
116  const KinodynamicPathPtr_t& path, const ConstraintSetPtr_t& constraints) {
117  KinodynamicPath* ptr = new KinodynamicPath(*path, constraints);
118  KinodynamicPathPtr_t shPtr(ptr);
119  ptr->init(shPtr);
120  ptr->checkPath();
121  return shPtr;
122  }
123 
128  virtual PathPtr_t copy() const { return createCopy(weak_.lock()); }
129 
134  virtual PathPtr_t copy(const ConstraintSetPtr_t& constraints) const {
135  return createCopy(weak_.lock(), constraints);
136  }
137 
142  virtual PathPtr_t impl_extract(const interval_t& paramInterval) const;
143 
144  vector_t getT0() { return t0_; }
145 
146  vector_t getT1() { return t1_; }
147 
148  vector_t getT2() { return t2_; }
149 
150  vector_t getTv() { return tv_; }
151 
152  vector_t getA1() { return a1_; }
153 
154  protected:
156  virtual std::ostream& print(std::ostream& os) const {
157  os << "KinodynamicPath:" << std::endl;
158  os << "interval: [ " << timeRange().first << ", " << timeRange().second
159  << " ]" << std::endl;
160  os << "initial configuration: " << pinocchio::displayConfig(initial_)
161  << std::endl;
162  os << "final configuration: " << pinocchio::displayConfig(end_)
163  << std::endl;
164  return os;
165  }
168  ConfigurationIn_t end, value_type length,
172 
175  ConfigurationIn_t end, value_type length,
179  ConstraintSetPtr_t constraints);
180 
183 
186  const ConstraintSetPtr_t& constraints);
187 
189  parent_t::init(self);
190  weak_ = self;
191  checkPath();
192  }
193 
194  virtual bool impl_compute(ConfigurationOut_t result, value_type t) const;
195 
196  inline double sgnenum(double val) const { return ((0. < val) - (val < 0.)); }
197 
198  inline int sgn(double d) const { return d >= 0.0 ? 1 : -1; }
199 
200  inline double sgnf(double d) const { return d >= 0.0 ? 1.0 : -1.0; }
201 
202  const DevicePtr_t& device() const { return device_; }
203 
204  private:
205  KinodynamicPathWkPtr_t weak_;
206  DevicePtr_t device_;
207  vector_t a1_;
208  vector_t t0_, t1_, tv_, t2_, vLim_;
209 }; // class KinodynamicPath
211 } // namespace core
212 } // namespace hpp
213 #endif // HPP_CORE_KINODYNAMIC_PATH_HH
Definition: kinodynamic-path.hh:59
static KinodynamicPathPtr_t create(const DevicePtr_t &device, ConfigurationIn_t init, ConfigurationIn_t end, value_type length, ConfigurationIn_t a1, ConfigurationIn_t t0, ConfigurationIn_t t1, ConfigurationIn_t tv, ConfigurationIn_t t2, ConfigurationIn_t vLim, ConstraintSetPtr_t constraints)
Definition: kinodynamic-path.hh:89
void init(KinodynamicPathPtr_t self)
Definition: kinodynamic-path.hh:188
const DevicePtr_t & device() const
Definition: kinodynamic-path.hh:202
vector_t getT2()
Definition: kinodynamic-path.hh:148
virtual PathPtr_t impl_extract(const interval_t &paramInterval) const
KinodynamicPath(const KinodynamicPath &path, const ConstraintSetPtr_t &constraints)
Copy constructor with constraints.
KinodynamicPath(const KinodynamicPath &path)
Copy constructor.
static KinodynamicPathPtr_t create(const DevicePtr_t &device, ConfigurationIn_t init, ConfigurationIn_t end, value_type length, ConfigurationIn_t a1, ConfigurationIn_t t0, ConfigurationIn_t t1, ConfigurationIn_t tv, ConfigurationIn_t t2, ConfigurationIn_t vLim)
Definition: kinodynamic-path.hh:69
KinodynamicPath(const DevicePtr_t &robot, ConfigurationIn_t init, ConfigurationIn_t end, value_type length, ConfigurationIn_t a1, ConfigurationIn_t t0, ConfigurationIn_t t1, ConfigurationIn_t tv, ConfigurationIn_t t2, ConfigurationIn_t vLim, ConstraintSetPtr_t constraints)
Constructor with constraints.
KinodynamicPath(const DevicePtr_t &robot, ConfigurationIn_t init, ConfigurationIn_t end, value_type length, ConfigurationIn_t a1, ConfigurationIn_t t0, ConfigurationIn_t t1, ConfigurationIn_t tv, ConfigurationIn_t t2, ConfigurationIn_t vLim)
Constructor.
vector_t getA1()
Definition: kinodynamic-path.hh:152
static KinodynamicPathPtr_t createCopy(const KinodynamicPathPtr_t &path)
Definition: kinodynamic-path.hh:104
double sgnenum(double val) const
Definition: kinodynamic-path.hh:196
int sgn(double d) const
Definition: kinodynamic-path.hh:198
virtual PathPtr_t copy() const
Definition: kinodynamic-path.hh:128
double sgnf(double d) const
Definition: kinodynamic-path.hh:200
virtual ~KinodynamicPath()
Destructor.
Definition: kinodynamic-path.hh:63
virtual std::ostream & print(std::ostream &os) const
Print path in a stream.
Definition: kinodynamic-path.hh:156
virtual bool impl_compute(ConfigurationOut_t result, value_type t) const
Function evaluation without applying constraints.
static KinodynamicPathPtr_t createCopy(const KinodynamicPathPtr_t &path, const ConstraintSetPtr_t &constraints)
Definition: kinodynamic-path.hh:115
vector_t getT1()
Definition: kinodynamic-path.hh:146
vector_t getTv()
Definition: kinodynamic-path.hh:150
StraightPath parent_t
Definition: kinodynamic-path.hh:61
vector_t getT0()
Definition: kinodynamic-path.hh:144
virtual PathPtr_t copy(const ConstraintSetPtr_t &constraints) const
Definition: kinodynamic-path.hh:134
virtual void checkPath() const
Should be called by child classes after having init.
Definition: straight-path.hh:52
#define HPP_CORE_DLLAPI
Definition: config.hh:88
pinocchio::value_type value_type
Definition: fwd.hh:174
pinocchio::ConfigurationOut_t ConfigurationOut_t
Definition: fwd.hh:109
pinocchio::vector_t vector_t
Definition: fwd.hh:220
pinocchio::ConfigurationIn_t ConfigurationIn_t
Definition: fwd.hh:108
shared_ptr< KinodynamicPath > KinodynamicPathPtr_t
Definition: fwd.hh:206
std::pair< value_type, value_type > interval_t
Definition: fwd.hh:175
pinocchio::DevicePtr_t DevicePtr_t
Definition: fwd.hh:134
shared_ptr< ConstraintSet > ConstraintSetPtr_t
Definition: fwd.hh:130
shared_ptr< Path > PathPtr_t
Definition: fwd.hh:187
Definition: bi-rrt-planner.hh:35