pendulum.cpp
Go to the documentation of this file.
00001 /*
00002  *    This file is part of ACADO Toolkit.
00003  *
00004  *    ACADO Toolkit -- A Toolkit for Automatic Control and Dynamic Optimization.
00005  *    Copyright (C) 2008-2009 by Boris Houska and Hans Joachim Ferreau, K.U.Leuven.
00006  *    Developed within the Optimization in Engineering Center (OPTEC) under
00007  *    supervision of Moritz Diehl. All rights reserved.
00008  *
00009  *    ACADO Toolkit is free software; you can redistribute it and/or
00010  *    modify it under the terms of the GNU Lesser General Public
00011  *    License as published by the Free Software Foundation; either
00012  *    version 3 of the License, or (at your option) any later version.
00013  *
00014  *    ACADO Toolkit is distributed in the hope that it will be useful,
00015  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017  *    Lesser General Public License for more details.
00018  *
00019  *    You should have received a copy of the GNU Lesser General Public
00020  *    License along with ACADO Toolkit; if not, write to the Free Software
00021  *    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00022  *
00023  */
00024 
00025 
00026 
00035 void pendulum( DifferentialEquation *f ){
00036 
00037 
00038     DifferentialState      phi;    // the angle phi
00039     DifferentialState     dphi;    // the first derivative of phi w.r.t time
00040 
00041     Control                  F;    // a force acting on the pendulum
00042 
00043     Parameter                l;    // the length of the pendulum
00044 
00045     const double m     = 1.0  ;    // the mass of the pendulum
00046     const double g     = 9.81 ;    // the gravitational constant
00047     const double alpha = 2.0  ;    // frictional constant
00048 
00049 
00050     IntermediateState z;
00051 
00052     z = sin(phi);
00053 
00054     *f << dot(phi) == dphi;
00055     *f << dot(dphi) == -(m*g/l)*z - alpha*dphi + F/(m*l);
00056 }
00057 
00058 
00059 


acado
Author(s): Milan Vukov, Rien Quirynen
autogenerated on Thu Aug 27 2015 11:59:46