planning_problem.h
Go to the documentation of this file.
1 //
2 // Copyright (c) 2018-2020, University of Edinburgh, University of Oxford
3 // All rights reserved.
4 //
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are met:
7 //
8 // * Redistributions of source code must retain the above copyright notice,
9 // this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution.
13 // * Neither the name of nor the names of its contributors may be used to
14 // endorse or promote products derived from this software without specific
15 // prior written permission.
16 //
17 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 // POSSIBILITY OF SUCH DAMAGE.
28 //
29 
30 #ifndef EXOTICA_CORE_PLANNING_PROBLEM_H_
31 #define EXOTICA_CORE_PLANNING_PROBLEM_H_
32 
33 #include <chrono>
34 #include <map>
35 #include <string>
36 #include <vector>
37 
38 #include <exotica_core/object.h>
39 #include <exotica_core/scene.h>
40 #include <exotica_core/task_map.h>
44 
45 #define REGISTER_PROBLEM_TYPE(TYPE, DERIV) EXOTICA_CORE_REGISTER_CORE(exotica::PlanningProblem, TYPE, DERIV)
46 
47 namespace exotica
48 {
50 {
51  NotStarted = -1,
52  // Continue = 0,
58  Divergence,
61  // Condition,
62 };
63 
64 class PlanningProblem : public Object, Uncopyable, public virtual InstantiableBase, public std::enable_shared_from_this<PlanningProblem>
65 {
66 public:
68  virtual ~PlanningProblem();
69 
70  void InstantiateBase(const Initializer& init) override;
71  TaskMapMap& GetTaskMaps();
72  TaskMapVec& GetTasks();
73  ScenePtr GetScene() const;
74  std::string Print(const std::string& prepend) const override;
75 
76  void SetStartState(Eigen::VectorXdRefConst x);
77  Eigen::VectorXd GetStartState() const;
78  virtual Eigen::VectorXd ApplyStartState(bool update_traj = true);
79 
80  void SetStartTime(double t);
81  double GetStartTime() const;
82 
83  virtual void PreUpdate();
84  unsigned int GetNumberOfProblemUpdates() const { return number_of_problem_updates_; }
85  void ResetNumberOfProblemUpdates() { number_of_problem_updates_ = 0; }
86  std::pair<std::vector<double>, std::vector<double>> GetCostEvolution() const;
87  int GetNumberOfIterations() const;
88  double GetCostEvolution(int index) const;
89  void ResetCostEvolution(size_t size);
90  void SetCostEvolution(int index, double value);
91  KinematicRequestFlags GetFlags() const { return flags_; }
93  virtual bool IsValid() { ThrowNamed("Not implemented"); };
94  double t_start;
96 
97  int N = 0;
98  [[deprecated("Replaced by Scene::get_num_positions")]] int get_num_positions() const;
99  [[deprecated("Replaced by Scene::get_num_velocities")]] int get_num_velocities() const;
100  [[deprecated("Replaced by Scene::get_num_controls")]] int get_num_controls() const;
101 
102 protected:
103  void UpdateTaskKinematics(std::shared_ptr<KinematicResponse> response);
104  void UpdateMultipleTaskKinematics(std::vector<std::shared_ptr<KinematicResponse>> responses);
105 
110  Eigen::VectorXd start_state_;
111  unsigned int number_of_problem_updates_ = 0; // Stores number of times the problem has been updated
112  std::vector<std::pair<std::chrono::high_resolution_clock::time_point, double>> cost_evolution_;
113 };
114 
116 typedef std::shared_ptr<PlanningProblem> PlanningProblemPtr;
117 typedef std::shared_ptr<const PlanningProblem> PlanningProblemConstPtr;
118 } // namespace exotica
119 
120 #endif // EXOTICA_CORE_PLANNING_PROBLEM_H_
std::vector< std::pair< std::chrono::high_resolution_clock::time_point, double > > cost_evolution_
unsigned int GetNumberOfProblemUpdates() const
std::vector< TaskMapPtr > TaskMapVec
Definition: task_map.h:94
std::shared_ptr< Scene > ScenePtr
Definition: scene.h:246
TerminationCriterion termination_criterion
KinematicRequestFlags
unsigned int index
#define ThrowNamed(m)
Definition: exception.h:42
std::shared_ptr< const PlanningProblem > PlanningProblemConstPtr
const Eigen::Ref< const Eigen::VectorXd > & VectorXdRefConst
Convenience wrapper for storing references to sub-matrices/vectors.
Definition: conversions.h:52
KinematicRequestFlags GetFlags() const
std::map< std::string, TaskMapPtr > TaskMapMap
The mapping by name of TaskMaps.
Definition: task_map.h:93
std::shared_ptr< PlanningProblem > PlanningProblemPtr
double x
Eigen::VectorXd start_state_
Factory< PlanningProblem > PlanningProblemFac


exotica_core
Author(s): Yiming Yang, Michael Camilleri
autogenerated on Sat Apr 10 2021 02:34:49