hpp-core  4.9.0
Implement basic classes for canonical path planning for kinematic chains.
straight-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_CORE_STRAIGHT_PATH_HH
20 # define HPP_CORE_STRAIGHT_PATH_HH
21 
22 # include <hpp/pinocchio/liegroup-element.hh>
23 
24 # include <hpp/core/fwd.hh>
25 # include <hpp/core/config.hh>
26 # include <hpp/core/path.hh>
27 
28 namespace hpp {
29  namespace core {
32 
42  class HPP_CORE_DLLAPI StraightPath : public Path
43  {
44  public:
45  typedef Path parent_t;
47  virtual ~StraightPath () {}
48 
54  vectorIn_t init,
55  vectorIn_t end,
56  interval_t interval,
57  ConstraintSetPtr_t constraints = ConstraintSetPtr_t())
58  {
59  StraightPath* ptr;
60  if (constraints)
61  ptr = new StraightPath (space, init, end, interval, constraints);
62  else
63  ptr = new StraightPath (space, init, end, interval);
64  StraightPathPtr_t shPtr (ptr);
65  ptr->init (shPtr);
66  ptr->checkPath ();
67  return shPtr;
68  }
69 
76  interval_t interval,
77  ConstraintSetPtr_t constraints = ConstraintSetPtr_t())
78  {
79  assert (init.space() == end.space());
80  return create (init.space(), init.vector(), end.vector(), interval, constraints);
81  }
82 
87  static StraightPathPtr_t create (const DevicePtr_t& device,
88  ConfigurationIn_t init,
91  {
92  return create (device, init, end, interval_t (0, length));
93  }
94 
99  static StraightPathPtr_t create (const DevicePtr_t& device,
100  ConfigurationIn_t init,
101  ConfigurationIn_t end,
102  interval_t interval)
103  {
104  StraightPath* ptr = new StraightPath (device, init, end, interval);
105  StraightPathPtr_t shPtr (ptr);
106  ptr->init (shPtr);
107  ptr->checkPath ();
108  return shPtr;
109  }
110 
113  static StraightPathPtr_t create (const DevicePtr_t& device,
114  ConfigurationIn_t init,
115  ConfigurationIn_t end,
117  ConstraintSetPtr_t constraints)
118  {
119  return create (device, init, end, interval_t (0, length), constraints);
120  }
121 
124  static StraightPathPtr_t create (const DevicePtr_t& device,
125  ConfigurationIn_t init,
126  ConfigurationIn_t end,
127  interval_t interval,
128  ConstraintSetPtr_t constraints)
129  {
130  StraightPath* ptr = new StraightPath (device, init, end, interval,
131  constraints);
132  StraightPathPtr_t shPtr (ptr);
133  ptr->init (shPtr);
134  ptr->checkPath ();
135  return shPtr;
136  }
137 
141  {
142  StraightPath* ptr = new StraightPath (*path);
143  StraightPathPtr_t shPtr (ptr);
144  ptr->init (shPtr);
145  ptr->checkPath ();
146  return shPtr;
147  }
148 
152  static StraightPathPtr_t createCopy
153  (const StraightPathPtr_t& path, const ConstraintSetPtr_t& constraints)
154  {
155  StraightPath* ptr = new StraightPath (*path, constraints);
156  StraightPathPtr_t shPtr (ptr);
157  ptr->init (shPtr);
158  ptr->checkPath ();
159  return shPtr;
160  }
161 
166  virtual PathPtr_t copy () const
167  {
168  return createCopy (weak_.lock ());
169  }
170 
175  virtual PathPtr_t copy (const ConstraintSetPtr_t& constraints) const
176  {
177  return createCopy (weak_.lock (), constraints);
178  }
179 
185  {
186  assert (initial.size () == initial_.size ());
187  initial_ = initial;
188  }
189 
195  {
196  assert (end.size () == end_.size ());
197  end_ = end;
198  }
199 
201  DevicePtr_t device () const HPP_CORE_DEPRECATED;
202 
205  {
206  return initial_;
207  }
208 
211  {
212  return end_;
213  }
214 
215  protected:
217  virtual std::ostream& print (std::ostream &os) const
218  {
219  os << "StraightPath:" << std::endl;
220  Path::print (os);
221  os << "initial configuration: " << initial_.transpose () << std::endl;
222  os << "final configuration: " << end_.transpose () << std::endl;
223  return os;
224  }
225 
228  interval_t interval);
229 
232  interval_t interval, ConstraintSetPtr_t constraints);
233 
235  StraightPath (const DevicePtr_t& robot, ConfigurationIn_t init,
236  ConfigurationIn_t end, interval_t interval);
237 
239  StraightPath (const DevicePtr_t& robot, ConfigurationIn_t init,
241  ConstraintSetPtr_t constraints);
242 
244  StraightPath (const DevicePtr_t& robot, ConfigurationIn_t init,
245  ConfigurationIn_t end, interval_t interval,
246  ConstraintSetPtr_t constraints);
247 
249  StraightPath (const StraightPath& path);
250 
252  StraightPath (const StraightPath& path,
253  const ConstraintSetPtr_t& constraints);
254 
256  {
257  parent_t::init (self);
258  weak_ = self;
259  checkPath ();
260  }
261 
262  virtual bool impl_compute (ConfigurationOut_t result,
263  value_type param) const;
265  virtual void impl_derivative (vectorOut_t result, const value_type& t,
266  size_type order) const;
267 
268  virtual void impl_velocityBound (vectorOut_t result, const value_type&, const value_type&) const;
269 
274  PathPtr_t impl_extract (const interval_t& subInterval) const;
275 
276  protected:
281  private:
282  StraightPathWkPtr_t weak_;
283  }; // class StraightPath
285  } // namespace core
286 } // namespace hpp
287 #endif // HPP_CORE_STRAIGHT_PATH_HH
const vector_type & vector() const
boost::shared_ptr< Path > PathPtr_t
Definition: fwd.hh:170
pinocchio::DevicePtr_t DevicePtr_t
Definition: fwd.hh:114
pinocchio::ConfigurationIn_t ConfigurationIn_t
Definition: fwd.hh:97
void init(StraightPathPtr_t self)
Definition: straight-path.hh:255
Configuration_t initial_
Definition: straight-path.hh:279
static StraightPathPtr_t create(const DevicePtr_t &device, ConfigurationIn_t init, ConfigurationIn_t end, interval_t interval, ConstraintSetPtr_t constraints)
Definition: straight-path.hh:124
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.
static StraightPathPtr_t create(const DevicePtr_t &device, ConfigurationIn_t init, ConfigurationIn_t end, interval_t interval)
Definition: straight-path.hh:99
static StraightPathPtr_t create(const DevicePtr_t &device, ConfigurationIn_t init, ConfigurationIn_t end, value_type length, ConstraintSetPtr_t constraints)
Definition: straight-path.hh:113
ObjectFactory * create(ObjectFactory *parent=NULL, const XMLElement *element=NULL)
pinocchio::ConfigurationOut_t ConfigurationOut_t
Definition: fwd.hh:98
pinocchio::size_type size_type
Definition: fwd.hh:156
void endConfig(ConfigurationIn_t end)
Definition: straight-path.hh:194
virtual PathPtr_t copy() const
Definition: straight-path.hh:166
static StraightPathPtr_t createCopy(const StraightPathPtr_t &path)
Definition: straight-path.hh:140
static StraightPathPtr_t create(LiegroupSpacePtr_t space, vectorIn_t init, vectorIn_t end, interval_t interval, ConstraintSetPtr_t constraints=ConstraintSetPtr_t())
Definition: straight-path.hh:53
Path parent_t
Definition: straight-path.hh:45
const LiegroupSpacePtr_t & space() const
void initialConfig(ConfigurationIn_t initial)
Definition: straight-path.hh:184
Configuration_t end() const
Get the final configuration.
Definition: straight-path.hh:210
boost::shared_ptr< StraightPath > StraightPathPtr_t
Definition: fwd.hh:182
static StraightPathPtr_t create(const DevicePtr_t &device, ConfigurationIn_t init, ConfigurationIn_t end, value_type length)
Definition: straight-path.hh:87
Configuration_t initial() const
Get the initial configuration.
Definition: straight-path.hh:204
assert(d.lhs()._blocks()==d.rhs()._blocks())
pinocchio::vectorIn_t vectorIn_t
Definition: fwd.hh:202
constraints::LiegroupSpacePtr_t LiegroupSpacePtr_t
Definition: fwd.hh:155
virtual ~StraightPath()
Destructor.
Definition: straight-path.hh:47
pinocchio::value_type value_type
Definition: fwd.hh:157
Configuration_t end_
Definition: straight-path.hh:280
virtual std::ostream & print(std::ostream &os) const
Print path in a stream.
Definition: straight-path.hh:217
Definition: straight-path.hh:42
static StraightPathPtr_t create(LiegroupElementConstRef init, LiegroupElementConstRef end, interval_t interval, ConstraintSetPtr_t constraints=ConstraintSetPtr_t())
Definition: straight-path.hh:74
virtual std::ostream & print(std::ostream &os) const
Transform3f t
constraints::Implicit NumericalConstraint HPP_CORE_DEPRECATED
Definition: fwd.hh:347
LiegroupSpacePtr_t space_
Definition: straight-path.hh:278
FCL_REAL length[2]
pinocchio::vectorOut_t vectorOut_t
Definition: fwd.hh:203
DevicePtr_t device_
Definition: straight-path.hh:277
virtual PathPtr_t copy(const ConstraintSetPtr_t &constraints) const
Definition: straight-path.hh:175
Definition: path.hh:60
pinocchio::Configuration_t Configuration_t
Definition: fwd.hh:96