IMP  2.1.0
The Integrative Modeling Platform
local_planners.h
Go to the documentation of this file.
1 /**
2  * \file kinematics/local_planners.h
3  * \brief Planners
4  *
5  * Copyright 2007-2010 Sali Lab. All rights reserved.
6  *
7  */
8 
9 #ifndef IMPKINEMATICS_LOCAL_PLANNERS_H
10 #define IMPKINEMATICS_LOCAL_PLANNERS_H
11 
12 #include "kinematics_config.h"
13 #include "DOFValues.h"
14 #include "directional_DOFs.h"
15 #include "DOFsSampler.h"
16 #include <IMP/base/Object.h>
17 #include <IMP/base/Pointer.h>
18 #include <IMP/kernel/Model.h>
19 
20 IMPKINEMATICS_BEGIN_NAMESPACE
21 
22 /** general interface for planning the motion between two
23  configuration nodes, each abstracted as a vector of DoFs
24 */
25 class IMPKINEMATICSEXPORT LocalPlanner
26 : public IMP::base::Object
27 {
29 
30 public:
31  LocalPlanner(kernel::Model* model, DOFsSampler* dofs_sampler);
32 
33  // plan a path of valid intermediate nodes
34  // from existing node q_from until the valid node that is
35  // somewhay close to q_rand
36  virtual
37  std::vector<DOFValues> plan(DOFValues q_near,
38  DOFValues q_rand) = 0;
39 
40  bool is_valid(const DOFValues& values) {
41  dofs_sampler_->apply(values);
42  double score = sf_->evaluate_if_below(false, 0.0); //TODO: what here?
43  //std::cerr << "score = " << score << std::endl;
44  if(score <= 0.000001)
45  return true;
46  return false;
47  }
48 
49  protected:
51  DOFsSampler* dofs_sampler_;
53 };
54 
55 
56 /**
57  Local planner implementation that samples conformations on a path
58  between two nodes.
59  @note the default path planning is over a linear interpolation between
60  the nodes
61 */
62 class IMPKINEMATICSEXPORT PathLocalPlanner : public LocalPlanner {
63 public:
64  //! construct a path planner (default planning is linear)
65  /**
66  construct a path planner
67  @param model the working model
68  @param dofs_sampler an object for sampling node configurations
69  @param directional_dof XX TODO XX
70  @param save_step_interval the interval for recording nodes in the path.
71  For instance, 2 would mean save every second node
72  in the local plan.
73  */
74  PathLocalPlanner(kernel::Model* model, DOFsSampler* dofs_sampler,
75  DirectionalDOF* directional_dof,
76  int save_step_interval = 1);
77 
78 protected:
79 
80  /** plan a linear path of intermediate nodes with a properly calculated
81  step size from existing node q_from until the valid node that is
82  found closest to q_rand (inclusive)
83  */
84  virtual std::vector<DOFValues> plan(DOFValues q_from, DOFValues q_rand);
85 
86 private:
87  DirectionalDOF* d_;
88  unsigned int save_step_interval_; // if 0, save only last valid node
89 };
90 
93 
94 IMPKINEMATICS_END_NAMESPACE
95 
96 #endif /* IMPKINEMATICS_LOCAL_PLANNERS_H */
A nullptr-initialized pointer to an IMP Object.
a simple class for storage of DOF values.
A smart pointer to a ref-counted Object that is a class memeber.
Definition: base/Pointer.h:146
Copyright 2007-2010 Sali Lab. All rights reserved.
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
Storage of a model, its restraints, constraints and particles.
Common base class for heavy weight IMP objects.
#define IMP_OBJECTS(Name, PluralName)
Define the types for storing sets of objects.
A shared base class to help in debugging and things.
Class for storing model, its restraints, constraints, and particles.