hpp-core  4.9.0
Implement basic classes for canonical path planning for kinematic chains.
problem.hh
Go to the documentation of this file.
1 
2 //
3 // Copyright (c) 2005, 2006, 2007, 2008, 2009, 2010, 2011 CNRS
4 // Authors: Florent Lamiraux
5 //
6 // This file is part of hpp-core
7 // hpp-core is free software: you can redistribute it
8 // and/or modify it under the terms of the GNU Lesser General Public
9 // License as published by the Free Software Foundation, either version
10 // 3 of the License, or (at your option) any later version.
11 //
12 // hpp-core is distributed in the hope that it will be
13 // useful, but WITHOUT ANY WARRANTY; without even the implied warranty
14 // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 // General Lesser Public License for more details. You should have
16 // received a copy of the GNU Lesser General Public License along with
17 // hpp-core If not, see
18 // <http://www.gnu.org/licenses/>.
19 
20 #ifndef HPP_CORE_PROBLEM_HH
21 # define HPP_CORE_PROBLEM_HH
22 
23 # include <stdexcept>
24 
25 # include <hpp/pinocchio/device.hh>
26 # include <hpp/util/pointer.hh>
27 
28 # include <hpp/core/config.hh>
30 # include <hpp/core/container.hh>
31 # include <hpp/core/parameter.hh>
32 
33 namespace hpp {
34  namespace core {
37 
48  class HPP_CORE_DLLAPI Problem
49  {
50  public:
53  static ProblemPtr_t create (DevicePtr_t robot);
54 
58  Problem ();
59 
60  virtual ~Problem ();
61 
64 
66  const DevicePtr_t& robot () const {
67  return robot_;
68  }
69 
72  {
73  return initConf_;
74  }
76  void initConfig (const ConfigurationPtr_t& inConfig);
78  void target (const ProblemTargetPtr_t& target)
79  {
80  target_ = target;
81  }
83  const ProblemTargetPtr_t& target () const
84  {
85  return target_;
86  }
88  const Configurations_t& goalConfigs () const;
90  void addGoalConfig (const ConfigurationPtr_t& config);
92  void resetGoalConfigs ();
93 
95 
98 
104  steeringMethod_ = sm;
105  if (constraints_) steeringMethod_->constraints (constraints_);
106  }
107 
110  return steeringMethod_;
111  }
112 
115  {
116  distance_ = distance;
117  }
119  const DistancePtr_t& distance () const
120  {
121  return distance_;
122  }
124 
127 
131  void configValidation (const ConfigValidationsPtr_t& configValidations)
132  {
133  configValidations_ = configValidations;
134  }
137  {
138  return configValidations_;
139  }
140 
143  void resetConfigValidations ();
144 
147  void clearConfigValidations ();
148 
150  void addConfigValidation (const ConfigValidationPtr_t& configValidation);
151 
155  virtual void pathValidation (const PathValidationPtr_t& pathValidation);
156 
159  {
160  return pathValidation_;
161  }
163 
164 
168  void configurationShooter (const ConfigurationShooterPtr_t& configurationShooter);
169 
172  {
173  return configurationShooter_;
174  }
176 
180  void pathProjector (const PathProjectorPtr_t& pathProjector)
181  {
182  pathProjector_ = pathProjector;
183  }
184 
187  {
188  return pathProjector_;
189  }
191 
194 
199  void constraints (const ConstraintSetPtr_t& constraints)
200  {
201  constraints_ = constraints;
202  if (steeringMethod_) steeringMethod_->constraints (constraints);
203  }
204 
207  {
208  return constraints_;
209  }
211 
213  virtual void checkProblem () const;
214 
217 
220  void addObstacle (const CollisionObjectPtr_t &object);
224  void removeObstacleFromJoint (const JointPtr_t& joint,
225  const CollisionObjectConstPtr_t& obstacle);
226 
244  void filterCollisionPairs ();
245 
247  const ObjectStdVector_t &collisionObstacles() const;
249  void collisionObstacles (const ObjectStdVector_t &collisionObstacles);
251 
255  const Parameter& getParameter (const std::string& name) const
256  {
257  if (parameters.has(name))
258  return parameters.get(name);
259  else
260  return parameterDescription(name).defaultValue();
261  }
262 
269  void setParameter (const std::string& name, const Parameter& value);
270 
282  static void declareParameter (const ParameterDescription& desc);
283 
285  static const Container<ParameterDescription>& parameterDescriptions ();
286 
288  static const ParameterDescription& parameterDescription (const std::string& name);
289 
291 
292  protected:
294  Problem (DevicePtr_t robot);
295 
296  void init (ProblemWkPtr_t wkPtr);
297 
298  private :
299  ProblemWkPtr_t wkPtr_;
301  DevicePtr_t robot_;
303  DistancePtr_t distance_;
305  ConfigurationPtr_t initConf_;
307  Configurations_t goalConfigurations_;
309  ProblemTargetPtr_t target_;
311  SteeringMethodPtr_t steeringMethod_;
313  ConfigValidationsPtr_t configValidations_;
315  PathValidationPtr_t pathValidation_;
317  PathProjectorPtr_t pathProjector_;
319  ObjectStdVector_t collisionObstacles_;
321  ConstraintSetPtr_t constraints_;
323  ConfigurationShooterPtr_t configurationShooter_;
324  }; // class Problem
326  } // namespace core
327 } // namespace hpp
328 
329 #define HPP_START_PARAMETER_DECLARATION(name) \
330  struct HPP_CORE_DLLAPI __InitializerClass_##name { \
331  __InitializerClass_##name () {
332 
333 #define HPP_END_PARAMETER_DECLARATION(name) \
334  } \
335  }; \
336  extern "C" { \
337  __InitializerClass_##name __instance_##name; \
338  }
339 
340 #endif // HPP_CORE_PROBLEM_HH
const DistancePtr_t & distance() const
Get distance between configuration.
Definition: problem.hh:119
boost::shared_ptr< ConfigValidations > ConfigValidationsPtr_t
Definition: fwd.hh:106
pinocchio::DevicePtr_t DevicePtr_t
Definition: fwd.hh:114
void steeringMethod(const SteeringMethodPtr_t &sm)
Definition: problem.hh:103
Definition: problem.hh:48
ConfigurationShooterPtr_t configurationShooter() const
Get path validation method.
Definition: problem.hh:171
boost::shared_ptr< ConfigurationShooter > ConfigurationShooterPtr_t
Definition: fwd.hh:103
const ConfigValidationsPtr_t & configValidations() const
Get configuration validation methods.
Definition: problem.hh:136
boost::shared_ptr< ConstraintSet > ConstraintSetPtr_t
Definition: fwd.hh:110
PathValidationPtr_t pathValidation() const
Get path validation method.
Definition: problem.hh:158
ObjectFactory * create(ObjectFactory *parent=NULL, const XMLElement *element=NULL)
Definition: parameter.hh:117
pinocchio::CollisionObjectPtr_t CollisionObjectPtr_t
Definition: fwd.hh:89
pinocchio::JointPtr_t JointPtr_t
Definition: fwd.hh:133
Definition: container.hh:55
void configValidation(const ConfigValidationsPtr_t &configValidations)
Definition: problem.hh:131
PathProjectorPtr_t pathProjector() const
Get path projector method.
Definition: problem.hh:186
const ProblemTargetPtr_t & target() const
Get the target.
Definition: problem.hh:83
boost::shared_ptr< ConfigValidation > ConfigValidationPtr_t
Definition: fwd.hh:105
Definition: parameter.hh:53
SteeringMethodPtr_t steeringMethod() const
Get steering method.
Definition: problem.hh:109
const ConfigurationPtr_t & initConfig() const
Get shared pointer to initial configuration.
Definition: problem.hh:71
void constraints(const ConstraintSetPtr_t &constraints)
Definition: problem.hh:199
boost::shared_ptr< PathValidation > PathValidationPtr_t
Definition: fwd.hh:290
boost::shared_ptr< PathProjector > PathProjectorPtr_t
Definition: fwd.hh:306
void target(const ProblemTargetPtr_t &target)
Set the target.
Definition: problem.hh:78
std::vector< ConfigurationPtr_t > Configurations_t
Definition: fwd.hh:100
pinocchio::ConfigurationPtr_t ConfigurationPtr_t
Definition: fwd.hh:99
Container< Parameter > parameters
Definition: problem.hh:290
void distance(const DistancePtr_t &distance)
Set distance between configurations.
Definition: problem.hh:114
boost::shared_ptr< SteeringMethod > SteeringMethodPtr_t
Definition: fwd.hh:194
void pathProjector(const PathProjectorPtr_t &pathProjector)
Definition: problem.hh:180
const Parameter & getParameter(const std::string &name) const
Definition: problem.hh:255
boost::shared_ptr< Distance > DistancePtr_t
Definition: fwd.hh:122
boost::shared_ptr< ProblemTarget > ProblemTargetPtr_t
Definition: fwd.hh:175
const ConstraintSetPtr_t & constraints() const
Get constraint set.
Definition: problem.hh:206
boost::shared_ptr< Problem > ProblemPtr_t
Definition: fwd.hh:179
pinocchio::CollisionObjectConstPtr_t CollisionObjectConstPtr_t
Definition: fwd.hh:90
std::vector< CollisionObjectPtr_t > ObjectStdVector_t
Definition: fwd.hh:167
FCL_REAL distance(const KDOP< N > &other, Vec3f *P=NULL, Vec3f *Q=NULL) const
const DevicePtr_t & robot() const
return shared pointer to robot.
Definition: problem.hh:66