Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
giampy1969 committed Sep 18, 2023
1 parent eea3c6f commit 135555b
Show file tree
Hide file tree
Showing 69 changed files with 9,920 additions and 0 deletions.
6 changes: 6 additions & 0 deletions SECURITY.md
@@ -0,0 +1,6 @@
# Reporting Security Vulnerabilities

If you believe you have discovered a security vulnerability, please report it to
[security@mathworks.com](mailto:security@mathworks.com). Please see
[MathWorks Vulnerability Disclosure Policy for Security Researchers](https://www.mathworks.com/company/aboutus/policies_statements/vulnerability-disclosure-policy.html)
for additional information.
10 changes: 10 additions & 0 deletions contents.m
@@ -0,0 +1,10 @@
% LQRSIM: Algebraic Riccati Equation solution in Simulink
% Version 2.1 (R14SP1) 1-Jan-2009
%
% Giampiero Campa, Jason Hall, Riccardo Bevilacqua
%
%
% EXAMPLE :
%
% sfcndemo_lqry : main example.
%
21 changes: 21 additions & 0 deletions demos.m
@@ -0,0 +1,21 @@
function tbxStruct = demos

%DEMOS Demo list for the LqrSim Library.

% Version 2.1
% Giampiero Campa, Jason Hall, Riccardo Bevilacqua
% 1-Jan-2009

if nargout == 0, demo blockset; return; end

tbxStruct.Name='LqrSim';
tbxStruct.Type='Blockset';

tbxStruct.Help={

'The block lqrysim solves Algebraic Riccati Equations'
'without calling the matlab interpreter.'

};

tbxStruct.DemoList = { ' Main Demo', 'sfcndemo_lqry' };
24 changes: 24 additions & 0 deletions info.xml
@@ -0,0 +1,24 @@
<productinfo>

<matlabrelease>12.1</matlabrelease>
<name>LqrSim</name>
<type>blockset</type>
<icon>$toolbox/simulink/simulink/simulinkicon.gif</icon>

<list>

<listitem>
<label>Help</label>
<callback>doc lqrsim/</callback>
<icon>$toolbox/matlab/icons/book_sim.gif</icon>
</listitem>

<listitem>
<label>Main Example</label>
<callback>sfcndemo_lqry</callback>
<icon>$toolbox/matlab/icons/demoicon.gif</icon>
</listitem>

</list>

</productinfo>
11 changes: 11 additions & 0 deletions license.txt
@@ -0,0 +1,11 @@
Copyright (c) 2023, The MathWorks, Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
3. In all cases, the software is, and all modifications and derivatives of the software shall be, licensed to you solely for use in conjunction with MathWorks products and service offerings.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.




105 changes: 105 additions & 0 deletions readme.txt
@@ -0,0 +1,105 @@
/*************************************************************************
* *
* ALGEBRAIC RICCATI SOLUTION IN SIMULINK VIA C + FORTRAN *
* Giampiero Campa *
* October 2002 *
* *
* Jason Hall, Riccardo Bevilacqua *
* Spacecraft Robotics Laboratory *
* Naval Postgraduate School, Monterey, CA *
* September 2008 *
* *
* The s-function sfun_lqrysim solves Riccati equations in Simulink *
* without calling the Matlab interpreter. *
* It is based on the "ricpack" FORTRAN code written by Arnold and Laub *
* in the early eighties and publicly available under the cascade *
* sublibrary of netlib: http://www.netlib.org/ieeecss/cascade/ *
* *
* In particular, the s-function is a level-2 gateway that performs a *
* coordinate transformation to rearrange a general LQR problem (see *
* the Matlab function lqry) into a simplified form, calls a simplified *
* version of the creg.f routine to solve the Riccati equation, and uses *
* the solution of the Riccati equation to find the feedback gain matrix *
* that solves the original LQR problem. *
* *
* The parameters to be given to the s-function are the number of states,*
* the number of inputs, and the number of outputs, in that order. *
* *
* The inputs to the s-function are, in order, the matrices A,B,C,D,Q,R *
* *
* The outputs are, in the following order, the solution of the Riccati *
* equation, the feedback gain matrix, and a 2D vector. The first *
* element in the 2D vector indicates an error when greater than zero or *
* a somewhat "unreliable" result when negative. The second element is *
* simply the condition number of the R matrix. *
* *
* A self-explanatory example (the Simulink scheme sfcndemo_lqry.mdl) is *
* presented along with appropriate mex function to allow it to be *
* executed in both a linux and win32 environment. Additionally, the *
* fortran filesnare included to allow re-mex of this .c file and use in *
* generating code for use in a real-time environments such as RTAI. *
* *
* The file creg.f has been simplified by commenting-out several sections*
* (see the source code to know why), and that a few other routines have *
* been modified to avoid complaints on standard output. *
* The original code is available at the address given above under the *
* link "creg.f plus dependencies" *
* *
* If creating the mex file in the win32 environment, ensure that MinGW *
* is installed with at least the g77 compiler selected (the latest *
* version can be downloaded and installed from www.sourceforge.net). *
* Copy the g77.exe file that will be created using the default install *
* from C:\MinGW\bin to the working directory in MATLAB and verify that *
* the Fortran files and the sfun_lqrysim.c files are also in the working*
* directory and then call the following in the MATLAB Command Window: *
* *
* >> eval('! g77 -c *.f') *
* >> mex sfun_lqrysim.c *.o *
* *
* If creating the mex file in a Linux enviroment, ensure g77 is *
* installed following these instructions from a root (ubuntu) terminal: *
* *
* #apt-get install g77-3.4 *
* #ln -s /usr/bin/g77-3.4 /usr/bin/g77 *
* *
* Again, verify that the Fortran files and the sfun_lqrysim.c files are *
* in the working directory (you do not need the g77.exe file as in the *
* win32 case) and then call the following in the Command Window: *
* *
* >> eval('! g77 -c *.f') *
* >> mex sfun_lqrysim.c *.o *
* *
* To compile using Real Time Workshop, choose the appropriate .tlc file *
* under Configuration Parameters>Real-Time Workshop, then go to *
* Configurations Parameters>Real-Time Workshop>Custom Code and put in *
* the full path to where the source code exists (*.f, *.o files, and *
* sfun_lqrysim.c) in the Include list of the additional:>Include *
* directories: of the RTW GUI window *
* *
* For example: For NPS SRL - ../toolbox/nps_srl/src/lqry/ *
* *
* Next, type all the *.o files into Include list of additional:>Source *
* files: GUI window. Go back to Configurations Parameters> Real-Time *
* Workshop> and select Generate Code. *
* *
* If the target is such that the executable can be built on the machine *
* where you run the simulation, then at this point you can deselect *
* the Generate Code option under Configurations Parameters > *
* Real-Time Workshop and build the code. *
* *
* Assumed that the target is RTAI, copy the all the Fortran files, *
* their object files and the sfun_lqrysim.c to the created *
* (mdl name)_rtai folder. If you are not on a windows machine then you *
* neet to move the whole folder to the linux machine (essentially *
* following point 17 of the RTAI_TARGET_HOWTO.TXT file, available on *
* the matlabcentral web site, assuming that the previous things have *
* already been done), then on linux, open a root terminal, browse to *
* the (mdl name)_rtai folder, and then type: *
* *
* # make -f *.mk *
* *
* The executable will be generated and placed in the folder one up from *
* the (mdl name)_rtai folder. *
* *
*************************************************************************/

0 comments on commit 135555b

Please sign in to comment.