tasks.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_TASKS_H_
31 #define EXOTICA_CORE_TASKS_H_
32 
33 #include <Eigen/Dense>
34 #include <map>
35 #include <memory>
36 #include <string>
37 #include <vector>
38 
40 #include <exotica_core/property.h>
43 
44 namespace exotica
45 {
47 {
48  int id;
49  int start;
50  int length;
53 };
54 
55 struct Task
56 {
57  Task() = default;
58  virtual ~Task() = default;
59 
60  virtual void Initialize(const std::vector<exotica::Initializer>& inits, std::shared_ptr<PlanningProblem> prob, TaskSpaceVector& Phi);
61 
64  std::vector<TaskIndexing> indexing;
65 
68  int num_tasks;
69  double tolerance = 0.0; // To avoid numerical issues consider all values below this as 0.0.
70 
71 protected:
72  std::vector<TaskInitializer> task_initializers_;
73 };
74 
75 struct TimeIndexedTask : public Task
76 {
77  TimeIndexedTask() = default;
78  virtual ~TimeIndexedTask() = default;
79 
80  virtual void Initialize(const std::vector<exotica::Initializer>& inits, std::shared_ptr<PlanningProblem> prob, TaskSpaceVector& Phi);
81  void UpdateS();
82 
83  void Update(const TaskSpaceVector& big_Phi,
84  Eigen::MatrixXdRefConst big_dPhi_dx,
85  Eigen::MatrixXdRefConst big_dPhi_du,
86  HessianRefConst big_ddPhi_ddx,
87  HessianRefConst big_ddPhi_ddu,
88  HessianRefConst big_ddPhi_dxdu,
89  int t);
90  void Update(const TaskSpaceVector& big_Phi,
91  Eigen::MatrixXdRefConst big_dPhi_dx,
92  Eigen::MatrixXdRefConst big_dPhi_du,
93  int t);
94 
95  void Update(const TaskSpaceVector& big_Phi, Eigen::MatrixXdRefConst big_jacobian, HessianRefConst big_hessian, int t);
96  void Update(const TaskSpaceVector& big_Phi, Eigen::MatrixXdRefConst big_jacobian, int t);
97  void Update(const TaskSpaceVector& big_Phi, int t);
98 
99  void ReinitializeVariables(int _T, std::shared_ptr<PlanningProblem> _prob, const TaskSpaceVector& _Phi);
100 
101  inline void ValidateTimeIndex(int& t_in) const;
102 
103  void SetGoal(const std::string& task_name, Eigen::VectorXdRefConst goal, int t);
104  Eigen::VectorXd GetGoal(const std::string& task_name, int t) const;
105 
106  void SetRho(const std::string& task_name, const double rho_in, int t);
107  double GetRho(const std::string& task_name, int t) const;
108 
109  Eigen::VectorXd GetTaskError(const std::string& task_name, int t) const;
110  Eigen::MatrixXd GetS(const std::string& task_name, int t) const;
111 
112  std::vector<Eigen::VectorXd> rho;
113  std::vector<TaskSpaceVector> y;
114  std::vector<Eigen::VectorXd> ydiff;
115  std::vector<TaskSpaceVector> Phi;
116  std::vector<Hessian> hessian;
117  std::vector<Hessian> ddPhi_ddx;
118  std::vector<Hessian> ddPhi_ddu;
119  std::vector<Hessian> ddPhi_dxdu;
120  std::vector<Eigen::MatrixXd> jacobian;
121  std::vector<Eigen::MatrixXd> dPhi_dx;
122  std::vector<Eigen::MatrixXd> dPhi_du;
123  std::vector<Eigen::MatrixXd> S;
124  int T;
125 };
126 
127 struct EndPoseTask : public Task
128 {
129  EndPoseTask() = default;
130  virtual ~EndPoseTask() = default;
131 
132  virtual void Initialize(const std::vector<exotica::Initializer>& inits, std::shared_ptr<PlanningProblem> prob, TaskSpaceVector& Phi);
133  void UpdateS();
134  void Update(const TaskSpaceVector& big_Phi, Eigen::MatrixXdRefConst big_jacobian, HessianRefConst big_hessian);
135  void Update(const TaskSpaceVector& big_Phi, Eigen::MatrixXdRefConst big_jacobian);
136  void Update(const TaskSpaceVector& big_Phi);
137 
138  void SetGoal(const std::string& task_name, Eigen::VectorXdRefConst goal);
139  Eigen::VectorXd GetGoal(const std::string& task_name) const;
140 
141  void SetRho(const std::string& task_name, const double rho_in);
142  double GetRho(const std::string& task_name) const;
143 
144  Eigen::VectorXd GetTaskError(const std::string& task_name) const;
145  Eigen::MatrixXd GetS(const std::string& task_name) const;
146 
147  Eigen::VectorXd rho;
149  Eigen::VectorXd ydiff;
151  Eigen::MatrixXd jacobian;
153  Eigen::MatrixXd S;
154 };
155 
156 struct SamplingTask : public Task
157 {
158  SamplingTask() = default;
159  virtual ~SamplingTask() = default;
160 
161  virtual void Initialize(const std::vector<exotica::Initializer>& inits, std::shared_ptr<PlanningProblem> prob, TaskSpaceVector& Phi);
162  void UpdateS();
163  void Update(const TaskSpaceVector& big_Phi);
164 
165  void SetGoal(const std::string& task_name, Eigen::VectorXdRefConst goal);
166  Eigen::VectorXd GetGoal(const std::string& task_name) const;
167 
168  void SetRho(const std::string& task_name, const double rho);
169  double GetRho(const std::string& task_name) const;
170 
171  Eigen::VectorXd rho;
173  Eigen::VectorXd ydiff;
175  Eigen::MatrixXd S;
176 };
177 } // namespace exotica
178 
179 #endif // EXOTICA_CORE_TASKS_H_
std::vector< TaskSpaceVector > y
Definition: tasks.h:113
Eigen::MatrixXd S
Definition: tasks.h:153
Eigen::MatrixXd jacobian
Definition: tasks.h:151
Eigen::MatrixXd S
Definition: tasks.h:175
Eigen::VectorXd ydiff
Definition: tasks.h:149
Eigen::VectorXd rho
Definition: tasks.h:147
int length_jacobian
Definition: tasks.h:67
Eigen::VectorXd ydiff
Definition: tasks.h:173
std::vector< TaskMapPtr > TaskMapVec
Definition: task_map.h:94
Eigen::VectorXd rho
Definition: tasks.h:171
Hessian hessian
Definition: tasks.h:152
std::vector< Hessian > hessian
Definition: tasks.h:116
std::vector< Eigen::VectorXd > rho
Definition: tasks.h:112
int num_tasks
Definition: tasks.h:68
TaskSpaceVector Phi
Definition: tasks.h:150
TaskSpaceVector y
Definition: tasks.h:148
std::vector< Hessian > ddPhi_dxdu
Definition: tasks.h:119
const Eigen::Ref< const Eigen::MatrixXd > & MatrixXdRefConst
Definition: conversions.h:53
Eigen::internal::ref_selector< Hessian >::type HessianRefConst
Definition: conversions.h:166
std::vector< Eigen::VectorXd > ydiff
Definition: tasks.h:114
TaskSpaceVector y
Definition: tasks.h:172
Eigen::Array< Eigen::MatrixXd, Eigen::Dynamic, 1 > Hessian
Definition: conversions.h:154
TaskMapMap task_maps
Definition: tasks.h:62
std::vector< TaskInitializer > task_initializers_
Definition: tasks.h:72
int length_Phi
Definition: tasks.h:66
std::vector< Eigen::MatrixXd > dPhi_du
Definition: tasks.h:122
const Eigen::Ref< const Eigen::VectorXd > & VectorXdRefConst
Convenience wrapper for storing references to sub-matrices/vectors.
Definition: conversions.h:52
std::vector< Eigen::MatrixXd > S
Definition: tasks.h:123
std::vector< Hessian > ddPhi_ddu
Definition: tasks.h:118
std::map< std::string, TaskMapPtr > TaskMapMap
The mapping by name of TaskMaps.
Definition: task_map.h:93
std::vector< Hessian > ddPhi_ddx
Definition: tasks.h:117
std::vector< TaskIndexing > indexing
Definition: tasks.h:64
std::vector< TaskSpaceVector > Phi
Definition: tasks.h:115
std::vector< Eigen::MatrixXd > jacobian
Definition: tasks.h:120
std::vector< Eigen::MatrixXd > dPhi_dx
Definition: tasks.h:121
TaskSpaceVector Phi
Definition: tasks.h:174
TaskMapVec tasks
Definition: tasks.h:63


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