hpp-core  6.0.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 
6 // Redistribution and use in source and binary forms, with or without
7 // modification, are permitted provided that the following conditions are
8 // met:
9 //
10 // 1. Redistributions of source code must retain the above copyright
11 // notice, this list of conditions and the following disclaimer.
12 //
13 // 2. Redistributions in binary form must reproduce the above copyright
14 // notice, this list of conditions and the following disclaimer in the
15 // documentation and/or other materials provided with the distribution.
16 //
17 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 // HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
28 // DAMAGE.
29 
30 #ifndef HPP_CORE_STRAIGHT_PATH_HH
31 #define HPP_CORE_STRAIGHT_PATH_HH
32 
33 #include <hpp/core/config.hh>
34 #include <hpp/core/fwd.hh>
35 #include <hpp/core/path.hh>
36 #include <hpp/pinocchio/liegroup-element.hh>
37 
38 namespace hpp {
39 namespace core {
42 
53  public:
54  typedef Path parent_t;
56  virtual ~StraightPath() {}
57 
63  LiegroupSpacePtr_t space, vectorIn_t init, vectorIn_t end,
64  interval_t interval,
65  ConstraintSetPtr_t constraints = ConstraintSetPtr_t()) {
66  StraightPath* ptr;
67  if (constraints)
68  ptr = new StraightPath(space, init, end, interval, constraints);
69  else
70  ptr = new StraightPath(space, init, end, interval);
71  StraightPathPtr_t shPtr(ptr);
72  ptr->init(shPtr);
73  ptr->checkPath();
74  return shPtr;
75  }
76 
83  interval_t interval,
84  ConstraintSetPtr_t constraints = ConstraintSetPtr_t()) {
85  assert(init.space() == end.space());
86  return create(init.space(), init.vector(), end.vector(), interval,
87  constraints);
88  }
89 
95  const DevicePtr_t& device, ConfigurationIn_t init, ConfigurationIn_t end,
96  value_type length,
97  ConstraintSetPtr_t constraints = ConstraintSetPtr_t()) {
98  return create(device, init, end, interval_t(0, length), constraints);
99  }
100 
107  const DevicePtr_t& device, ConfigurationIn_t init, ConfigurationIn_t end,
108  interval_t interval,
109  ConstraintSetPtr_t constraints = ConstraintSetPtr_t());
110 
114  StraightPath* ptr = new StraightPath(*path);
115  StraightPathPtr_t shPtr(ptr);
116  ptr->init(shPtr);
117  ptr->checkPath();
118  return shPtr;
119  }
120 
125  const ConstraintSetPtr_t& constraints) {
126  StraightPath* ptr = new StraightPath(*path, constraints);
127  StraightPathPtr_t shPtr(ptr);
128  ptr->init(shPtr);
129  ptr->checkPath();
130  return shPtr;
131  }
132 
137  virtual PathPtr_t copy() const { return createCopy(weak_.lock()); }
138 
143  virtual PathPtr_t copy(const ConstraintSetPtr_t& constraints) const {
144  return createCopy(weak_.lock(), constraints);
145  }
146 
152  assert(initial.size() == initial_.size());
153  initial_ = initial;
154  }
155 
161  assert(end.size() == end_.size());
162  end_ = end;
163  }
164 
166  Configuration_t initial() const { return initial_; }
167 
169  Configuration_t end() const { return end_; }
170 
171  protected:
173  virtual std::ostream& print(std::ostream& os) const;
174 
177  interval_t interval);
178 
181  interval_t interval, ConstraintSetPtr_t constraints);
182 
185 
187  StraightPath(const StraightPath& path, const ConstraintSetPtr_t& constraints);
188 
189  void init(StraightPathPtr_t self) {
190  parent_t::init(self);
191  weak_ = self;
192  checkPath();
193  }
194 
195  virtual bool impl_compute(ConfigurationOut_t result, value_type param) const;
197  virtual void impl_derivative(vectorOut_t result, const value_type& t,
198  size_type order) const;
199 
200  virtual void impl_velocityBound(vectorOut_t result, const value_type&,
201  const value_type&) const;
202 
207  PathPtr_t impl_extract(const interval_t& subInterval) const;
208 
209  protected:
213 
214  private:
215  StraightPathWkPtr_t weak_;
216 
217  protected:
219 
220  private:
221  HPP_SERIALIZABLE();
222 }; // class StraightPath
224 } // namespace core
225 } // namespace hpp
226 
227 BOOST_CLASS_EXPORT_KEY(hpp::core::StraightPath)
228 
229 #endif // HPP_CORE_STRAIGHT_PATH_HH
Definition: path.hh:71
virtual void checkPath() const
Should be called by child classes after having init.
Definition: straight-path.hh:52
Configuration_t initial_
Definition: straight-path.hh:211
virtual bool impl_compute(ConfigurationOut_t result, value_type param) const
Function evaluation without applying constraints.
virtual ~StraightPath()
Destructor.
Definition: straight-path.hh:56
StraightPath(const StraightPath &path)
Copy constructor.
Configuration_t initial() const
Get the initial configuration.
Definition: straight-path.hh:166
void endConfig(ConfigurationIn_t end)
Definition: straight-path.hh:160
virtual void impl_derivative(vectorOut_t result, const value_type &t, size_type order) const
Virtual implementation of derivative.
void init(StraightPathPtr_t self)
Definition: straight-path.hh:189
Configuration_t end() const
Get the final configuration.
Definition: straight-path.hh:169
StraightPath(const StraightPath &path, const ConstraintSetPtr_t &constraints)
Copy constructor with constraints.
static StraightPathPtr_t create(const DevicePtr_t &device, ConfigurationIn_t init, ConfigurationIn_t end, value_type length, ConstraintSetPtr_t constraints=ConstraintSetPtr_t())
Definition: straight-path.hh:94
virtual void impl_velocityBound(vectorOut_t result, const value_type &, const value_type &) const
virtual PathPtr_t copy(const ConstraintSetPtr_t &constraints) const
Definition: straight-path.hh:143
LiegroupSpacePtr_t space_
Definition: straight-path.hh:210
StraightPath(LiegroupSpacePtr_t space, vectorIn_t init, vectorIn_t end, interval_t interval, ConstraintSetPtr_t constraints)
Constructor.
StraightPath(LiegroupSpacePtr_t space, vectorIn_t init, vectorIn_t end, interval_t interval)
Constructor.
static StraightPathPtr_t createCopy(const StraightPathPtr_t &path)
Definition: straight-path.hh:113
virtual PathPtr_t copy() const
Definition: straight-path.hh:137
Configuration_t end_
Definition: straight-path.hh:212
static StraightPathPtr_t create(LiegroupElementConstRef init, LiegroupElementConstRef end, interval_t interval, ConstraintSetPtr_t constraints=ConstraintSetPtr_t())
Definition: straight-path.hh:81
Path parent_t
Definition: straight-path.hh:54
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:62
StraightPath()
Definition: straight-path.hh:218
static StraightPathPtr_t create(const DevicePtr_t &device, ConfigurationIn_t init, ConfigurationIn_t end, interval_t interval, ConstraintSetPtr_t constraints=ConstraintSetPtr_t())
PathPtr_t impl_extract(const interval_t &subInterval) const
void initialConfig(ConfigurationIn_t initial)
Definition: straight-path.hh:151
virtual std::ostream & print(std::ostream &os) const
Print path in a stream.
static StraightPathPtr_t createCopy(const StraightPathPtr_t &path, const ConstraintSetPtr_t &constraints)
Definition: straight-path.hh:124
#define HPP_CORE_DLLAPI
Definition: config.hh:88
pinocchio::value_type value_type
Definition: fwd.hh:174
shared_ptr< StraightPath > StraightPathPtr_t
Definition: fwd.hh:200
pinocchio::LiegroupElementConstRef LiegroupElementConstRef
Definition: fwd.hh:170
pinocchio::vectorIn_t vectorIn_t
Definition: fwd.hh:221
pinocchio::vectorOut_t vectorOut_t
Definition: fwd.hh:222
pinocchio::ConfigurationOut_t ConfigurationOut_t
Definition: fwd.hh:109
constraints::LiegroupSpacePtr_t LiegroupSpacePtr_t
Definition: fwd.hh:172
pinocchio::ConfigurationIn_t ConfigurationIn_t
Definition: fwd.hh:108
std::pair< value_type, value_type > interval_t
Definition: fwd.hh:175
pinocchio::size_type size_type
Definition: fwd.hh:173
pinocchio::Configuration_t Configuration_t
Definition: fwd.hh:107
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