non_uniform_shooting_grid_base.cpp
Go to the documentation of this file.
1 /*********************************************************************
2  *
3  * Software License Agreement
4  *
5  * Copyright (c) 2020,
6  * TU Dortmund - Institute of Control Theory and Systems Engineering.
7  * All rights reserved.
8  *
9  * This program is free software: you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation, either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program. If not, see <https://www.gnu.org/licenses/>.
21  *
22  * Authors: Christoph Rösmann
23  *********************************************************************/
24 
26 
28 #include <corbo-core/console.h>
29 
30 #include <algorithm>
31 #include <cmath>
32 #include <cstdlib>
33 #include <memory>
34 
35 namespace corbo {
36 
37 GridUpdateResult NonUniformShootingGridBase::update(const Eigen::VectorXd& x0, ReferenceTrajectoryInterface& xref, ReferenceTrajectoryInterface& uref,
38  NlpFunctions& nlp_fun, OptimizationEdgeSet& edges, SystemDynamicsInterface::Ptr dynamics,
39  bool new_run, const Time& t, ReferenceTrajectoryInterface* sref, const Eigen::VectorXd* prev_u,
40  double prev_u_dt, ReferenceTrajectoryInterface* xinit, ReferenceTrajectoryInterface* uinit)
41 {
42  assert(x0.size() == dynamics->getStateDimension());
43  assert(xref.getDimension() == x0.size());
44  assert(uref.getDimension() == dynamics->getInputDimension());
45 
46  GridUpdateResult result;
47 
48  if (isGridAdaptActive() && !_first_run && !isEmpty()) // TODO(roesmann): this might not be efficient in case warm start is deactivated
49  {
50  // adapt grid if implemented by subclass
51  adaptGrid(new_run, nlp_fun); // note, isModified() should return true if something was changed!, we could also use the return value...
52  }
53 
54  int n = std::max(getNRef(), _n_adapt);
55 
56  // check if we need to cache the reference trajectory values // TODO(roesmann): we could restrict this to new_run==true only as long as we do not
57  // have a grid resize...
58  std::vector<double> dts;
59  if (!xref.isStatic() || !uref.isStatic() || (sref && !sref->isStatic()) || (xinit && !xinit->isStatic()) || (uinit && !uinit->isStatic()))
60  {
61  if (!_intervals.empty() && _n_adapt == 0) // TODO(roesmann): check if we add a more robust check
62  getDts(dts);
63  else
64  dts.resize(n, _dt_ref);
65  if (!xref.isStatic() && !xref.isCached(dts, t))
66  xref.precompute(dts, t); // TODO(roesmann): if we have grid adaptation, we might need to chache up to n_max....
67  if (!uref.isStatic() && !uref.isCached(dts, t)) uref.precompute(dts, t);
68 
69  if (sref && !sref->isStatic() && !sref->isCached(dts, t)) sref->precompute(dts, t);
70  if (xinit && !xinit->isStatic() && !xinit->isCached(dts, t)) xinit->precompute(dts, t);
71  if (uinit && !uinit->isStatic() && !uinit->isCached(dts, t)) uinit->precompute(dts, t);
72  }
73 
74  // set previous control which might be utilized by some edges
75  if (prev_u && prev_u->size() > 0)
76  setPreviousControl(*prev_u, prev_u_dt);
77  else
78  setPreviousControl(Eigen::VectorXd::Zero(dynamics->getInputDimension()), prev_u_dt);
79 
80  // TODO(roesmann) we do not check if bounds in nlp_fun are updated
81  // updateBounds(); // calling this everytime is not efficient
82 
83  // initialize trajectories if empty or if the goal differs from the last one
84  // reinit if goal is far away
85  if (isEmpty() ||
86  !_warm_start) // TODO(roesmann): threshold?: if (_cached_xf.rows() > 0 && (xf - _cached_xf).norm() > _warm_start_goal_dist_reinit)
87  {
88  if (_num_u_per_interv_ref <= 1)
89  _full_discretization = true;
90  else
91  _full_discretization = false;
92 
93  if (xref.isStatic() && !xinit)
94  {
95  initializeSequences(x0, xref.getReferenceCached(n - 1), uinit ? *uinit : uref, nlp_fun);
96  }
97  else
98  {
99  initializeSequences(x0, xref.getReferenceCached(n - 1), xinit ? *xinit : xref, uinit ? *uinit : uref, nlp_fun);
100  }
101  }
102  else
103  {
104  if (new_run && isMovingHorizonWarmStartActive())
105  {
106  // warm_start
107  warmStartShifting(x0);
108  }
109  if (new_run)
110  {
111  // make sure to always overwrite the start with the actual (measured) values
112  _intervals.front().s.values() = x0;
113  // update fixed goal states
114  for (int i = 0; i < _xf_fixed.size(); ++i)
115  {
116  if (_xf_fixed[i]) _xf.values()[i] = xref.getReferenceCached(getN() - 1)[i];
117  }
118  }
119  }
120 
121  result.vertices_updated = isModified(); // isModified() returns if the underlying vertex set is updated
122 
123  if (new_run || result.updated()) // new run -> new t
124  {
125  // update NLP functions w.r.t. the current discretization
126  result.edges_updated =
127  nlp_fun.update(getN(), t.toSec(), xref, uref, sref, hasSingleDt(), x0, dts, this); // returns true if edge dimensions changed
128  // TODO(roesmann): sref is not yet implemented for testing, add this later...
129  // TODO(roesmann): we do not yet check if dt was updated, this might affect nlp update
130  // TODO(roesmann): maybe, for non-uniform grids, we need a better nlp update method which gets all correct reference time stamps
131  }
132 
133  if (result.updated()) // vertices or eges updated
134  {
135  // create grid specific edges
136  // TODO(roesmann): for now, we assume that we are the only maintainer of the edge set (which might be not true generally!)
137  // so we clear the edge set whenever we want
138  createEdges(nlp_fun, edges, dynamics);
139  result.edges_updated = true; // now we definitely updated the edgeset
140  }
141 
142  _first_run = false;
143  return result;
144 }
145 
146 void NonUniformShootingGridBase::initializeSequences(const Eigen::VectorXd& x0, const Eigen::VectorXd& xf, ReferenceTrajectoryInterface& uref,
147  NlpFunctions& nlp_fun)
148 {
149  // clear(); // make sure everything is cleared
150  _intervals.clear();
151  _xf.clear();
152  _active_vertices.clear();
153 
154  // check or initalize bounds if empty
155  nlp_fun.checkAndInitializeBoundDimensions(x0.size(), uref.getDimension());
156 
157  // check x_fixed
159 
160  int n_init = _n_adapt > 0 ? _n_adapt : _n_ref;
161 
162  int num_normal_intervals;
163  int add_controls_last_interval;
164 
165  if (_num_u_per_interv_ref <= 1)
166  {
167  num_normal_intervals = n_init - 1;
168  add_controls_last_interval = 0;
169  }
170  else
171  {
172  std::div_t interv_div = std::div(n_init - 1, _num_u_per_interv_ref);
173  num_normal_intervals = interv_div.quot;
174  add_controls_last_interval = interv_div.rem;
175  }
176 
177  // we initialize the state trajectory linearly
178  Eigen::VectorXd dir = xf - x0;
179  double dist = dir.norm();
180  if (dist != 0) dir /= dist;
181  double step = dist / (n_init - 1);
182 
183  int k = 0;
184  for (int i = 0; i < num_normal_intervals; ++i)
185  {
186  // add shooting interval
187  _intervals.emplace_back();
188  _intervals.back().s.set(x0 + (double)k * step * dir, nlp_fun.x_lb, nlp_fun.x_ub);
189  // _intervals.back().u_seq.resize(controls_per_interval, VectorVertex(uref.getReferenceCached(k), nlp_fun.u_lb, nlp_fun.u_ub));
190  for (int j = 0; j < _num_u_per_interv_ref; ++j)
191  {
192  _intervals.back().u_seq.emplace_back(uref.getReferenceCached(k), nlp_fun.u_lb, nlp_fun.u_ub);
193  _intervals.back().dt_seq.emplace_back(_dt_ref, _dt_lb, _dt_ub, isDtFixedIntended());
194  }
195 
197  }
198 
199  // add last shooting interval
200  if (add_controls_last_interval > 0)
201  {
202  _intervals.emplace_back();
203  _intervals.back().s.set(x0 + (double)k * step * dir, nlp_fun.x_lb, nlp_fun.x_ub);
204  // _intervals.back().u_seq.resize(controls_last_interval, VectorVertex(uref.getReferenceCached(k), nlp_fun.u_lb, nlp_fun.u_ub));
205  for (int j = 0; j < add_controls_last_interval; ++j)
206  {
207  _intervals.back().u_seq.emplace_back(uref.getReferenceCached(k + j), nlp_fun.u_lb, nlp_fun.u_ub);
208  _intervals.back().dt_seq.emplace_back(_dt_ref, _dt_lb, _dt_ub, isDtFixedIntended());
209  }
210  }
211 
212  // add final state (even if isXfShootingNode() is false, we store xf here)
213  _xf.set(xf, nlp_fun.x_lb, nlp_fun.x_ub, _xf_fixed);
214 
215  // set first state as fixed
216  _intervals.front().s.setFixed(true);
217 
218  assert(!_intervals.empty());
219 
220  // notify graph that vertices are changed
221  setModified(true);
222 }
223 
224 void NonUniformShootingGridBase::initializeSequences(const Eigen::VectorXd& x0, const Eigen::VectorXd& xf, ReferenceTrajectoryInterface& xref,
225  ReferenceTrajectoryInterface& uref, NlpFunctions& nlp_fun)
226 {
227  // clear(); // make sure everything is cleared
228  _intervals.clear();
229  _xf.clear();
230  _active_vertices.clear();
231 
232  // TODO(roesmann): check if this is ever needed in any pracital realization:
233  // if ((x0 - xref.getReferenceCached(0)).norm() > _non_static_ref_dist_threshold)
234  // {
235  // initializeSequences(x0, xref.getReferenceCached(getN() - 1), uref, nlp_fun);
236  // }
237 
238  // check or initalize bounds if empty
239  nlp_fun.checkAndInitializeBoundDimensions(x0.size(), uref.getDimension());
240 
241  // check x_fixed
243 
244  int n_init = _n_adapt > 0 ? _n_adapt : _n_ref;
245 
246  int num_normal_intervals;
247  int add_controls_last_interval;
248 
249  if (_num_u_per_interv_ref <= 1)
250  {
251  num_normal_intervals = n_init - 1;
252  add_controls_last_interval = 0;
253  }
254  else
255  {
256  std::div_t interv_div = std::div(n_init - 1, _num_u_per_interv_ref);
257  num_normal_intervals = interv_div.quot;
258  add_controls_last_interval = interv_div.rem;
259  }
260 
261  int k = 0;
262  for (int i = 0; i < num_normal_intervals; ++i)
263  {
264  // add shooting interval
265  _intervals.emplace_back();
266  _intervals.back().s.set(xref.getReferenceCached(k), nlp_fun.x_lb, nlp_fun.x_ub);
267  // _intervals.back().u_seq.resize(controls_per_interval, VectorVertex(uref.getReferenceCached(k), nlp_fun.u_lb, nlp_fun.u_ub));
268  for (int j = 0; j < _num_u_per_interv_ref; ++j)
269  {
270  _intervals.back().u_seq.emplace_back(uref.getReferenceCached(k + j), nlp_fun.u_lb, nlp_fun.u_ub);
271  _intervals.back().dt_seq.emplace_back(_dt_ref, _dt_lb, _dt_ub, isDtFixedIntended());
272  }
273 
275  }
276 
277  // add last shooting interval
278  if (add_controls_last_interval > 0)
279  {
280  _intervals.emplace_back();
281  _intervals.back().s.set(xref.getReferenceCached(k), nlp_fun.x_lb, nlp_fun.x_ub);
282  // _intervals.back().u_seq.resize(controls_last_interval, VectorVertex(uref.getReferenceCached(k), nlp_fun.u_lb, nlp_fun.u_ub));
283  for (int j = 0; j < add_controls_last_interval; ++j)
284  {
285  _intervals.back().u_seq.emplace_back(uref.getReferenceCached(k + j), nlp_fun.u_lb, nlp_fun.u_ub);
286  _intervals.back().dt_seq.emplace_back(_dt_ref, _dt_lb, _dt_ub, isDtFixedIntended());
287  }
288  }
289 
290  // add final state (even if isXfShootingNode() is false, we store xf here)
291  _xf.set(xf, nlp_fun.x_lb, nlp_fun.x_ub, _xf_fixed);
292 
293  // set first state as fixed
294  _intervals.front().s.setFixed(true);
295 
296  assert(!_intervals.empty());
297 
298  // notify graph that vertices are changed
299  setModified(true);
300 }
301 
302 void NonUniformShootingGridBase::warmStartShifting(const Eigen::VectorXd& x0)
303 {
304  // find nearest state to x0 (ideally it is the second one in _x_seq).
305  int num_shift = findNearestShootingInterval(x0);
306  if (num_shift <= 0) return;
307 
309  {
310  if (num_shift > getN() - 2)
311  {
312  PRINT_ERROR_NAMED("Cannot shift if num_shift > N-2");
313  return;
314  }
315 
316  // the simplest strategy would be to just remove remove x_seq[0], append xf to x_seq and replace xf (num_shift=1)
317  // however, this requries to change the structure which always triggers an edge recreation and so the solver must reallocate memory.
318  // TOOD(roesmann): for time-optimal stuff, if we are sure that we resize the grid, it is then more efficent to implement the strategy above...
319 
320  // shift from end to front:
321  for (int i = 0; i < getN() - num_shift; ++i)
322  {
323  int idx = i + num_shift;
324  if (idx == getN() - 1)
325  {
326  // final state reached
327  _intervals[i].s.values() = _xf.values();
328  }
329  else
330  {
331  _intervals[i].s.values() = _intervals[idx].s.values();
332  _intervals[i].u_seq.front().values() = _intervals[idx].u_seq.front().values();
333  _intervals[i].dt_seq.front().values() = _intervals[idx].dt_seq.front().values();
334  }
335  }
336 
337  int idx = getN() - num_shift;
338  if (idx < 0)
339  {
340  PRINT_ERROR_NAMED("idx < 0...");
341  return;
342  }
343  for (int i = 0; i < num_shift; ++i, ++idx)
344  {
345  // now extrapolate
346  assert(idx > 1);
347 
348  // linearly extrapolate states
349  if (i == num_shift - 1) // consider xf
350  {
351  _xf.values() = _intervals[idx - 2].s.values() + 2.0 * (_intervals[idx - 1].s.values() - _intervals[idx - 2].s.values());
352  }
353  else
354  {
355  _intervals[idx].s.values() = _intervals[idx - 2].s.values() + 2.0 * (_intervals[idx - 1].s.values() - _intervals[idx - 2].s.values());
356  // TODO(roesmann) multiply by fraction of last dt and _dt
357  }
358  _intervals[idx - 1].u_seq.front().values() = _intervals[idx - 2].u_seq.front().values();
359  _intervals[idx - 1].dt_seq.front().values() = _intervals[idx - 2].dt_seq.front().values();
360  }
361  }
362  else
363  {
364  PRINT_WARNING_ONCE("Shifting for shooting grids with more than 1 control per interval not yet implemented.");
365  }
366 }
367 
368 int NonUniformShootingGridBase::findNearestShootingInterval(const Eigen::VectorXd& x0)
369 {
370  assert(!isEmpty());
371  assert(isValid());
372 
373  // same start as before
374  double first_dist = (x0 - _intervals.front().s.values()).norm();
375  if (std::abs(first_dist) < 1e-12) return 0;
376 
377  // find nearest state (using l2-norm) in order to prune the trajectory
378  // (remove already passed states, should be 1 if the sampling times of the planning and controller call match, but could be higher if rates
379  // differ)
380 
381  int num_interv = (int)_intervals.size();
382 
383  double dist_cache = first_dist;
384  double dist;
385  int num_keep_interv = 1; // std::max(1, _num_states_min - 1); // we need to keep at least this number of intervals in the trajectory
386  int lookahead = std::min(num_interv - num_keep_interv, 20); // max 20 samples
387 
388  int nearest_idx = 0;
389 
390  for (int i = 1; i <= lookahead; ++i)
391  {
392  dist = (x0 - _intervals[i].s.values()).norm();
393  if (dist < dist_cache)
394  {
395  dist_cache = dist;
396  nearest_idx = i;
397  }
398  else
399  break;
400  }
401 
402  return nearest_idx;
403 }
404 
406 {
407  double t = 0;
408  for (const ShootingInterval& interv : _intervals)
409  {
410  for (const ScalarVertex& dt : interv.dt_seq) t += dt.value();
411  }
412  return t;
413 }
414 
415 bool NonUniformShootingGridBase::getFirstControlInput(Eigen::VectorXd& u0)
416 {
417  if (isEmpty() || !isValid()) return false;
418 
419  u0 = _intervals.front().u_seq.front().values();
420  return true;
421 }
422 
424 {
425  if (_full_discretization) return _intervals.size() + 1;
426  int n = 1; // xf
427  for (const ShootingInterval& interv : _intervals)
428  {
429  n += interv.u_seq.size();
430  }
431  return n;
432 }
433 
435 {
436  // clear grid if we change n
437  if (n != getN()) clear();
438  if (n < 2)
439  {
440  PRINT_ERROR_NAMED("Number of states must be n>1.");
441  _n_ref = 2;
442  return;
443  }
444  _n_ref = n;
445  _n_adapt = 0;
446 }
447 
448 void NonUniformShootingGridBase::getDts(std::vector<double>& dts) const
449 {
450  dts.clear();
451  for (const ShootingInterval& interv : _intervals)
452  {
453  for (const ScalarVertex& dt : interv.dt_seq) dts.push_back(dt.value());
454  }
455 }
456 
458 {
459  if (_xf_fixed.size() == 0)
460  {
461  _xf_fixed.setConstant(dim_x, false);
462  return true;
463  }
464  else if (_xf_fixed.size() == dim_x)
465  return true;
466 
467  PRINT_ERROR_NAMED("Dimensions mismatch between xf_fixed and xf. Setting xf_fixed to false.");
468  _xf_fixed.setConstant(dim_x, false);
469  return false;
470 }
471 
473 {
474  if (isEmpty()) return;
475  for (ShootingInterval& interv : _intervals)
476  {
477  if (interv.s.getDimension() == nlp_fun.x_lb.size())
478  interv.s.setLowerBounds(nlp_fun.x_lb);
479  else
480  PRINT_ERROR_NAMED("Cannot update lower state bounds due to dimensions mismatch");
481 
482  if (interv.s.getDimension() == nlp_fun.x_ub.size())
483  interv.s.setUpperBounds(nlp_fun.u_ub);
484  else
485  PRINT_ERROR_NAMED("Cannot update upper state bounds due to dimensions mismatch");
486 
487  for (VectorVertex& vtx : interv.u_seq)
488  {
489  if (vtx.getDimension() == nlp_fun.u_lb.size())
490  vtx.setLowerBounds(nlp_fun.u_lb);
491  else
492  PRINT_ERROR_NAMED("Cannot update lower control input bounds due to dimensions mismatch");
493 
494  if (vtx.getDimension() == nlp_fun.u_ub.size())
495  vtx.setUpperBounds(nlp_fun.u_ub);
496  else
497  PRINT_ERROR_NAMED("Cannot update upper control input bounds due to dimensions mismatch");
498  }
499 
500  for (ScalarVertex& vtx : interv.dt_seq)
501  {
502  vtx.setLowerBound(_dt_lb);
503  vtx.setUpperBound(_dt_ub);
504  }
505  }
506 }
507 
509 {
510  _intervals.clear();
511  _xf.clear();
512  _active_vertices.clear();
513  _first_run = true;
514  _n_adapt = 0;
515  setModified(true);
516 }
517 
518 void NonUniformShootingGridBase::getVertices(std::vector<VertexInterface*>& vertices)
519 {
520  vertices.clear();
521  // order doesn't matter here
522  for (ShootingInterval& interv : _intervals)
523  {
524  vertices.push_back(&interv.s);
525  assert(interv.u_seq.size() == interv.dt_seq.size());
526  for (int i = 0; i < (int)interv.u_seq.size(); ++i)
527  {
528  vertices.push_back(&interv.u_seq[i]);
529  vertices.push_back(&interv.dt_seq[i]);
530  }
531  }
532  if (isXfShootingNode()) vertices.push_back(&_xf); // TODO(roesmann) check if xf_shooting_node is implemented correctly everywhere
533  vertices.push_back(&_u_prev); // always fixed...
534  vertices.push_back(&_u_ref);
535  vertices.push_back(&_u_prev_dt);
536 }
537 
539 {
541  assert(isValid());
542 
543  for (ShootingInterval& interv : _intervals)
544  {
545  if (!interv.s.isFixed()) _active_vertices.push_back(&interv.s);
546  assert(interv.u_seq.size() == interv.dt_seq.size());
547  for (int i = 0; i < (int)interv.u_seq.size(); ++i)
548  {
549  if (!interv.u_seq[i].isFixed()) _active_vertices.push_back(&interv.u_seq[i]);
550  if (!interv.dt_seq[i].isFixed()) _active_vertices.push_back(&interv.dt_seq[i]);
551  }
552  }
553  if (isXfShootingNode() && !_xf.isFixed()) _active_vertices.push_back(&_xf);
554 }
555 
557 {
558  if (x_sequence) x_sequence->clear();
559  if (u_sequence) u_sequence->clear();
560 
561  if (isEmpty()) return;
562  assert(isValid());
563 
564  PRINT_ERROR_COND_NAMED(t_max < 0, "t_max >= 0 required");
565 
566  double t = 0;
567  for (const ShootingInterval& interv : _intervals)
568  {
569  if (x_sequence) x_sequence->add(t, interv.s.values());
570  if (u_sequence)
571  {
572  assert(interv.u_seq.size() == interv.dt_seq.size());
573  for (int i = 0; i < interv.u_seq.size(); ++i)
574  {
575  u_sequence->add(t, interv.u_seq[i].values());
576  t += interv.dt_seq[i].value();
577  if (t > t_max) break;
578  }
579  }
580  else
581  {
582  t += interv.getIntervalLength();
583  if (t > t_max) break;
584  }
585  }
586  if (t <= t_max && isXfShootingNode())
587  {
588  if (x_sequence && t <= t_max) x_sequence->add(t, _xf.values());
589  // duplicate last u to have the sampe time stamps as x_sequence
590  if (u_sequence) u_sequence->add(t, _intervals.back().u_seq.back().values());
591  }
592 }
593 
594 } // namespace corbo
PRINT_WARNING_ONCE
#define PRINT_WARNING_ONCE(msg)
Print msg-stream only once.
Definition: console.h:149
corbo::DiscretizationGridInterface::_u_ref
VectorVertex _u_ref
Definition: discretization_grid_interface.h:192
corbo::VectorVertex::setUpperBounds
void setUpperBounds(const Eigen::Ref< const Eigen::VectorXd > &ub) override
Define upper bounds on the vertex values [getDimension() x 1].
Definition: vector_vertex.h:200
corbo::NonUniformShootingGridBase::_xf
PartiallyFixedVectorVertex _xf
Definition: non_uniform_shooting_grid_base.h:204
corbo::ScalarVertex::setUpperBound
void setUpperBound(double ub)
Set upper bound.
Definition: scalar_vertex.h:150
corbo::NonUniformShootingGridBase::_n_ref
int _n_ref
Definition: non_uniform_shooting_grid_base.h:208
corbo::NonUniformShootingGridBase::_dt_ref
double _dt_ref
Definition: non_uniform_shooting_grid_base.h:210
corbo::NonUniformShootingGridBase::isMovingHorizonWarmStartActive
virtual bool isMovingHorizonWarmStartActive() const
Definition: non_uniform_shooting_grid_base.h:193
PRINT_ERROR_NAMED
#define PRINT_ERROR_NAMED(msg)
Definition: console.h:260
corbo::VectorVertex::getDimension
int getDimension() const override
Return number of elements/values/components stored in this vertex.
Definition: vector_vertex.h:140
corbo::NonUniformShootingGridBase::isXfShootingNode
virtual bool isXfShootingNode() const
Definition: non_uniform_shooting_grid_base.h:199
corbo::NonUniformShootingGridBase::checkAndInitializeXfFixedFlags
bool checkAndInitializeXfFixedFlags(int dim_x)
Definition: non_uniform_shooting_grid_base.cpp:479
corbo::NonUniformShootingGridBase::update
GridUpdateResult update(const Eigen::VectorXd &x0, ReferenceTrajectoryInterface &xref, ReferenceTrajectoryInterface &uref, NlpFunctions &nlp_fun, OptimizationEdgeSet &edges, SystemDynamicsInterface::Ptr dynamics, bool new_run, const Time &t, ReferenceTrajectoryInterface *sref=nullptr, const Eigen::VectorXd *prev_u=nullptr, double prev_u_dt=0, ReferenceTrajectoryInterface *xinit=nullptr, ReferenceTrajectoryInterface *uinit=nullptr) override
Definition: non_uniform_shooting_grid_base.cpp:59
corbo::NonUniformShootingGridBase::isValid
bool isValid() const
Definition: non_uniform_shooting_grid_base.h:133
corbo::NonUniformShootingGridBase::warmStartShifting
void warmStartShifting(const Eigen::VectorXd &x0)
Definition: non_uniform_shooting_grid_base.cpp:324
corbo
Definition: communication/include/corbo-communication/utilities.h:37
corbo::NlpFunctions::x_ub
Eigen::VectorXd x_ub
Definition: nlp_functions.h:69
PRINT_ERROR_COND_NAMED
#define PRINT_ERROR_COND_NAMED(cond, msg)
Definition: console.h:262
corbo::DiscretizationGridInterface::setPreviousControl
void setPreviousControl(const Eigen::VectorXd &prev_u, double prev_u_dt)
Definition: discretization_grid_interface.h:175
corbo::NonUniformShootingGridBase::getDts
void getDts(std::vector< double > &dts) const
Definition: non_uniform_shooting_grid_base.cpp:470
corbo::NonUniformShootingGridBase::initializeSequences
void initializeSequences(const Eigen::VectorXd &x0, const Eigen::VectorXd &xf, ReferenceTrajectoryInterface &uref, NlpFunctions &nlp_fun)
Definition: non_uniform_shooting_grid_base.cpp:168
corbo::NlpFunctions
Definition: nlp_functions.h:58
corbo::NonUniformShootingGridBase::createEdges
virtual void createEdges(NlpFunctions &nlp_fun, OptimizationEdgeSet &edges, SystemDynamicsInterface::Ptr dynamics)=0
corbo::DiscretizationGridInterface::_u_prev_dt
ScalarVertex _u_prev_dt
Definition: discretization_grid_interface.h:191
console.h
non_uniform_shooting_grid_base.h
corbo::NonUniformShootingGridBase::getVertices
void getVertices(std::vector< VertexInterface * > &vertices) override
Definition: non_uniform_shooting_grid_base.cpp:540
corbo::NonUniformShootingGridBase::getNRef
int getNRef() const
Definition: non_uniform_shooting_grid_base.h:144
corbo::NonUniformShootingGridBase::findNearestShootingInterval
int findNearestShootingInterval(const Eigen::VectorXd &x0)
Definition: non_uniform_shooting_grid_base.cpp:390
corbo::NonUniformShootingGridBase::_dt_lb
double _dt_lb
Definition: non_uniform_shooting_grid_base.h:217
corbo::NonUniformShootingGridBase::updateBounds
void updateBounds(const NlpFunctions &nlp_fun)
Definition: non_uniform_shooting_grid_base.cpp:494
corbo::NonUniformShootingGridBase::ShootingInterval
Definition: non_uniform_shooting_grid_base.h:89
corbo::NonUniformShootingGridBase::clear
void clear() override
Definition: non_uniform_shooting_grid_base.cpp:530
corbo::VectorVertex::values
const Eigen::VectorXd & values() const
Read-access to the underlying value vector.
Definition: vector_vertex.h:284
corbo::NlpFunctions::u_ub
Eigen::VectorXd u_ub
Definition: nlp_functions.h:71
Eigen::PlainObjectBase::setConstant
EIGEN_DEVICE_FUNC Derived & setConstant(Index size, const Scalar &val)
Definition: CwiseNullaryOp.h:341
corbo::NonUniformShootingGridBase::getStateAndControlTimeSeries
void getStateAndControlTimeSeries(TimeSeries::Ptr x_sequence, TimeSeries::Ptr u_sequence, double t_max=CORBO_INF_DBL) const override
Return state and control trajectory as time series object (shared instance)
Definition: non_uniform_shooting_grid_base.cpp:578
abs
EIGEN_DEVICE_FUNC const EIGEN_STRONG_INLINE AbsReturnType abs() const
Definition: ArrayCwiseUnaryOps.h:43
corbo::NonUniformShootingGridBase::hasSingleDt
bool hasSingleDt() const override
Definition: non_uniform_shooting_grid_base.h:121
corbo::NlpFunctions::x_lb
Eigen::VectorXd x_lb
Definition: nlp_functions.h:68
corbo::NlpFunctions::u_lb
Eigen::VectorXd u_lb
Definition: nlp_functions.h:70
corbo::NonUniformShootingGridBase::_active_vertices
std::vector< VertexInterface * > _active_vertices
Definition: non_uniform_shooting_grid_base.h:205
corbo::NonUniformShootingGridBase::_intervals
std::vector< ShootingInterval > _intervals
Definition: non_uniform_shooting_grid_base.h:203
corbo::VectorVertex::clear
void clear() override
Clear complete backup container.
Definition: vector_vertex.h:279
corbo::VertexInterface::isFixed
virtual bool isFixed() const
Check if all components are fixed.
Definition: vertex_interface.h:91
corbo::NonUniformShootingGridBase::_xf_fixed
Eigen::Matrix< bool, -1, 1 > _xf_fixed
Definition: non_uniform_shooting_grid_base.h:216
corbo::NonUniformShootingGridBase::isGridAdaptActive
virtual bool isGridAdaptActive() const
Definition: non_uniform_shooting_grid_base.h:194
corbo::NonUniformShootingGridBase::isDtFixedIntended
virtual bool isDtFixedIntended() const
Definition: non_uniform_shooting_grid_base.h:192
corbo::SystemDynamicsInterface::Ptr
std::shared_ptr< SystemDynamicsInterface > Ptr
Definition: system_dynamics_interface.h:91
corbo::NonUniformShootingGridBase::_n_adapt
int _n_adapt
Definition: non_uniform_shooting_grid_base.h:209
int
return int(ret)+1
corbo::NonUniformShootingGridBase::_warm_start
bool _warm_start
Definition: non_uniform_shooting_grid_base.h:212
corbo::NonUniformShootingGridBase::computeActiveVertices
void computeActiveVertices() override
Definition: non_uniform_shooting_grid_base.cpp:560
utilities.h
corbo::ScalarVertex::value
const double & value() const
Get underlying value.
Definition: scalar_vertex.h:225
corbo::VectorVertex::setLowerBounds
void setLowerBounds(const Eigen::Ref< const Eigen::VectorXd > &lb) override
Define lower bounds on the vertex values [getDimension() x 1].
Definition: vector_vertex.h:188
corbo::PartiallyFixedVectorVertex::set
void set(const Eigen::Ref< const Eigen::VectorXd > &values, const Eigen::Ref< const Eigen::VectorXd > &lb, const Eigen::Ref< const Eigen::VectorXd > &ub, bool fixed=false) override
Set values and bounds at once.
Definition: vector_vertex.h:349
corbo::NonUniformShootingGridBase::setNRef
void setNRef(int n)
Definition: non_uniform_shooting_grid_base.cpp:456
corbo::VertexSetInterface::isModified
bool isModified() const
Definition: vertex_set.h:127
corbo::NonUniformShootingGridBase::isEmpty
bool isEmpty() const override
Definition: non_uniform_shooting_grid_base.h:132
corbo::NonUniformShootingGridBase::_first_run
bool _first_run
Definition: non_uniform_shooting_grid_base.h:213
corbo::NonUniformShootingGridBase::getFinalTime
double getFinalTime() const override
Definition: non_uniform_shooting_grid_base.cpp:427
corbo::ScalarVertex
Vertex implementation for scalar values.
Definition: scalar_vertex.h:72
min
#define min(a, b)
Definition: datatypes.h:19
corbo::NonUniformShootingGridBase::getN
int getN() const override
Definition: non_uniform_shooting_grid_base.cpp:445
corbo::NonUniformShootingGridBase::_full_discretization
bool _full_discretization
Definition: non_uniform_shooting_grid_base.h:220
corbo::NonUniformShootingGridBase::getFirstControlInput
bool getFirstControlInput(Eigen::VectorXd &u0) override
Definition: non_uniform_shooting_grid_base.cpp:437
n
PlainMatrixType mat * n
Definition: eigenvalues.cpp:41
corbo::NonUniformShootingGridBase::_num_u_per_interv_ref
int _num_u_per_interv_ref
Definition: non_uniform_shooting_grid_base.h:207
corbo::VectorVertex
Vertex implementation that stores an Eigen::VectorXd (dynamic dimension)
Definition: vector_vertex.h:73
corbo::TimeSeries::Ptr
std::shared_ptr< TimeSeries > Ptr
Definition: time_series.h:108
corbo::NonUniformShootingGridBase::_dt_ub
double _dt_ub
Definition: non_uniform_shooting_grid_base.h:218
max
#define max(a, b)
Definition: datatypes.h:20
corbo::NonUniformShootingGridBase::adaptGrid
virtual bool adaptGrid(bool new_run, NlpFunctions &nlp_fun)
Definition: non_uniform_shooting_grid_base.h:182
corbo::VertexSetInterface::setModified
void setModified(bool modified)
Definition: vertex_set.h:126
corbo::ScalarVertex::setLowerBound
void setLowerBound(double lb)
Set lower bound.
Definition: scalar_vertex.h:148
corbo::DiscretizationGridInterface::_u_prev
VectorVertex _u_prev
Definition: discretization_grid_interface.h:190


control_box_rst
Author(s): Christoph Rösmann
autogenerated on Wed Mar 2 2022 00:05:58