tasks.cpp
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 #include <exotica_core/task_map.h>
31 #include <exotica_core/tasks.h>
32 
33 #include <exotica_core/task_initializer.h>
34 
35 namespace exotica
36 {
37 void Task::Initialize(const std::vector<exotica::Initializer>& inits, PlanningProblemPtr prob, TaskSpaceVector& Phi)
38 {
39  for (const exotica::Initializer& init : inits)
40  {
41  TaskInitializer task(init);
42  auto it = prob->GetTaskMaps().find(task.Task);
43  if (it == prob->GetTaskMaps().end()) ThrowPretty("Task map '" << task.Task << "' has not been defined!");
44  task_maps[task.Task] = it->second;
45  tasks.push_back(it->second);
46  task_initializers_.push_back(task);
47  }
48  num_tasks = tasks.size();
49  length_Phi = 0;
50  length_jacobian = 0;
51  Phi.map.resize(0);
52  indexing.resize(tasks.size());
53  for (int i = 0; i < num_tasks; ++i)
54  {
55  indexing[i].id = i;
56  indexing[i].start = length_Phi;
57  indexing[i].length = tasks[i]->length;
58  indexing[i].start_jacobian = length_jacobian;
59  indexing[i].length_jacobian = tasks[i]->length_jacobian;
60 
61  AppendVector(Phi.map, TaskVectorEntry::reindex(tasks[i]->GetLieGroupIndices(), tasks[i]->start, indexing[i].start));
62  length_Phi += tasks[i]->length;
63  length_jacobian += tasks[i]->length_jacobian;
64  }
65  Phi.SetZero(length_Phi);
66 }
67 
68 void EndPoseTask::Initialize(const std::vector<exotica::Initializer>& inits, PlanningProblemPtr prob, TaskSpaceVector& unused)
69 {
70  Task::Initialize(inits, prob, Phi);
71  y = Phi;
72  y.SetZero(length_Phi);
73  rho = Eigen::VectorXd::Ones(num_tasks);
74  if (prob->GetFlags() & KIN_J) jacobian = Eigen::MatrixXd(length_jacobian, prob->N);
75  if (prob->GetFlags() & KIN_H) hessian.setConstant(length_jacobian, Eigen::MatrixXd::Zero(prob->N, prob->N));
76  S = Eigen::MatrixXd::Identity(length_jacobian, length_jacobian);
77  ydiff = Eigen::VectorXd::Zero(length_jacobian);
78 
79  for (int i = 0; i < num_tasks; ++i)
80  {
81  TaskInitializer task(inits[i]);
82  if (task.Goal.rows() == 0)
83  {
84  // Keep zero goal
85  }
86  else if (task.Goal.rows() == tasks[i]->length)
87  {
88  y.data.segment(indexing[i].start, indexing[i].length) = task.Goal;
89  }
90  else
91  {
92  ThrowPretty("Invalid task goal size! Expecting " << tasks[i]->length << " got " << task.Goal.rows());
93  }
94  if (task.Rho.rows() == 0)
95  {
96  rho(i) = 1.0;
97  }
98  else if (task.Rho.rows() == 1)
99  {
100  rho(i) = task.Rho(0);
101  }
102  else
103  {
104  ThrowPretty("Invalid task rho size! Expecting 1 got " << task.Rho.rows());
105  }
106  }
107 }
108 
110 {
111  for (const TaskIndexing& task : indexing)
112  {
113  for (int i = 0; i < task.length_jacobian; ++i)
114  {
115  S(i + task.start_jacobian, i + task.start_jacobian) = rho(task.id);
116  }
117  if (rho(task.id) != 0.0) tasks[task.id]->is_used = true;
118  }
119 }
120 
121 void EndPoseTask::Update(const TaskSpaceVector& big_Phi, Eigen::MatrixXdRefConst big_jacobian, HessianRefConst big_hessian)
122 {
123  for (const TaskIndexing& task : indexing)
124  {
125  Phi.data.segment(task.start, task.length) = big_Phi.data.segment(tasks[task.id]->start, tasks[task.id]->length);
126  jacobian.middleRows(task.start_jacobian, task.length_jacobian) = big_jacobian.middleRows(tasks[task.id]->start_jacobian, tasks[task.id]->length_jacobian);
127  hessian.segment(task.start_jacobian, task.length_jacobian) = big_hessian.segment(tasks[task.id]->start_jacobian, tasks[task.id]->length_jacobian);
128  }
129  ydiff = Phi - y;
130 }
131 
133 {
134  for (const TaskIndexing& task : indexing)
135  {
136  Phi.data.segment(task.start, task.length) = big_Phi.data.segment(tasks[task.id]->start, tasks[task.id]->length);
137  jacobian.middleRows(task.start_jacobian, task.length_jacobian) = big_jacobian.middleRows(tasks[task.id]->start_jacobian, tasks[task.id]->length_jacobian);
138  }
139  ydiff = Phi - y;
140 }
141 
143 {
144  for (const TaskIndexing& task : indexing)
145  {
146  Phi.data.segment(task.start, task.length) = big_Phi.data.segment(tasks[task.id]->start, tasks[task.id]->length);
147  }
148  ydiff = Phi - y;
149 }
150 
151 void EndPoseTask::SetGoal(const std::string& task_name, Eigen::VectorXdRefConst goal)
152 {
153  for (size_t i = 0; i < indexing.size(); ++i)
154  {
155  if (tasks[i]->GetObjectName() == task_name)
156  {
157  if (goal.rows() != indexing[i].length) ThrowPretty("Expected length of " << indexing[i].length << " and got " << goal.rows());
158  y.data.segment(indexing[i].start, indexing[i].length) = goal;
159  return;
160  }
161  }
162  ThrowPretty("Cannot set Goal. Task Map '" << task_name << "' does not exist.");
163 }
164 
165 void EndPoseTask::SetRho(const std::string& task_name, const double rho_in)
166 {
167  for (size_t i = 0; i < indexing.size(); ++i)
168  {
169  if (tasks[i]->GetObjectName() == task_name)
170  {
171  rho(indexing[i].id) = rho_in;
172  UpdateS();
173  return;
174  }
175  }
176  ThrowPretty("Cannot set rho. Task Map '" << task_name << "' does not exist.");
177 }
178 
179 Eigen::VectorXd EndPoseTask::GetGoal(const std::string& task_name) const
180 {
181  for (size_t i = 0; i < indexing.size(); ++i)
182  {
183  if (tasks[i]->GetObjectName() == task_name)
184  {
185  return y.data.segment(indexing[i].start, indexing[i].length);
186  }
187  }
188  ThrowPretty("Cannot get Goal. Task Map '" << task_name << "' does not exist.");
189 }
190 
191 double EndPoseTask::GetRho(const std::string& task_name) const
192 {
193  for (size_t i = 0; i < indexing.size(); ++i)
194  {
195  if (tasks[i]->GetObjectName() == task_name)
196  {
197  return rho(indexing[i].id);
198  }
199  }
200  ThrowPretty("Cannot get rho. Task Map '" << task_name << "' does not exist.");
201 }
202 
203 Eigen::MatrixXd EndPoseTask::GetS(const std::string& task_name) const
204 {
205  for (size_t i = 0; i < indexing.size(); ++i)
206  {
207  if (tasks[i]->GetObjectName() == task_name)
208  {
209  // We are interested in the square matrix of dimension length_jacobian
210  return S.block(indexing[i].start_jacobian, indexing[i].start_jacobian, indexing[i].length_jacobian, indexing[i].length_jacobian);
211  }
212  }
213  ThrowPretty("Cannot get S. Task map '" << task_name << "' does not exist.");
214 }
215 
216 Eigen::VectorXd EndPoseTask::GetTaskError(const std::string& task_name) const
217 {
218  for (size_t i = 0; i < indexing.size(); ++i)
219  {
220  if (tasks[i]->GetObjectName() == task_name)
221  {
222  return ydiff.segment(indexing[i].start_jacobian, indexing[i].length_jacobian);
223  }
224  }
225  ThrowPretty("Cannot get task error. Task map '" << task_name << "' does not exist.");
226 }
227 
228 void TimeIndexedTask::Initialize(const std::vector<exotica::Initializer>& inits, PlanningProblemPtr prob, TaskSpaceVector& Phi)
229 {
230  Task::Initialize(inits, prob, Phi);
231  Phi.SetZero(length_Phi);
232 }
233 
235 {
236  for (int t = 0; t < T; ++t)
237  {
238  for (const TaskIndexing& task : indexing)
239  {
240  for (int i = 0; i < task.length_jacobian; ++i)
241  {
242  S[t](i + task.start_jacobian, i + task.start_jacobian) = rho[t](task.id);
243  }
244  if (rho[t](task.id) != 0.0) tasks[task.id]->is_used = true;
245  }
246  }
247 }
248 
250  Eigen::MatrixXdRefConst big_dPhi_dx,
251  Eigen::MatrixXdRefConst big_dPhi_du,
252  HessianRefConst big_ddPhi_ddx,
253  HessianRefConst big_ddPhi_ddu,
254  HessianRefConst big_ddPhi_dxdu,
255  int t)
256 {
257  for (const TaskIndexing& task : indexing)
258  {
259  Phi[t].data.segment(task.start, task.length) = big_Phi.data.segment(tasks[task.id]->start, tasks[task.id]->length);
260  dPhi_dx[t].middleRows(task.start_jacobian, task.length_jacobian) = big_dPhi_dx.middleRows(tasks[task.id]->start_jacobian, tasks[task.id]->length_jacobian);
261  dPhi_du[t].middleRows(task.start_jacobian, task.length_jacobian) = big_dPhi_du.middleRows(tasks[task.id]->start_jacobian, tasks[task.id]->length_jacobian);
262  ddPhi_ddx[t].segment(task.start_jacobian, task.length_jacobian) = big_ddPhi_ddx.segment(tasks[task.id]->start_jacobian, tasks[task.id]->length_jacobian);
263  ddPhi_ddu[t].segment(task.start_jacobian, task.length_jacobian) = big_ddPhi_ddu.segment(tasks[task.id]->start_jacobian, tasks[task.id]->length_jacobian);
264  ddPhi_dxdu[t].segment(task.start_jacobian, task.length_jacobian) = big_ddPhi_dxdu.segment(tasks[task.id]->start_jacobian, tasks[task.id]->length_jacobian);
265  }
266  ydiff[t] = Phi[t] - y[t];
267 }
268 
270  Eigen::MatrixXdRefConst big_dPhi_dx,
271  Eigen::MatrixXdRefConst big_dPhi_du,
272  int t)
273 {
274  for (const TaskIndexing& task : indexing)
275  {
276  Phi[t].data.segment(task.start, task.length) = big_Phi.data.segment(tasks[task.id]->start, tasks[task.id]->length);
277  dPhi_dx[t].middleRows(task.start_jacobian, task.length_jacobian) = big_dPhi_dx.middleRows(tasks[task.id]->start_jacobian, tasks[task.id]->length_jacobian);
278  dPhi_du[t].middleRows(task.start_jacobian, task.length_jacobian) = big_dPhi_du.middleRows(tasks[task.id]->start_jacobian, tasks[task.id]->length_jacobian);
279  }
280  ydiff[t] = Phi[t] - y[t];
281 }
282 
283 void TimeIndexedTask::Update(const TaskSpaceVector& big_Phi, Eigen::MatrixXdRefConst big_jacobian, HessianRefConst big_hessian, int t)
284 {
285  for (const TaskIndexing& task : indexing)
286  {
287  Phi[t].data.segment(task.start, task.length) = big_Phi.data.segment(tasks[task.id]->start, tasks[task.id]->length);
288  jacobian[t].middleRows(task.start_jacobian, task.length_jacobian) = big_jacobian.middleRows(tasks[task.id]->start_jacobian, tasks[task.id]->length_jacobian);
289  hessian[t].segment(task.start_jacobian, task.length_jacobian) = big_hessian.segment(tasks[task.id]->start_jacobian, tasks[task.id]->length_jacobian);
290  }
291  ydiff[t] = Phi[t] - y[t];
292 }
293 
294 void TimeIndexedTask::Update(const TaskSpaceVector& big_Phi, Eigen::MatrixXdRefConst big_jacobian, int t)
295 {
296  for (const TaskIndexing& task : indexing)
297  {
298  Phi[t].data.segment(task.start, task.length) = big_Phi.data.segment(tasks[task.id]->start, tasks[task.id]->length);
299  jacobian[t].middleRows(task.start_jacobian, task.length_jacobian) = big_jacobian.middleRows(tasks[task.id]->start_jacobian, tasks[task.id]->length_jacobian);
300  }
301  ydiff[t] = Phi[t] - y[t];
302 }
303 
304 void TimeIndexedTask::Update(const TaskSpaceVector& big_Phi, int t)
305 {
306  for (const TaskIndexing& task : indexing)
307  {
308  Phi[t].data.segment(task.start, task.length) = big_Phi.data.segment(tasks[task.id]->start, tasks[task.id]->length);
309  }
310  ydiff[t] = Phi[t] - y[t];
311 }
312 
313 inline void TimeIndexedTask::ValidateTimeIndex(int& t_in) const
314 {
315  if (t_in >= T || t_in < -1)
316  {
317  ThrowPretty("Requested t=" << t_in << " out of range, needs to be 0 =< t < " << T);
318  }
319  else if (t_in == -1)
320  {
321  t_in = (T - 1);
322  }
323 }
324 
325 void TimeIndexedTask::SetGoal(const std::string& task_name, Eigen::VectorXdRefConst goal, int t)
326 {
327  ValidateTimeIndex(t);
328  for (size_t i = 0; i < indexing.size(); ++i)
329  {
330  if (tasks[i]->GetObjectName() == task_name)
331  {
332  if (goal.rows() != indexing[i].length) ThrowPretty("Expected length of " << indexing[i].length << " and got " << goal.rows());
333  y[t].data.segment(indexing[i].start, indexing[i].length) = goal;
334  return;
335  }
336  }
337  ThrowPretty("Cannot set Goal. Task map '" << task_name << "' does not exist.");
338 }
339 
340 Eigen::VectorXd TimeIndexedTask::GetGoal(const std::string& task_name, int t) const
341 {
342  ValidateTimeIndex(t);
343  for (size_t i = 0; i < indexing.size(); ++i)
344  {
345  if (tasks[i]->GetObjectName() == task_name)
346  {
347  return y[t].data.segment(indexing[i].start, indexing[i].length);
348  }
349  }
350  ThrowPretty("Cannot get Goal. Task map '" << task_name << "' does not exist.");
351 }
352 
353 void TimeIndexedTask::SetRho(const std::string& task_name, const double rho_in, int t)
354 {
355  ValidateTimeIndex(t);
356  for (size_t i = 0; i < indexing.size(); ++i)
357  {
358  if (tasks[i]->GetObjectName() == task_name)
359  {
360  rho[t](indexing[i].id) = rho_in;
361  UpdateS();
362  return;
363  }
364  }
365  ThrowPretty("Cannot set rho. Task map '" << task_name << "' does not exist.");
366 }
367 
368 double TimeIndexedTask::GetRho(const std::string& task_name, int t) const
369 {
370  ValidateTimeIndex(t);
371  for (size_t i = 0; i < indexing.size(); ++i)
372  {
373  if (tasks[i]->GetObjectName() == task_name)
374  {
375  return rho[t](indexing[i].id);
376  }
377  }
378  ThrowPretty("Cannot get rho. Task map '" << task_name << "' does not exist.");
379 }
380 
381 Eigen::VectorXd TimeIndexedTask::GetTaskError(const std::string& task_name, int t) const
382 {
383  ValidateTimeIndex(t);
384  for (size_t i = 0; i < indexing.size(); ++i)
385  {
386  if (tasks[i]->GetObjectName() == task_name)
387  {
388  return ydiff[t].segment(indexing[i].start_jacobian, indexing[i].length_jacobian);
389  }
390  }
391  ThrowPretty("Cannot get ydiff. Task map '" << task_name << "' does not exist.");
392 }
393 
394 Eigen::MatrixXd TimeIndexedTask::GetS(const std::string& task_name, int t) const
395 {
396  ValidateTimeIndex(t);
397  for (size_t i = 0; i < indexing.size(); ++i)
398  {
399  if (tasks[i]->GetObjectName() == task_name)
400  {
401  // We are interested in the square matrix of dimension length_jacobian
402  return S[t].block(indexing[i].start_jacobian, indexing[i].start_jacobian, indexing[i].length_jacobian, indexing[i].length_jacobian);
403  }
404  }
405  ThrowPretty("Cannot get S. Task map '" << task_name << "' does not exist.");
406 }
407 
409 {
410  T = _T;
411  Phi.assign(_T, _Phi);
412  y = Phi;
413  rho.assign(T, Eigen::VectorXd::Ones(num_tasks));
414 
415  if (_prob->GetFlags() & KIN_J)
416  {
417  jacobian.assign(T, Eigen::MatrixXd(length_jacobian, _prob->N));
418  dPhi_dx.assign(T, Eigen::MatrixXd(length_jacobian, _prob->GetScene()->get_num_state_derivative()));
419  dPhi_du.assign(T, Eigen::MatrixXd(length_jacobian, _prob->GetScene()->get_num_controls()));
420  }
421  if (_prob->GetFlags() & KIN_H)
422  {
423  hessian.assign(T, Hessian::Constant(length_jacobian, Eigen::MatrixXd::Zero(_prob->N, _prob->N)));
424  ddPhi_ddx.assign(T, Hessian::Constant(length_jacobian, Eigen::MatrixXd::Zero(_prob->GetScene()->get_num_state_derivative(), _prob->GetScene()->get_num_state_derivative())));
425  ddPhi_ddu.assign(T, Hessian::Constant(length_jacobian, Eigen::MatrixXd::Zero(_prob->GetScene()->get_num_controls(), _prob->GetScene()->get_num_controls())));
426  ddPhi_dxdu.assign(T, Hessian::Constant(length_jacobian, Eigen::MatrixXd::Zero(_prob->GetScene()->get_num_state_derivative(), _prob->GetScene()->get_num_controls())));
427  }
428  S.assign(T, Eigen::MatrixXd::Identity(length_jacobian, length_jacobian));
429  ydiff.assign(T, Eigen::VectorXd::Zero(length_jacobian));
430 
431  if (num_tasks != task_initializers_.size()) ThrowPretty("Number of tasks does not match internal number of tasks!");
432  for (int i = 0; i < num_tasks; ++i)
433  {
434  TaskInitializer& task = task_initializers_[i];
435  if (task.Goal.rows() == 0)
436  {
437  // Keep zero goal
438  }
439  else if (task.Goal.rows() == tasks[i]->length * T)
440  {
441  for (int t = 0; t < T; ++t)
442  {
443  y[t].data.segment(indexing[i].start, indexing[i].length) = task.Goal.segment(t * tasks[i]->length, tasks[i]->length);
444  }
445  }
446  else if (task.Goal.rows() == tasks[i]->length)
447  {
448  for (int t = 0; t < T; ++t)
449  {
450  y[t].data.segment(indexing[i].start, indexing[i].length) = task.Goal;
451  }
452  }
453  else
454  {
455  ThrowPretty("Invalid task goal size! Expecting " << tasks[i]->length * T << ", " << tasks[i]->length << ", or 1 and got " << task.Goal.rows());
456  }
457  if (task.Rho.rows() == 0)
458  {
459  // Keep ones
460  }
461  else if (task.Rho.rows() == T)
462  {
463  for (int t = 0; t < T; ++t)
464  {
465  rho[t](i) = task.Rho(t);
466  }
467  }
468  else if (task.Rho.rows() == 1)
469  {
470  for (int t = 0; t < T; ++t)
471  {
472  rho[t](i) = task.Rho(0);
473  }
474  }
475  else
476  {
477  ThrowPretty("Invalid task rho size! Expecting " << T << " (or 1) and got " << task.Rho.rows());
478  }
479  }
480 }
481 
482 void SamplingTask::Initialize(const std::vector<exotica::Initializer>& inits, PlanningProblemPtr prob, TaskSpaceVector& unused)
483 {
484  Task::Initialize(inits, prob, Phi);
485  y = Phi;
486  y.SetZero(length_Phi);
487  rho = Eigen::VectorXd::Ones(num_tasks);
488  S = Eigen::MatrixXd::Identity(length_jacobian, length_jacobian);
489  ydiff = Eigen::VectorXd::Zero(length_jacobian);
490 
491  for (int i = 0; i < num_tasks; ++i)
492  {
493  TaskInitializer task(inits[i]);
494  if (task.Goal.rows() == 0)
495  {
496  // Keep zero goal
497  }
498  else if (task.Goal.rows() == tasks[i]->length)
499  {
500  y.data.segment(indexing[i].start, indexing[i].length) = task.Goal;
501  }
502  else
503  {
504  ThrowPretty("Invalid task goal size! Expecting " << tasks[i]->length << " got " << task.Goal.rows());
505  }
506  if (task.Rho.rows() == 0)
507  {
508  rho(i) = 1.0;
509  }
510  else if (task.Rho.rows() == 1)
511  {
512  rho(i) = task.Rho(0);
513  }
514  else
515  {
516  ThrowPretty("Invalid task rho size! Expecting 1 got " << task.Rho.rows());
517  }
518  }
519 }
520 
522 {
523  for (const TaskIndexing& task : indexing)
524  {
525  for (int i = 0; i < task.length_jacobian; ++i)
526  {
527  S(i + task.start_jacobian, i + task.start_jacobian) = rho(task.id);
528  }
529  if (rho(task.id) != 0.0) tasks[task.id]->is_used = true;
530  }
531 }
532 
534 {
535  for (const TaskIndexing& task : indexing)
536  {
537  Phi.data.segment(task.start, task.length) = big_Phi.data.segment(tasks[task.id]->start, tasks[task.id]->length);
538  }
539  ydiff = Phi - y;
540 
541  for (unsigned int i = 0; i < ydiff.size(); ++i)
542  if (std::abs(ydiff[i]) < tolerance) ydiff[i] = 0.0;
543 }
544 
545 void SamplingTask::SetGoal(const std::string& task_name, Eigen::VectorXdRefConst goal)
546 {
547  for (size_t i = 0; i < indexing.size(); ++i)
548  {
549  if (tasks[i]->GetObjectName() == task_name)
550  {
551  if (goal.rows() != indexing[i].length) ThrowPretty("Expected length of " << indexing[i].length << " and got " << goal.rows());
552  y.data.segment(indexing[i].start, indexing[i].length) = goal;
553  return;
554  }
555  }
556  ThrowPretty("Cannot set Goal. Task Map '" << task_name << "' does not exist.");
557 }
558 
559 void SamplingTask::SetRho(const std::string& task_name, const double rho_in)
560 {
561  for (size_t i = 0; i < indexing.size(); ++i)
562  {
563  if (tasks[i]->GetObjectName() == task_name)
564  {
565  rho(indexing[i].id) = rho_in;
566  UpdateS();
567  return;
568  }
569  }
570  ThrowPretty("Cannot set rho. Task Map '" << task_name << "' does not exist.");
571 }
572 
573 Eigen::VectorXd SamplingTask::GetGoal(const std::string& task_name) const
574 {
575  for (size_t i = 0; i < indexing.size(); ++i)
576  {
577  if (tasks[i]->GetObjectName() == task_name)
578  {
579  return y.data.segment(indexing[i].start, indexing[i].length);
580  }
581  }
582  ThrowPretty("Cannot get Goal. Task Map '" << task_name << "' does not exist.");
583 }
584 
585 double SamplingTask::GetRho(const std::string& task_name) const
586 {
587  for (size_t i = 0; i < indexing.size(); ++i)
588  {
589  if (tasks[i]->GetObjectName() == task_name)
590  {
591  return rho(indexing[i].id);
592  }
593  }
594  ThrowPretty("Cannot get rho. Task Map '" << task_name << "' does not exist.");
595 }
596 } // namespace exotica
std::vector< TaskVectorEntry > map
Eigen::VectorXd GetTaskError(const std::string &task_name, int t) const
Definition: tasks.cpp:381
double GetRho(const std::string &task_name, int t) const
Definition: tasks.cpp:368
Eigen::VectorXd GetGoal(const std::string &task_name, int t) const
Definition: tasks.cpp:340
Eigen::VectorXd GetGoal(const std::string &task_name) const
Definition: tasks.cpp:179
int length_jacobian
Definition: tasks.h:67
void ValidateTimeIndex(int &t_in) const
Definition: tasks.cpp:313
#define ThrowPretty(m)
Definition: exception.h:36
double GetRho(const std::string &task_name) const
Definition: tasks.cpp:585
Eigen::VectorXd GetTaskError(const std::string &task_name) const
Definition: tasks.cpp:216
virtual void Initialize(const std::vector< exotica::Initializer > &inits, std::shared_ptr< PlanningProblem > prob, TaskSpaceVector &Phi)
Definition: tasks.cpp:68
int num_tasks
Definition: tasks.h:68
void SetRho(const std::string &task_name, const double rho_in, int t)
Definition: tasks.cpp:353
virtual void Initialize(const std::vector< exotica::Initializer > &inits, std::shared_ptr< PlanningProblem > prob, TaskSpaceVector &Phi)
Definition: tasks.cpp:228
void Update(const TaskSpaceVector &big_Phi, Eigen::MatrixXdRefConst big_dPhi_dx, Eigen::MatrixXdRefConst big_dPhi_du, HessianRefConst big_ddPhi_ddx, HessianRefConst big_ddPhi_ddu, HessianRefConst big_ddPhi_dxdu, int t)
Definition: tasks.cpp:249
const Eigen::Ref< const Eigen::MatrixXd > & MatrixXdRefConst
Definition: conversions.h:53
Eigen::internal::ref_selector< Hessian >::type HessianRefConst
Definition: conversions.h:166
void SetRho(const std::string &task_name, const double rho)
Definition: tasks.cpp:559
TaskMapMap task_maps
Definition: tasks.h:62
std::vector< TaskInitializer > task_initializers_
Definition: tasks.h:72
static std::vector< TaskVectorEntry > reindex(const std::vector< TaskVectorEntry > &_map, int _old_start, int _new_start)
int length_Phi
Definition: tasks.h:66
virtual void Initialize(const std::vector< exotica::Initializer > &inits, std::shared_ptr< PlanningProblem > prob, TaskSpaceVector &Phi)
Definition: tasks.cpp:482
const Eigen::Ref< const Eigen::VectorXd > & VectorXdRefConst
Convenience wrapper for storing references to sub-matrices/vectors.
Definition: conversions.h:52
void SetGoal(const std::string &task_name, Eigen::VectorXdRefConst goal, int t)
Definition: tasks.cpp:325
double tolerance
Definition: tasks.h:69
Eigen::VectorXd GetGoal(const std::string &task_name) const
Definition: tasks.cpp:573
double GetRho(const std::string &task_name) const
Definition: tasks.cpp:191
void ReinitializeVariables(int _T, std::shared_ptr< PlanningProblem > _prob, const TaskSpaceVector &_Phi)
Definition: tasks.cpp:408
Eigen::MatrixXd GetS(const std::string &task_name) const
Definition: tasks.cpp:203
Eigen::MatrixXd GetS(const std::string &task_name, int t) const
Definition: tasks.cpp:394
std::vector< TaskIndexing > indexing
Definition: tasks.h:64
std::shared_ptr< PlanningProblem > PlanningProblemPtr
void Update(const TaskSpaceVector &big_Phi, Eigen::MatrixXdRefConst big_jacobian, HessianRefConst big_hessian)
Definition: tasks.cpp:121
void AppendVector(std::vector< Val > &orig, const std::vector< Val > &extra)
Definition: conversions.h:223
virtual void Initialize(const std::vector< exotica::Initializer > &inits, std::shared_ptr< PlanningProblem > prob, TaskSpaceVector &Phi)
Definition: tasks.cpp:37
void SetGoal(const std::string &task_name, Eigen::VectorXdRefConst goal)
Definition: tasks.cpp:545
TaskMapVec tasks
Definition: tasks.h:63
void SetGoal(const std::string &task_name, Eigen::VectorXdRefConst goal)
Definition: tasks.cpp:151
void Update(const TaskSpaceVector &big_Phi)
Definition: tasks.cpp:533
const T & y
void SetRho(const std::string &task_name, const double rho_in)
Definition: tasks.cpp:165


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