examples/basic_data_structures/curve/getting_started.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 
35 #include <acado_integrators.hpp>
36 #include <acado_gnuplot.hpp>
37 
38 
39 /* >>> start tutorial code >>> */
40 int main( ){
41 
43 
44 
45  // DEFINE SOME FUNCTIONS:
46  // ----------------------
47 
48  TIME t;
49  Function sine, cosine,
50  ramp1, ramp2, ramp3,
51  parabola;
52 
53  sine << sin(t);
54  cosine << cos(t);
55 
56  ramp1 << t ;
57  ramp2 << t - 1.0;
58  ramp3 << t - 2.0;
59 
60  parabola << t*t/M_PI - 3.0*t + 2.0*M_PI;
61 
62 
63  // DEFINE SOME CURVES:
64  // -------------------
65 
66  Curve c1, c2, c3, c4;
67 
68  c1.add( 0.0, 2.0*M_PI, sine );
69  c2.add( 0.0, 2.0*M_PI, cosine );
70 
71  c3.add( 0.0, 1.0, ramp1 );
72  c3.add( 1.0, 2.0, ramp2 );
73  c3.add( 2.0, 3.0, ramp3 );
74 
75  c4.add( 0.0 , M_PI, sine );
76  c4.add( M_PI, 2.0*M_PI, parabola );
77 
78 
79 
80  // PLOT CURVES ON GIVEN GRID:
81  // --------------------------
82  GnuplotWindow window;
83  window.addSubplot( c1, 0.0,2.0*M_PI, "Sampled sine function" );
84  window.addSubplot( c2, 0.0,2.0*M_PI, "Sampled cosine function" );
85  window.addSubplot( c3, 0.0,3.0, "Sampled ramp function" );
86  window.addSubplot( c4, 0.0,2.0*M_PI, "composed curve" );
87  window.plot();
88 
89  return 0;
90 }
91 /* <<< end tutorial code <<< */
92 
93 
USING_NAMESPACE_ACADO IntermediateState sin(const Expression &arg)
Allows to setup and evaluate a general function based on SymbolicExpressions.
Definition: function_.hpp:59
virtual returnValue plot(PlotFrequency _frequency=PLOT_IN_ANY_CASE)
returnValue add(double tStart, double tEnd, const DVector constant)
Definition: curve.cpp:143
#define USING_NAMESPACE_ACADO
returnValue addSubplot(PlotWindowSubplot &_subplot)
IntermediateState cos(const Expression &arg)
#define M_PI
Definition: acado_utils.hpp:54
Allows to work with piecewise-continous function defined over a scalar time interval.
Definition: curve.hpp:52
Provides an interface to Gnuplot for plotting algorithmic outputs.


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