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;
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 Eigen::MatrixXd EndPoseTask::GetTaskJacobian(const std::string& task_name) const
229 {
230  for (size_t i = 0; i < indexing.size(); ++i)
231  {
232  if (tasks[i]->GetObjectName() == task_name)
233  {
234  return jacobian.middleRows(indexing[i].start_jacobian, indexing[i].length_jacobian);
235  }
236  }
237  ThrowPretty("Cannot get task Jacobian. Task map '" << task_name << "' does not exist.");
238 }
239 
240 void TimeIndexedTask::Initialize(const std::vector<exotica::Initializer>& inits, PlanningProblemPtr prob, TaskSpaceVector& Phi)
241 {
242  Task::Initialize(inits, prob, Phi);
243  Phi.SetZero(length_Phi);
244 }
245 
247 {
248  for (int t = 0; t < T; ++t)
249  {
250  for (const TaskIndexing& task : indexing)
251  {
252  for (int i = 0; i < task.length_jacobian; ++i)
253  {
254  S[t](i + task.start_jacobian, i + task.start_jacobian) = rho[t](task.id);
255  }
256  if (rho[t](task.id) != 0.0) tasks[task.id]->is_used = true;
257  }
258  }
259 }
260 
262  Eigen::MatrixXdRefConst big_dPhi_dx,
263  Eigen::MatrixXdRefConst big_dPhi_du,
264  HessianRefConst big_ddPhi_ddx,
265  HessianRefConst big_ddPhi_ddu,
266  HessianRefConst big_ddPhi_dxdu,
267  int t)
268 {
269  for (const TaskIndexing& task : indexing)
270  {
271  Phi[t].data.segment(task.start, task.length) = big_Phi.data.segment(tasks[task.id]->start, tasks[task.id]->length);
272  dPhi_dx[t].middleRows(task.start_jacobian, task.length_jacobian) = big_dPhi_dx.middleRows(tasks[task.id]->start_jacobian, tasks[task.id]->length_jacobian);
273  dPhi_du[t].middleRows(task.start_jacobian, task.length_jacobian) = big_dPhi_du.middleRows(tasks[task.id]->start_jacobian, tasks[task.id]->length_jacobian);
274  ddPhi_ddx[t].segment(task.start_jacobian, task.length_jacobian) = big_ddPhi_ddx.segment(tasks[task.id]->start_jacobian, tasks[task.id]->length_jacobian);
275  ddPhi_ddu[t].segment(task.start_jacobian, task.length_jacobian) = big_ddPhi_ddu.segment(tasks[task.id]->start_jacobian, tasks[task.id]->length_jacobian);
276  ddPhi_dxdu[t].segment(task.start_jacobian, task.length_jacobian) = big_ddPhi_dxdu.segment(tasks[task.id]->start_jacobian, tasks[task.id]->length_jacobian);
277  }
278  ydiff[t] = Phi[t] - y[t];
279 }
280 
282  Eigen::MatrixXdRefConst big_dPhi_dx,
283  Eigen::MatrixXdRefConst big_dPhi_du,
284  int t)
285 {
286  for (const TaskIndexing& task : indexing)
287  {
288  Phi[t].data.segment(task.start, task.length) = big_Phi.data.segment(tasks[task.id]->start, tasks[task.id]->length);
289  dPhi_dx[t].middleRows(task.start_jacobian, task.length_jacobian) = big_dPhi_dx.middleRows(tasks[task.id]->start_jacobian, tasks[task.id]->length_jacobian);
290  dPhi_du[t].middleRows(task.start_jacobian, task.length_jacobian) = big_dPhi_du.middleRows(tasks[task.id]->start_jacobian, tasks[task.id]->length_jacobian);
291  }
292  ydiff[t] = Phi[t] - y[t];
293 }
294 
295 void TimeIndexedTask::Update(const TaskSpaceVector& big_Phi, Eigen::MatrixXdRefConst big_jacobian, HessianRefConst big_hessian, int t)
296 {
297  for (const TaskIndexing& task : indexing)
298  {
299  Phi[t].data.segment(task.start, task.length) = big_Phi.data.segment(tasks[task.id]->start, tasks[task.id]->length);
300  jacobian[t].middleRows(task.start_jacobian, task.length_jacobian) = big_jacobian.middleRows(tasks[task.id]->start_jacobian, tasks[task.id]->length_jacobian);
301  hessian[t].segment(task.start_jacobian, task.length_jacobian) = big_hessian.segment(tasks[task.id]->start_jacobian, tasks[task.id]->length_jacobian);
302  }
303  ydiff[t] = Phi[t] - y[t];
304 }
305 
306 void TimeIndexedTask::Update(const TaskSpaceVector& big_Phi, Eigen::MatrixXdRefConst big_jacobian, int t)
307 {
308  for (const TaskIndexing& task : indexing)
309  {
310  Phi[t].data.segment(task.start, task.length) = big_Phi.data.segment(tasks[task.id]->start, tasks[task.id]->length);
311  jacobian[t].middleRows(task.start_jacobian, task.length_jacobian) = big_jacobian.middleRows(tasks[task.id]->start_jacobian, tasks[task.id]->length_jacobian);
312  }
313  ydiff[t] = Phi[t] - y[t];
314 }
315 
316 void TimeIndexedTask::Update(const TaskSpaceVector& big_Phi, int t)
317 {
318  for (const TaskIndexing& task : indexing)
319  {
320  Phi[t].data.segment(task.start, task.length) = big_Phi.data.segment(tasks[task.id]->start, tasks[task.id]->length);
321  }
322  ydiff[t] = Phi[t] - y[t];
323 }
324 
325 inline void TimeIndexedTask::ValidateTimeIndex(int& t_in) const
326 {
327  if (t_in >= T || t_in < -1)
328  {
329  ThrowPretty("Requested t=" << t_in << " out of range, needs to be 0 =< t < " << T);
330  }
331  else if (t_in == -1)
332  {
333  t_in = (T - 1);
334  }
335 }
336 
337 void TimeIndexedTask::SetGoal(const std::string& task_name, Eigen::VectorXdRefConst goal, int t)
338 {
340  for (size_t i = 0; i < indexing.size(); ++i)
341  {
342  if (tasks[i]->GetObjectName() == task_name)
343  {
344  if (goal.rows() != indexing[i].length) ThrowPretty("Expected length of " << indexing[i].length << " and got " << goal.rows());
345  y[t].data.segment(indexing[i].start, indexing[i].length) = goal;
346  return;
347  }
348  }
349  ThrowPretty("Cannot set Goal. Task map '" << task_name << "' does not exist.");
350 }
351 
352 Eigen::VectorXd TimeIndexedTask::GetGoal(const std::string& task_name, int t) const
353 {
355  for (size_t i = 0; i < indexing.size(); ++i)
356  {
357  if (tasks[i]->GetObjectName() == task_name)
358  {
359  return y[t].data.segment(indexing[i].start, indexing[i].length);
360  }
361  }
362  ThrowPretty("Cannot get Goal. Task map '" << task_name << "' does not exist.");
363 }
364 
365 void TimeIndexedTask::SetRho(const std::string& task_name, const double rho_in, int t)
366 {
368  for (size_t i = 0; i < indexing.size(); ++i)
369  {
370  if (tasks[i]->GetObjectName() == task_name)
371  {
372  rho[t](indexing[i].id) = rho_in;
373  UpdateS();
374  return;
375  }
376  }
377  ThrowPretty("Cannot set rho. Task map '" << task_name << "' does not exist.");
378 }
379 
380 double TimeIndexedTask::GetRho(const std::string& task_name, int t) const
381 {
383  for (size_t i = 0; i < indexing.size(); ++i)
384  {
385  if (tasks[i]->GetObjectName() == task_name)
386  {
387  return rho[t](indexing[i].id);
388  }
389  }
390  ThrowPretty("Cannot get rho. Task map '" << task_name << "' does not exist.");
391 }
392 
393 Eigen::VectorXd TimeIndexedTask::GetTaskError(const std::string& task_name, int t) const
394 {
396  for (size_t i = 0; i < indexing.size(); ++i)
397  {
398  if (tasks[i]->GetObjectName() == task_name)
399  {
400  return ydiff[t].segment(indexing[i].start_jacobian, indexing[i].length_jacobian);
401  }
402  }
403  ThrowPretty("Cannot get ydiff. Task map '" << task_name << "' does not exist.");
404 }
405 
406 Eigen::MatrixXd TimeIndexedTask::GetS(const std::string& task_name, int t) const
407 {
409  for (size_t i = 0; i < indexing.size(); ++i)
410  {
411  if (tasks[i]->GetObjectName() == task_name)
412  {
413  // We are interested in the square matrix of dimension length_jacobian
414  return S[t].block(indexing[i].start_jacobian, indexing[i].start_jacobian, indexing[i].length_jacobian, indexing[i].length_jacobian);
415  }
416  }
417  ThrowPretty("Cannot get S. Task map '" << task_name << "' does not exist.");
418 }
419 
421 {
422  T = _T;
423  Phi.assign(_T, _Phi);
424  y = Phi;
425  rho.assign(T, Eigen::VectorXd::Ones(num_tasks));
426 
427  if (_prob->GetFlags() & KIN_J)
428  {
429  jacobian.assign(T, Eigen::MatrixXd(length_jacobian, _prob->N));
430  dPhi_dx.assign(T, Eigen::MatrixXd(length_jacobian, _prob->GetScene()->get_num_state_derivative()));
431  dPhi_du.assign(T, Eigen::MatrixXd(length_jacobian, _prob->GetScene()->get_num_controls()));
432  }
433  if (_prob->GetFlags() & KIN_H)
434  {
435  hessian.assign(T, Hessian::Constant(length_jacobian, Eigen::MatrixXd::Zero(_prob->N, _prob->N)));
436  ddPhi_ddx.assign(T, Hessian::Constant(length_jacobian, Eigen::MatrixXd::Zero(_prob->GetScene()->get_num_state_derivative(), _prob->GetScene()->get_num_state_derivative())));
437  ddPhi_ddu.assign(T, Hessian::Constant(length_jacobian, Eigen::MatrixXd::Zero(_prob->GetScene()->get_num_controls(), _prob->GetScene()->get_num_controls())));
438  ddPhi_dxdu.assign(T, Hessian::Constant(length_jacobian, Eigen::MatrixXd::Zero(_prob->GetScene()->get_num_state_derivative(), _prob->GetScene()->get_num_controls())));
439  }
440  S.assign(T, Eigen::MatrixXd::Identity(length_jacobian, length_jacobian));
441  ydiff.assign(T, Eigen::VectorXd::Zero(length_jacobian));
442 
443  if (num_tasks != task_initializers_.size()) ThrowPretty("Number of tasks does not match internal number of tasks!");
444  for (int i = 0; i < num_tasks; ++i)
445  {
446  TaskInitializer& task = task_initializers_[i];
447  if (task.Goal.rows() == 0)
448  {
449  // Keep zero goal
450  }
451  else if (task.Goal.rows() == tasks[i]->length * T)
452  {
453  for (int t = 0; t < T; ++t)
454  {
455  y[t].data.segment(indexing[i].start, indexing[i].length) = task.Goal.segment(t * tasks[i]->length, tasks[i]->length);
456  }
457  }
458  else if (task.Goal.rows() == tasks[i]->length)
459  {
460  for (int t = 0; t < T; ++t)
461  {
462  y[t].data.segment(indexing[i].start, indexing[i].length) = task.Goal;
463  }
464  }
465  else
466  {
467  ThrowPretty("Invalid task goal size! Expecting " << tasks[i]->length * T << ", " << tasks[i]->length << ", or 1 and got " << task.Goal.rows());
468  }
469  if (task.Rho.rows() == 0)
470  {
471  // Keep ones
472  }
473  else if (task.Rho.rows() == T)
474  {
475  for (int t = 0; t < T; ++t)
476  {
477  rho[t](i) = task.Rho(t);
478  }
479  }
480  else if (task.Rho.rows() == 1)
481  {
482  for (int t = 0; t < T; ++t)
483  {
484  rho[t](i) = task.Rho(0);
485  }
486  }
487  else
488  {
489  ThrowPretty("Invalid task rho size! Expecting " << T << " (or 1) and got " << task.Rho.rows());
490  }
491  }
492 }
493 
494 void SamplingTask::Initialize(const std::vector<exotica::Initializer>& inits, PlanningProblemPtr prob, TaskSpaceVector& unused)
495 {
496  Task::Initialize(inits, prob, Phi);
497  y = Phi;
499  rho = Eigen::VectorXd::Ones(num_tasks);
500  S = Eigen::MatrixXd::Identity(length_jacobian, length_jacobian);
501  ydiff = Eigen::VectorXd::Zero(length_jacobian);
502 
503  for (int i = 0; i < num_tasks; ++i)
504  {
505  TaskInitializer task(inits[i]);
506  if (task.Goal.rows() == 0)
507  {
508  // Keep zero goal
509  }
510  else if (task.Goal.rows() == tasks[i]->length)
511  {
512  y.data.segment(indexing[i].start, indexing[i].length) = task.Goal;
513  }
514  else
515  {
516  ThrowPretty("Invalid task goal size! Expecting " << tasks[i]->length << " got " << task.Goal.rows());
517  }
518  if (task.Rho.rows() == 0)
519  {
520  rho(i) = 1.0;
521  }
522  else if (task.Rho.rows() == 1)
523  {
524  rho(i) = task.Rho(0);
525  }
526  else
527  {
528  ThrowPretty("Invalid task rho size! Expecting 1 got " << task.Rho.rows());
529  }
530  }
531 }
532 
534 {
535  for (const TaskIndexing& task : indexing)
536  {
537  for (int i = 0; i < task.length_jacobian; ++i)
538  {
539  S(i + task.start_jacobian, i + task.start_jacobian) = rho(task.id);
540  }
541  if (rho(task.id) != 0.0) tasks[task.id]->is_used = true;
542  }
543 }
544 
546 {
547  for (const TaskIndexing& task : indexing)
548  {
549  Phi.data.segment(task.start, task.length) = big_Phi.data.segment(tasks[task.id]->start, tasks[task.id]->length);
550  }
551  ydiff = Phi - y;
552 
553  for (unsigned int i = 0; i < ydiff.size(); ++i)
554  if (std::abs(ydiff[i]) < tolerance) ydiff[i] = 0.0;
555 }
556 
557 void SamplingTask::SetGoal(const std::string& task_name, Eigen::VectorXdRefConst goal)
558 {
559  for (size_t i = 0; i < indexing.size(); ++i)
560  {
561  if (tasks[i]->GetObjectName() == task_name)
562  {
563  if (goal.rows() != indexing[i].length) ThrowPretty("Expected length of " << indexing[i].length << " and got " << goal.rows());
564  y.data.segment(indexing[i].start, indexing[i].length) = goal;
565  return;
566  }
567  }
568  ThrowPretty("Cannot set Goal. Task Map '" << task_name << "' does not exist.");
569 }
570 
571 void SamplingTask::SetRho(const std::string& task_name, const double rho_in)
572 {
573  for (size_t i = 0; i < indexing.size(); ++i)
574  {
575  if (tasks[i]->GetObjectName() == task_name)
576  {
577  rho(indexing[i].id) = rho_in;
578  UpdateS();
579  return;
580  }
581  }
582  ThrowPretty("Cannot set rho. Task Map '" << task_name << "' does not exist.");
583 }
584 
585 Eigen::VectorXd SamplingTask::GetGoal(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 y.data.segment(indexing[i].start, indexing[i].length);
592  }
593  }
594  ThrowPretty("Cannot get Goal. Task Map '" << task_name << "' does not exist.");
595 }
596 
597 double SamplingTask::GetRho(const std::string& task_name) const
598 {
599  for (size_t i = 0; i < indexing.size(); ++i)
600  {
601  if (tasks[i]->GetObjectName() == task_name)
602  {
603  return rho(indexing[i].id);
604  }
605  }
606  ThrowPretty("Cannot get rho. Task Map '" << task_name << "' does not exist.");
607 }
608 } // namespace exotica
exotica::KIN_H
@ KIN_H
Definition: kinematic_tree.h:61
exotica::TimeIndexedTask::ReinitializeVariables
void ReinitializeVariables(int _T, std::shared_ptr< PlanningProblem > _prob, const TaskSpaceVector &_Phi)
Definition: tasks.cpp:420
exotica::TimeIndexedTask::ddPhi_ddu
std::vector< Hessian > ddPhi_ddu
Definition: tasks.h:118
exotica::EndPoseTask::Update
void Update(const TaskSpaceVector &big_Phi, Eigen::MatrixXdRefConst big_jacobian, HessianRefConst big_hessian)
Definition: tasks.cpp:121
exotica::AppendVector
void AppendVector(std::vector< Val > &orig, const std::vector< Val > &extra)
Definition: conversions.h:224
exotica::EndPoseTask::SetGoal
void SetGoal(const std::string &task_name, Eigen::VectorXdRefConst goal)
Definition: tasks.cpp:151
exotica::EndPoseTask::rho
Eigen::VectorXd rho
Definition: tasks.h:148
exotica::EndPoseTask::GetRho
double GetRho(const std::string &task_name) const
Definition: tasks.cpp:191
exotica::EndPoseTask::S
Eigen::MatrixXd S
Definition: tasks.h:154
exotica::TimeIndexedTask::hessian
std::vector< Hessian > hessian
Definition: tasks.h:116
exotica::EndPoseTask::hessian
Hessian hessian
Definition: tasks.h:153
exotica::Task::length_jacobian
int length_jacobian
Definition: tasks.h:67
exotica::SamplingTask::Initialize
virtual void Initialize(const std::vector< exotica::Initializer > &inits, std::shared_ptr< PlanningProblem > prob, TaskSpaceVector &Phi)
Definition: tasks.cpp:494
exotica::TimeIndexedTask::Phi
std::vector< TaskSpaceVector > Phi
Definition: tasks.h:115
exotica::EndPoseTask::GetGoal
Eigen::VectorXd GetGoal(const std::string &task_name) const
Definition: tasks.cpp:179
exotica::TimeIndexedTask::Update
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:261
exotica::KIN_J
@ KIN_J
Definition: kinematic_tree.h:59
exotica::EndPoseTask::jacobian
Eigen::MatrixXd jacobian
Definition: tasks.h:152
exotica::TimeIndexedTask::GetS
Eigen::MatrixXd GetS(const std::string &task_name, int t) const
Definition: tasks.cpp:406
exotica::TimeIndexedTask::GetTaskError
Eigen::VectorXd GetTaskError(const std::string &task_name, int t) const
Definition: tasks.cpp:393
exotica::EndPoseTask::GetS
Eigen::MatrixXd GetS(const std::string &task_name) const
Definition: tasks.cpp:203
exotica::EndPoseTask::UpdateS
void UpdateS()
Definition: tasks.cpp:109
exotica::SamplingTask::SetRho
void SetRho(const std::string &task_name, const double rho)
Definition: tasks.cpp:571
exotica::TimeIndexedTask::SetGoal
void SetGoal(const std::string &task_name, Eigen::VectorXdRefConst goal, int t)
Definition: tasks.cpp:337
exotica::EndPoseTask::GetTaskJacobian
Eigen::MatrixXd GetTaskJacobian(const std::string &task_name) const
Definition: tasks.cpp:228
exotica
Definition: collision_scene.h:46
exotica::TimeIndexedTask::ValidateTimeIndex
void ValidateTimeIndex(int &t_in) const
Definition: tasks.cpp:325
exotica::EndPoseTask::Phi
TaskSpaceVector Phi
Definition: tasks.h:151
exotica::TimeIndexedTask::SetRho
void SetRho(const std::string &task_name, const double rho_in, int t)
Definition: tasks.cpp:365
exotica::EndPoseTask::y
TaskSpaceVector y
Definition: tasks.h:149
exotica::SamplingTask::rho
Eigen::VectorXd rho
Definition: tasks.h:172
exotica::TimeIndexedTask::ddPhi_dxdu
std::vector< Hessian > ddPhi_dxdu
Definition: tasks.h:119
exotica::SamplingTask::Update
void Update(const TaskSpaceVector &big_Phi)
Definition: tasks.cpp:545
exotica::Task::task_initializers_
std::vector< TaskInitializer > task_initializers_
Definition: tasks.h:72
exotica::EndPoseTask::Initialize
virtual void Initialize(const std::vector< exotica::Initializer > &inits, std::shared_ptr< PlanningProblem > prob, TaskSpaceVector &Phi)
Definition: tasks.cpp:68
exotica::Task::num_tasks
int num_tasks
Definition: tasks.h:68
Eigen::VectorXdRefConst
const typedef Eigen::Ref< const Eigen::VectorXd > & VectorXdRefConst
Convenience wrapper for storing references to sub-matrices/vectors.
Definition: conversions.h:53
exotica::TimeIndexedTask::dPhi_dx
std::vector< Eigen::MatrixXd > dPhi_dx
Definition: tasks.h:121
exotica::TaskSpaceVector
Definition: task_space_vector.h:50
exotica::TimeIndexedTask::dPhi_du
std::vector< Eigen::MatrixXd > dPhi_du
Definition: tasks.h:122
exotica::SamplingTask::y
TaskSpaceVector y
Definition: tasks.h:173
exotica::EndPoseTask::GetTaskError
Eigen::VectorXd GetTaskError(const std::string &task_name) const
Definition: tasks.cpp:216
Eigen::MatrixXdRefConst
const typedef Eigen::Ref< const Eigen::MatrixXd > & MatrixXdRefConst
Definition: conversions.h:54
exotica::SamplingTask::ydiff
Eigen::VectorXd ydiff
Definition: tasks.h:174
exotica::Initializer
Definition: property.h:70
exotica::TaskSpaceVector::map
std::vector< TaskVectorEntry > map
Definition: task_space_vector.h:59
exotica::HessianRefConst
Eigen::internal::ref_selector< Hessian >::type HessianRefConst
Definition: conversions.h:167
exotica::SamplingTask::GetRho
double GetRho(const std::string &task_name) const
Definition: tasks.cpp:597
exotica::Task::length_Phi
int length_Phi
Definition: tasks.h:66
tasks.h
exotica::TimeIndexedTask::Initialize
virtual void Initialize(const std::vector< exotica::Initializer > &inits, std::shared_ptr< PlanningProblem > prob, TaskSpaceVector &Phi)
Definition: tasks.cpp:240
exotica::TimeIndexedTask::GetGoal
Eigen::VectorXd GetGoal(const std::string &task_name, int t) const
Definition: tasks.cpp:352
exotica::Task::indexing
std::vector< TaskIndexing > indexing
Definition: tasks.h:64
exotica::TimeIndexedTask::GetRho
double GetRho(const std::string &task_name, int t) const
Definition: tasks.cpp:380
exotica::Task::task_maps
TaskMapMap task_maps
Definition: tasks.h:62
start
ROSCPP_DECL void start()
exotica::SamplingTask::SetGoal
void SetGoal(const std::string &task_name, Eigen::VectorXdRefConst goal)
Definition: tasks.cpp:557
exotica::TimeIndexedTask::rho
std::vector< Eigen::VectorXd > rho
Definition: tasks.h:112
exotica::TimeIndexedTask::jacobian
std::vector< Eigen::MatrixXd > jacobian
Definition: tasks.h:120
exotica::PlanningProblemPtr
std::shared_ptr< PlanningProblem > PlanningProblemPtr
Definition: planning_problem.h:116
exotica::SamplingTask::Phi
TaskSpaceVector Phi
Definition: tasks.h:175
exotica::SamplingTask::GetGoal
Eigen::VectorXd GetGoal(const std::string &task_name) const
Definition: tasks.cpp:585
exotica::TimeIndexedTask::S
std::vector< Eigen::MatrixXd > S
Definition: tasks.h:123
exotica::TimeIndexedTask::ydiff
std::vector< Eigen::VectorXd > ydiff
Definition: tasks.h:114
exotica::TaskVectorEntry::reindex
static std::vector< TaskVectorEntry > reindex(const std::vector< TaskVectorEntry > &_map, int _old_start, int _new_start)
Definition: task_space_vector.cpp:93
ThrowPretty
#define ThrowPretty(m)
Definition: exception.h:36
length
TFSIMD_FORCE_INLINE tfScalar length(const Quaternion &q)
exotica::TimeIndexedTask::ddPhi_ddx
std::vector< Hessian > ddPhi_ddx
Definition: tasks.h:117
exotica::Task::tolerance
double tolerance
Definition: tasks.h:69
exotica::TimeIndexedTask::UpdateS
void UpdateS()
Definition: tasks.cpp:246
exotica::EndPoseTask::SetRho
void SetRho(const std::string &task_name, const double rho_in)
Definition: tasks.cpp:165
exotica::Task::tasks
TaskMapVec tasks
Definition: tasks.h:63
init
void init(const M_string &remappings)
exotica::TaskSpaceVector::data
Eigen::VectorXd data
Definition: task_space_vector.h:58
exotica::Task::Initialize
virtual void Initialize(const std::vector< exotica::Initializer > &inits, std::shared_ptr< PlanningProblem > prob, TaskSpaceVector &Phi)
Definition: tasks.cpp:37
exotica::TimeIndexedTask::y
std::vector< TaskSpaceVector > y
Definition: tasks.h:113
task_map.h
t
geometry_msgs::TransformStamped t
exotica::SamplingTask::UpdateS
void UpdateS()
Definition: tasks.cpp:533
exotica::TimeIndexedTask::T
int T
Definition: tasks.h:124
exotica::TaskIndexing
Definition: tasks.h:46
exotica::EndPoseTask::ydiff
Eigen::VectorXd ydiff
Definition: tasks.h:150
exotica::TaskSpaceVector::SetZero
void SetZero(const int n)
Definition: task_space_vector.cpp:54
exotica::SamplingTask::S
Eigen::MatrixXd S
Definition: tasks.h:176


exotica_core
Author(s): Yiming Yang, Michael Camilleri
autogenerated on Fri Aug 2 2024 08:43:02