Skip to content

Commit 6e9a676

Browse files
Gabriele NavaGiuleroCarlottaSartore
authored
Whole-Body-Controllers Release 2.5.1 (#108)
* added a new momentum-velocity controller * cleanup of the WCB simulink library * improvements in velocity controller (#104) * improvements in velocity controller * added new line at the end of the files * Velocity Controller-Relax Momentum Constraint (#107) * fixes centroidalTransformaion and ComputeReferencesController * fixed some typos, removed hardcoded variables, clean up * fixed indeces for velocity limits * minor fixes Co-authored-by: Giuseppe <gl.giuseppelerario@gmail.com> Co-authored-by: CarlottaSartore <56030908+CarlottaSartore@users.noreply.github.com>
1 parent e505003 commit 6e9a676

32 files changed

+3604
-10304
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ slprj/
2626
# Simulink slx
2727
*.slxc
2828
*.slx
29+
!/library/simulink-library/*.slx
30+
!/library/simulink-library/*/*.slx
2931

3032
# Matlab binary .mat files
3133
*.mat

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ The repository contains `Simulink-based whole-body controllers` developed to con
2222
This repository depends upon the following Software:
2323

2424
- [CMake](https://cmake.org/), at least version **3.5**.
25-
- [Matlab/Simulink](https://it.mathworks.com/products/matlab.html), default version **R2017b**.
25+
- [Matlab/Simulink](https://it.mathworks.com/products/matlab.html), default version **R2019b**.
2626
- [WB-Toolbox](https://github.com/robotology/WB-Toolbox) and [blockfactory](https://github.com/robotology/blockfactory).
2727
- [Gazebo Simulator](http://gazebosim.org/), default version **9.0**.
2828
- [gazebo-yarp-plugins](https://github.com/robotology/gazebo-yarp-plugins).

config/export_WBC.m

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
%% export_WBC.m
22
%
33
% Export Simulink models to a previous supported version. Currently,
4-
% the default version is MATLAB 2017b. IF YOU OWE A MATLAB VERSION GREATER
5-
% THAN 2017B, REMEMBER TO EXPORT ALL MODELS TO THE DEFAULT SUPPORTED
4+
% the default version is MATLAB 2019b. IF YOU OWE A MATLAB VERSION GREATER
5+
% THAN 2019B, REMEMBER TO EXPORT ALL MODELS TO THE DEFAULT SUPPORTED
66
% VERSION BEFORE PUBLISHING ANY MODIFICATIONS, OTHERWISE OTHER USERS MAY
77
% NOT BE ABLE TO USE THE MODELS!
88
%
@@ -12,6 +12,7 @@
1212

1313
fprintf('\nwhole-body-controllers\n');
1414
fprintf('\nExport project to a previous Matlab version\n');
15+
fprintf('\nWBC Default version: R2019b\n');
1516
fprintf('\nOldest supported version: R2014a\n');
1617

1718
fprintf('\n######################################################\n');
@@ -21,19 +22,20 @@
2122
fprintf('\nmay still not work properly.\n');
2223
fprintf('\n######################################################\n\n');
2324

24-
% list of all simulink models (in this repo only .mdl are allowed) in the project
25+
% list of all simulink mdl and slx in the project
2526
mdlList = dir('../**/*.mdl');
27+
slxList = dir('../**/*.slx');
2628

2729
% matlab version to which export all models
2830
matlabVer = input('Specify the Matlab version to export models (format: R20XXx) ','s');
2931

3032
%% Verify matlab version
3133

32-
% latest version: R2018a
33-
matlabVer_list = {'R2014a','R2014b','R2015a','R2015b','R2016a','R2016b','R2017a','R2017b','R2018a'};
34+
% latest version: R2019b
35+
matlabVer_list = {'R2014a','R2014b','R2015a','R2015b','R2016a','R2016b','R2017a','R2017b','R2018a','R2018b','R2019a','R2019b'};
3436

3537
% associated Simulink version
36-
simulinkVer_number = {'8.3','8.4','8.5','8.6','8.7','8.8','8.9','9.0','9.1'};
38+
simulinkVer_number = {'8.3','8.4','8.5','8.6','8.7','8.8','8.9','9.0','9.1','9.2','9.3','10.0'};
3739

3840
% installed Simulink version
3941
currentSimulinkVer = ver('Simulink');
@@ -65,14 +67,15 @@
6567
end
6668

6769
%% Load the Simulink models and export to previous versions
68-
mdlVer_list = {'R2014A_MDL','R2014B_MDL','R2015A_MDL','R2015B_MDL','R2016A_MDL','R2016B_MDL','R2017A_MDL','R2017B_MDL','R2018A_MDL'};
70+
mdlVer_list = {'R2014A_MDL','R2014B_MDL','R2015A_MDL','R2015B_MDL','R2016A_MDL','R2016B_MDL','R2017A_MDL','R2017B_MDL','R2018A_MDL','R2018B_MDL','R2019A_MDL','R2019B_MDL'};
71+
slxVer_list = {'R2014A_SLX','R2014B_SLX','R2015A_SLX','R2015B_SLX','R2016A_SLX','R2016B_SLX','R2017A_SLX','R2017B_SLX','R2018A_SLX','R2018B_SLX','R2019A_SLX','R2019B_SLX'};
6972

7073
% close all open models (if there is any)
7174
close_system('',0)
7275

7376
for k = 1:length(mdlList)
7477

75-
fprintf(['\nLOADED MODEL: ' mdlList(k).name '\n']);
78+
fprintf(['\nLOADED MDL FILE: ' mdlList(k).name '\n']);
7679
open_system([mdlList(k).folder,'/',mdlList(k).name],'loadonly');
7780

7881
% save the model in a temporary copy. Then, export the copy into
@@ -97,5 +100,32 @@
97100
% delete the temporary model
98101
delete([mdlList(k).folder,'/',mdlList(k).name(1:end-4),'_temp.mdl'])
99102
end
103+
for k = 1:length(slxList)
104+
105+
fprintf(['\nLOADED SLX FILE: ' slxList(k).name '\n']);
106+
open_system([slxList(k).folder,'/',slxList(k).name],'loadonly');
107+
108+
% save the model in a temporary copy. Then, export the copy into
109+
% the previous version, by overwriting the original model
110+
fprintf('\n saving a temporary copy of the model \n\n');
111+
save_system([slxList(k).folder,'/',slxList(k).name], [slxList(k).folder,'/',slxList(k).name(1:end-4),'_temp.slx']);
112+
close_system([slxList(k).folder,'/',slxList(k).name],0);
113+
open_system([slxList(k).folder,'/',slxList(k).name(1:end-4),'_temp.slx'],'loadonly');
114+
115+
% do not export if simulink models are already at the required version
116+
if str2double(simulinkVer_number{matlabVer_found}) == str2double(currentSimulinkVer.Version)
117+
118+
fprintf('\n model is already at the required version. \n');
119+
else
120+
save_system([slxList(k).folder,'/',slxList(k).name(1:end-4),'_temp.slx'], [slxList(k).folder,'/',slxList(k).name], 'ExportToVersion', slxVer_list{matlabVer_found});
121+
end
122+
123+
% closing the temporary model
124+
fprintf('\n closing the model \n');
125+
close_system([slxList(k).folder,'/',slxList(k).name(1:end-4),'_temp.slx']);
126+
127+
% delete the temporary model
128+
delete([slxList(k).folder,'/',slxList(k).name(1:end-4),'_temp.slx'])
129+
end
100130

101131
fprintf('\nDone.\n');

config/startup_WBC.m.in

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,20 @@ pathToInstallDir = '@CMAKE_INSTALL_PREFIX@';
1111

1212
% path to the matlab-wbc library
1313
pathToLibrary = [pathToInstallDir, filesep, 'mex'];
14+
pathToSimLib = [pathToInstallDir, filesep, 'mex/+wbc/simulink'];
1415

1516
if exist(pathToLibrary, 'dir')
1617

1718
addpath(pathToLibrary);
1819
else
1920
error('Path to the "+wbc" library not found or not correct.')
2021
end
22+
if exist(pathToSimLib, 'dir')
23+
24+
addpath(pathToSimLib);
25+
else
26+
error('Path to the "+wbc/simulink" library not found or not correct.')
27+
end
2128

2229
% Path to the Matlab userpath
2330
pathToUserpath = userpath;

0 commit comments

Comments
 (0)