crane_cl_mhe.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 
32 
33 int main()
34 {
36 
37  // Variables:
38  DifferentialState p; // the trolley position
39  DifferentialState v; // the trolley velocity
40  DifferentialState phi; // the excitation angle
41  DifferentialState omega; // the angular velocity
42  Control a; // the acc. of the trolley
43 
44  const double g = 9.81; // the gravitational constant
45  const double b = 0.20; // the friction coefficient
46 
47  // Model equations:
49 
50  f << dot( p ) == v;
51  f << dot( v ) == a;
52  f << dot( phi ) == omega;
53  f << dot( omega ) == -g * sin(phi) - a * cos(phi) - b * omega;
54 
55  // Measurement functions and weighting matrices:
56  Function h, hN;
57  h << p << phi << a;
58  hN << p << phi;
59 
60  BMatrix W = eye<bool>( h.getDim() );
61  BMatrix WN = eye<bool>( hN.getDim() );
62 
63  //
64  // Optimal Control Problem
65  //
66  OCP ocp(0.0, 3.0, 10);
67 
68  ocp.subjectTo( f );
69 
70  ocp.minimizeLSQ(W, h);
71  ocp.minimizeLSQEndTerm(WN, hN);
72 
73  // Export the code:
74  OCPexport mhe( ocp );
75 
78  mhe.set( INTEGRATOR_TYPE, INT_RK4 );
79  mhe.set( NUM_INTEGRATOR_STEPS, 30 );
80 
81  // NOTE: Those three options define MHE configuration!
82  mhe.set( FIX_INITIAL_STATE, NO );
84  mhe.set( QP_SOLVER, QP_QPOASES );
85 
86 // mpc.set( LEVENBERG_MARQUARDT, 1.0e-4 );
87 
88  mhe.set( GENERATE_TEST_FILE, NO );
89  mhe.set( GENERATE_MAKE_FILE, NO );
92 
93 // mpc.set( USE_SINGLE_PRECISION, YES );
94 
95  // Optionally set custom module name:
96  mhe.set( CG_MODULE_NAME, "mhe" );
97 
98  if (mhe.exportCode( "crane_cl_mhe_export" ) != SUCCESSFUL_RETURN)
99  exit( EXIT_FAILURE );
100 
101  mhe.printDimensionsQP( );
102 
103  return EXIT_SUCCESS;
104 }
USING_NAMESPACE_ACADO IntermediateState sin(const Expression &arg)
Allows to setup and evaluate a general function based on SymbolicExpressions.
Definition: function_.hpp:59
#define USING_NAMESPACE_ACADO
virtual returnValue exportCode(const std::string &dirName, const std::string &_realString="real_t", const std::string &_intString="int", int _precision=16)
Definition: ocp_export.cpp:68
IntermediateState cos(const Expression &arg)
returnValue set(OptionsName name, int value)
Definition: options.cpp:126
#define YES
Definition: acado_types.hpp:51
int getDim() const
#define NO
Definition: acado_types.hpp:53
Data class for defining optimal control problems.
Definition: ocp.hpp:89
#define v
Expression dot(const Expression &arg)
int main()
A user class for auto-generation of OCP solvers.
Definition: ocp_export.hpp:57
returnValue printDimensionsQP()
Definition: ocp_export.cpp:464
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:31