interfaces/matlab/examples/integrator/pendulum.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-2009 by Boris Houska and Hans Joachim Ferreau, K.U.Leuven.
6  * Developed within the Optimization in Engineering Center (OPTEC) under
7  * supervision of Moritz Diehl. All rights reserved.
8  *
9  * ACADO Toolkit is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 3 of the License, or (at your option) any later version.
13  *
14  * ACADO Toolkit 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 GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with ACADO Toolkit; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22  *
23  */
24 
25 
26 
36 
37 
38  DifferentialState phi; // the angle phi
39  DifferentialState dphi; // the first derivative of phi w.r.t time
40 
41  Control F; // a force acting on the pendulum
42 
43  Parameter l; // the length of the pendulum
44 
45  const double m = 1.0 ; // the mass of the pendulum
46  const double g = 9.81 ; // the gravitational constant
47  const double alpha = 2.0 ; // frictional constant
48 
49 
51 
52  z = sin(phi);
53 
54  *f << dot(phi) == dphi;
55  *f << dot(dphi) == -(m*g/l)*z - alpha*dphi + F/(m*l);
56 }
57 
58 
59 
USING_NAMESPACE_ACADO IntermediateState sin(const Expression &arg)
void pendulum(DifferentialEquation *f)
Expression dot(const Expression &arg)
Allows to setup and evaluate differential equations (ODEs and DAEs) based on SymbolicExpressions.


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