From c0de94043400baac9a383aa70e3fb13358bc3299 Mon Sep 17 00:00:00 2001 From: Thomas Dehaeze Date: Wed, 22 Jan 2020 15:32:32 +0100 Subject: [PATCH] Add simulink project --- Stewartsimscape.prj | 2 +- active-damping.org | 2 +- control-study.org | 3 +- cubic-configuration.org | 3 +- dynamics-study.org | 2 +- identification.org | 16 ++++++-- kinematic-study.org | 13 +++++-- simscape-model.org | 2 +- simulink-project.org | 85 +++++++++++++++++++++++++++++++++++++++++ src/project_shutdown.m | 5 +++ src/project_startup.m | 18 +++++++++ 11 files changed, 136 insertions(+), 15 deletions(-) create mode 100644 simulink-project.org create mode 100644 src/project_shutdown.m create mode 100644 src/project_startup.m diff --git a/Stewartsimscape.prj b/Stewartsimscape.prj index a7df471..92c6696 100644 --- a/Stewartsimscape.prj +++ b/Stewartsimscape.prj @@ -1,2 +1,2 @@ - + diff --git a/active-damping.org b/active-damping.org index 53b49d3..b5bf2c2 100644 --- a/active-damping.org +++ b/active-damping.org @@ -31,7 +31,7 @@ #+end_src #+begin_src matlab - addpath('./src/') + simulinkproject('./'); #+end_src ** Simscape Model diff --git a/control-study.org b/control-study.org index 4001a58..22949aa 100644 --- a/control-study.org +++ b/control-study.org @@ -43,8 +43,7 @@ #+end_src #+begin_src matlab - addpath('./src/') - addpath('./simulink/') + simulinkproject('./'); #+end_src ** Control Schematic diff --git a/cubic-configuration.org b/cubic-configuration.org index c0a4bc3..8b07ad0 100644 --- a/cubic-configuration.org +++ b/cubic-configuration.org @@ -44,8 +44,7 @@ According to cite:preumont07_six_axis_singl_stage_activ, the cubic configuration #+end_src #+begin_src matlab :results none :exports none - addpath('src'); - addpath('library'); + simulinkproject('./'); #+end_src * Questions we wish to answer with this analysis diff --git a/dynamics-study.org b/dynamics-study.org index 7870dcd..fca28df 100644 --- a/dynamics-study.org +++ b/dynamics-study.org @@ -31,7 +31,7 @@ #+end_src #+begin_src matlab - addpath('./src/') + simulinkproject('./'); #+end_src ** Simscape Model diff --git a/identification.org b/identification.org index 42fc5e1..d084ba6 100644 --- a/identification.org +++ b/identification.org @@ -22,12 +22,20 @@ :END: * Identification -#+begin_src matlab :results none :exports none :noweb yes - <> - addpath('src'); - addpath('library'); +** Matlab Init :noexport:ignore: +#+begin_src matlab :tangle no :exports none :results silent :noweb yes :var current_dir=(file-name-directory buffer-file-name) + <> #+end_src +#+begin_src matlab :exports none :results silent :noweb yes + <> +#+end_src + +#+begin_src matlab :results none :exports none + simulinkproject('./'); +#+end_src + +** Script #+begin_src matlab :results none :exports none open stewart #+end_src diff --git a/kinematic-study.org b/kinematic-study.org index 5b471ed..54f7d3b 100644 --- a/kinematic-study.org +++ b/kinematic-study.org @@ -21,10 +21,17 @@ #+PROPERTY: header-args:matlab+ :output-dir figs :END: -#+begin_src matlab :results none :exports none :noweb yes +* Matlab Init :noexport:ignore: +#+begin_src matlab :tangle no :exports none :results silent :noweb yes :var current_dir=(file-name-directory buffer-file-name) + <> +#+end_src + +#+begin_src matlab :exports none :results silent :noweb yes <> - addpath('src'); - addpath('library'); +#+end_src + +#+begin_src matlab :results none :exports none + simulinkproject('./'); #+end_src * Needed Actuator Stroke diff --git a/simscape-model.org b/simscape-model.org index 7ad1b68..5b2bdbf 100644 --- a/simscape-model.org +++ b/simscape-model.org @@ -91,7 +91,7 @@ By following this procedure, we obtain a Matlab structure =stewart= that contain #+end_src #+begin_src matlab - addpath('./src/') + simulinkproject('./'); #+end_src ** Simscape Model diff --git a/simulink-project.org b/simulink-project.org new file mode 100644 index 0000000..960aba5 --- /dev/null +++ b/simulink-project.org @@ -0,0 +1,85 @@ +#+TITLE: Simulink Project for the Stewart Simscape folder +:DRAWER: +#+STARTUP: overview + +#+LANGUAGE: en +#+EMAIL: dehaeze.thomas@gmail.com +#+AUTHOR: Dehaeze Thomas + +#+HTML_LINK_HOME: ./index.html +#+HTML_LINK_UP: ./index.html + +#+HTML_HEAD: +#+HTML_HEAD: +#+HTML_HEAD: +#+HTML_HEAD: +#+HTML_HEAD: +#+HTML_HEAD: +#+HTML_HEAD: + +#+HTML_MATHJAX: align: center tagside: right font: TeX + +#+PROPERTY: header-args:matlab :session *MATLAB* +#+PROPERTY: header-args:matlab+ :comments org +#+PROPERTY: header-args:matlab+ :results none +#+PROPERTY: header-args:matlab+ :exports both +#+PROPERTY: header-args:matlab+ :eval no-export +#+PROPERTY: header-args:matlab+ :output-dir figs +#+PROPERTY: header-args:matlab+ :tangle no +#+PROPERTY: header-args:matlab+ :mkdirp yes + +#+PROPERTY: header-args:shell :eval no-export + +#+PROPERTY: header-args:latex :headers '("\\usepackage{tikz}" "\\usepackage{import}" "\\import{$HOME/Cloud/thesis/latex/}{config.tex}") +#+PROPERTY: header-args:latex+ :imagemagick t :fit yes +#+PROPERTY: header-args:latex+ :iminoptions -scale 100% -density 150 +#+PROPERTY: header-args:latex+ :imoutoptions -quality 100 +#+PROPERTY: header-args:latex+ :results raw replace :buffer no +#+PROPERTY: header-args:latex+ :eval no-export +#+PROPERTY: header-args:latex+ :exports both +#+PROPERTY: header-args:latex+ :mkdirp yes +#+PROPERTY: header-args:latex+ :output-dir figs +:END: + +Simulink Project is used for the study of the NASS using Simscape. + +From the [[https://mathworks.com/products/simulink/projects.html][Simulink project]] mathworks page: +#+begin_quote + SimulinkĀ® and Simulink Projects provide a collaborative, scalable environment that enables teams to manage their files and data in one place. + + With Simulink Projects, you can: + - *Collaborate*: Enforce companywide standards such as company tools, libraries, and standard startup and shutdown scripts. Share your work with rich sharing options including MATLABĀ® toolboxes, email, and archives. + - *Automate*: Set up your project environment correctly every time by automating steps such as loading the data, managing the path, and opening the models. + - *Integrate with source control*: Enable easy integration with source control and configuration management tools. +#+end_quote + +The project can be opened using the =simulinkproject= function: + +#+begin_src matlab + simulinkproject('./'); +#+end_src + +When the project opens, a startup script is ran. +The startup script is defined below and is exported to the =project_startup.m= script. +#+begin_src matlab :eval no :tangle ./src/project_startup.m + project = simulinkproject; + projectRoot = project.RootFolder; + + myCacheFolder = fullfile(projectRoot, '.SimulinkCache'); + myCodeFolder = fullfile(projectRoot, '.SimulinkCode'); + + Simulink.fileGenControl('set',... + 'CacheFolder', myCacheFolder,... + 'CodeGenFolder', myCodeFolder,... + 'createDir', true); + + %% Load the Simscape Configuration + load('mat/conf_simscape.mat'); +#+end_src + +When the project closes, it runs the =project_shutdown.m= script defined below. +#+begin_src matlab :eval no :tangle ./src/project_shutdown.m + Simulink.fileGenControl('reset'); +#+end_src + +The project also permits to automatically add defined folder to the path when the project is opened. diff --git a/src/project_shutdown.m b/src/project_shutdown.m new file mode 100644 index 0000000..5bb8d70 --- /dev/null +++ b/src/project_shutdown.m @@ -0,0 +1,5 @@ + + +% When the project closes, it runs the =project_shutdown.m= script defined below. + +Simulink.fileGenControl('reset'); diff --git a/src/project_startup.m b/src/project_startup.m new file mode 100644 index 0000000..0cca35e --- /dev/null +++ b/src/project_startup.m @@ -0,0 +1,18 @@ + + +% When the project opens, a startup script is ran. +% The startup script is defined below and is exported to the =project_startup.m= script. + +project = simulinkproject; +projectRoot = project.RootFolder; + +myCacheFolder = fullfile(projectRoot, '.SimulinkCache'); +myCodeFolder = fullfile(projectRoot, '.SimulinkCode'); + +Simulink.fileGenControl('set',... + 'CacheFolder', myCacheFolder,... + 'CodeGenFolder', myCodeFolder,... + 'createDir', true); + +%% Load the Simscape Configuration +load('mat/conf_simscape.mat');