getting_started_grid.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of ACADO Toolkit.
3  *
4  * ACADO Toolkit -- A Toolkit for Automatic Control and Dynamic Optimization.
5  * Copyright (C) 2008-2014 by Boris Houska, Hans Joachim Ferreau,
6  * Milan Vukov, Rien Quirynen, KU Leuven.
7  * Developed within the Optimization in Engineering Center (OPTEC)
8  * under supervision of Moritz Diehl. All rights reserved.
9  *
10  * ACADO Toolkit is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Lesser General Public
12  * License as published by the Free Software Foundation; either
13  * version 3 of the License, or (at your option) any later version.
14  *
15  * ACADO Toolkit is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  * Lesser General Public License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public
21  * License along with ACADO Toolkit; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23  *
24  */
25 
26 
27 
34 #include <acado_integrators.hpp>
35 
36 using namespace std;
37 
39 
40 /* >>> start tutorial code >>> */
41 int main( )
42 {
43  // Setup an equidistant Grid with 5 grid points
44  double tStart = 0.0;
45  double tEnd = 2.0;
46 
47  Grid firstGrid( tStart,tEnd,5 );
48 
49  cout << "The grid consists of the following grid points:\n";
50  firstGrid.print();
51  cout << "Its third grid point has time: " << firstGrid.getTime( 2 ) << endl;
52 
53 
54  // Add additional grid point at time 7
55  // (time must be greater than time at last grid point)
56  firstGrid.addTime( 7.0 );
57 
58  cout << "\nNow, the grid consists of the following grid points:\n";
59  firstGrid.print();
60  cout << "Its interval length is: " << firstGrid.getIntervalLength() << endl;
61 
62 
63  // Setup an arbitrary grid with 3 grid points
64  Grid secondGrid( 3 );
65 
66  secondGrid.setTime( 0,-1.0 );
67  secondGrid.setTime( 1,1.0 );
68  secondGrid.setTime( 2,5.0 );
69 
70  cout << "\nThe second grid consists of the following grid points:\n";
71  secondGrid.print();
72 
73  // Add grid points of first grid to that of the second one
74  secondGrid& firstGrid;
75 
76  cout << "\nNow, the second grid consists of the following grid points:\n";
77  secondGrid.print();
78  cout << "Its interval length is: " << secondGrid.getIntervalLength() << endl
79  << "Its third grid point has time: " << secondGrid.getTime( 2 ) << endl;
80 
81  return 0;
82 }
83 /* <<< end tutorial code <<< */
84 
85 
returnValue setTime(double _time)
Definition: grid.cpp:307
double getTime(uint pointIdx) const
#define USING_NAMESPACE_ACADO
Allows to conveniently handle (one-dimensional) grids consisting of time points.
Definition: grid.hpp:58
returnValue print() const
Definition: grid.cpp:700
double getIntervalLength() const
USING_NAMESPACE_ACADO int main()
returnValue addTime(double _time)
Definition: grid.cpp:339


acado
Author(s): Milan Vukov, Rien Quirynen
autogenerated on Mon Jun 10 2019 12:34:39