hpp-core  4.9.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 // This file is part of hpp-core
5 // hpp-core is free software: you can redistribute it
6 // and/or modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation, either version
8 // 3 of the License, or (at your option) any later version.
9 //
10 // hpp-core is distributed in the hope that it will be
11 // useful, but WITHOUT ANY WARRANTY; without even the implied warranty
12 // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // General Lesser Public License for more details. You should have
14 // received a copy of the GNU Lesser General Public License along with
15 // hpp-core If not, see
16 // <http://www.gnu.org/licenses/>.
17 
18 #ifndef HPP_CORE_KINODYNAMIC_PATH_HH
19 # define HPP_CORE_KINODYNAMIC_PATH_HH
20 
21 # include <hpp/core/fwd.hh>
22 # include <hpp/core/config.hh>
23 # include <hpp/core/straight-path.hh>
24 # include <hpp/pinocchio/configuration.hh>
25 
26 namespace hpp {
27  namespace core {
30 
45  class HPP_CORE_DLLAPI KinodynamicPath : public StraightPath
46  {
47  public:
50  virtual ~KinodynamicPath () {}
51 
56  static KinodynamicPathPtr_t create (const DevicePtr_t& device,
57  ConfigurationIn_t init,
60  {
61  KinodynamicPath* ptr = new KinodynamicPath (device, init, end, length,a1,t0,t1,tv,t2,vLim);
62  KinodynamicPathPtr_t shPtr (ptr);
63  ptr->init (shPtr);
64  ptr->checkPath ();
65  return shPtr;
66  }
67 
73  static KinodynamicPathPtr_t create (const DevicePtr_t& device,
74  ConfigurationIn_t init,
77  ConstraintSetPtr_t constraints)
78  {
79  KinodynamicPath* ptr = new KinodynamicPath (device, init, end, length,a1,t0,t1,tv,t2,vLim,
80  constraints);
81  KinodynamicPathPtr_t shPtr (ptr);
82  ptr->init (shPtr);
83  ptr->checkPath ();
84  return shPtr;
85  }
86 
90  {
91  KinodynamicPath* ptr = new KinodynamicPath (*path);
92  KinodynamicPathPtr_t shPtr (ptr);
93  ptr->init (shPtr);
94  ptr->checkPath ();
95  return shPtr;
96  }
97 
101  static KinodynamicPathPtr_t createCopy
102  (const KinodynamicPathPtr_t& path, const ConstraintSetPtr_t& constraints)
103  {
104  KinodynamicPath* ptr = new KinodynamicPath (*path, constraints);
105  KinodynamicPathPtr_t shPtr (ptr);
106  ptr->init (shPtr);
107  ptr->checkPath ();
108  return shPtr;
109  }
110 
115  virtual PathPtr_t copy () const
116  {
117  return createCopy (weak_.lock ());
118  }
119 
124  virtual PathPtr_t copy (const ConstraintSetPtr_t& constraints) const
125  {
126  return createCopy (weak_.lock (), constraints);
127  }
128 
129 
133  virtual PathPtr_t impl_extract (const interval_t& paramInterval) const;
134 
135  vector_t getT0(){return t0_;}
136 
137  vector_t getT1(){return t1_;}
138 
139  vector_t getT2(){return t2_;}
140 
141  vector_t getTv(){return tv_;}
142 
143  vector_t getA1(){return a1_;}
144 
145 
146  protected:
148  virtual std::ostream& print (std::ostream &os) const
149  {
150  os << "KinodynamicPath:" << std::endl;
151  os << "interval: [ " << timeRange ().first << ", "
152  << timeRange ().second << " ]" << std::endl;
153  os << "initial configuration: " << pinocchio::displayConfig(initial_ )<< std::endl;
154  os << "final configuration: " << pinocchio::displayConfig(end_) << std::endl;
155  return os;
156  }
158  KinodynamicPath (const DevicePtr_t& robot, ConfigurationIn_t init,
160 
162  KinodynamicPath (const DevicePtr_t& robot, ConfigurationIn_t init,
164  ConstraintSetPtr_t constraints);
165 
167  KinodynamicPath (const KinodynamicPath& path);
168 
170  KinodynamicPath (const KinodynamicPath& path,
171  const ConstraintSetPtr_t& constraints);
172 
174  {
175  parent_t::init (self);
176  weak_ = self;
177  checkPath ();
178  }
179 
180 
181  virtual bool impl_compute (ConfigurationOut_t result,
182  value_type t) const;
183 
184 
185  inline double sgnenum(double val) const{
186  return ((0. < val ) - (val < 0.));
187  }
188 
189  inline int sgn(double d) const {
190  return d >= 0.0 ? 1 : -1;
191  }
192 
193  inline double sgnf(double d) const {
194  return d >= 0.0 ? 1.0 : -1.0;
195  }
196 
197  const DevicePtr_t& device () const
198  {
199  return device_;
200  }
201 
202  private:
203  KinodynamicPathWkPtr_t weak_;
204  DevicePtr_t device_;
205  vector_t a1_;
206  vector_t t0_,t1_,tv_,t2_,vLim_;
207  }; // class KinodynamicPath
209  } // namespace core
210 } // namespace hpp
211 #endif // HPP_CORE_KINODYNAMIC_PATH_HH
boost::shared_ptr< Path > PathPtr_t
Definition: fwd.hh:170
int sgn(double d) const
Definition: kinodynamic-path.hh:189
vector_t getTv()
Definition: kinodynamic-path.hh:141
virtual std::ostream & print(std::ostream &os) const
Print path in a stream.
Definition: kinodynamic-path.hh:148
pinocchio::DevicePtr_t DevicePtr_t
Definition: fwd.hh:114
pinocchio::ConfigurationIn_t ConfigurationIn_t
Definition: fwd.hh:97
StraightPath parent_t
Definition: kinodynamic-path.hh:48
boost::shared_ptr< ConstraintSet > ConstraintSetPtr_t
Definition: fwd.hh:110
std::pair< value_type, value_type > interval_t
Definition: fwd.hh:158
virtual void checkPath() const
Should be called by child classes after having init.
pinocchio::ConfigurationOut_t ConfigurationOut_t
Definition: fwd.hh:98
const DevicePtr_t & device() const
Definition: kinodynamic-path.hh:197
virtual ~KinodynamicPath()
Destructor.
Definition: kinodynamic-path.hh:50
static KinodynamicPathPtr_t createCopy(const KinodynamicPathPtr_t &path)
Definition: kinodynamic-path.hh:89
vector_t getA1()
Definition: kinodynamic-path.hh:143
Definition: kinodynamic-path.hh:45
vector_t getT2()
Definition: kinodynamic-path.hh:139
pinocchio::vector_t vector_t
Definition: fwd.hh:201
virtual PathPtr_t copy(const ConstraintSetPtr_t &constraints) const
Definition: kinodynamic-path.hh:124
pinocchio::value_type value_type
Definition: fwd.hh:157
FCL_REAL d
vector_t getT1()
Definition: kinodynamic-path.hh:137
Definition: straight-path.hh:42
void init(KinodynamicPathPtr_t self)
Definition: kinodynamic-path.hh:173
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:56
double sgnenum(double val) const
Definition: kinodynamic-path.hh:185
vector_t getT0()
Definition: kinodynamic-path.hh:135
Transform3f t
FCL_REAL length[2]
double sgnf(double d) const
Definition: kinodynamic-path.hh:193
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:73
virtual PathPtr_t copy() const
Definition: kinodynamic-path.hh:115
std::string displayConfig(ConfigurationIn_t q, int precision=20)
boost::shared_ptr< KinodynamicPath > KinodynamicPathPtr_t
Definition: fwd.hh:188