Skip to content

Commit

Permalink
Add <INSTALL_PREFIX>/mex/+wbc/examples path to the CMake templates …
Browse files Browse the repository at this point in the history
…and conda scripts (#722)

- After changes introduced by robotology/whole-body-controllers#126
  • Loading branch information
nunoguedelha authored May 12, 2021
1 parent 029fdd3 commit d94d8ca
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 18 deletions.
1 change: 1 addition & 0 deletions cmake/template/addPathsToUserEnvVariables.ps1.in
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ Add-ValueToUserEnvVariable YARP_DATA_DIRS $ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX"
Add-ValueToUserEnvVariable GAZEBO_MODEL_PATH $ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX"\share\RRbot\robots";
Add-ValueToUserEnvVariable MATLABPATH $ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX"\mex";
Add-ValueToUserEnvVariable MATLABPATH $ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX"\mex\+wbc\simulink";
Add-ValueToUserEnvVariable MATLABPATH $ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX"\mex\+wbc\examples";
Add-ValueToUserEnvVariable MATLABPATH $ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX"\share\WBToolbox";
Add-ValueToUserEnvVariable MATLABPATH $ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX"\share\WBToolbox\images";
@endcmakeif ROBOTOLOGY_USES_MATLAB
1 change: 1 addition & 0 deletions cmake/template/removePathsFromUserEnvVariables.ps1.in
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ Remove-ValueFromUserEnvVariable YARP_DATA_DIRS $ROBOTOLOGY_SUPERBUILD_INSTALL_PR
Remove-ValueFromUserEnvVariable GAZEBO_MODEL_PATH $ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX"\share\RRbot\robots";
Remove-ValueFromUserEnvVariable MATLABPATH $ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX"\mex";
Remove-ValueFromUserEnvVariable MATLABPATH $ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX"\mex\+wbc\simulink";
Remove-ValueFromUserEnvVariable MATLABPATH $ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX"\mex\+wbc\examples";
Remove-ValueFromUserEnvVariable MATLABPATH $ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX"\share\WBToolbox";
Remove-ValueFromUserEnvVariable MATLABPATH $ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX"\share\WBToolbox\images";
@endcmakeif ROBOTOLOGY_USES_MATLAB
2 changes: 1 addition & 1 deletion cmake/template/setup.bat.in
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,5 @@ rem Set YARP and Gazebo related env variables
set "YARP_DATA_DIRS=%YARP_DATA_DIRS%;%ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX%\share\RRbot"
set "GAZEBO_MODEL_PATH=%GAZEBO_MODEL_PATH%;%ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX%\share\RRbot\robots"
rem Configure the Matlab
set "MATLABPATH=%MATLABPATH%;%ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX%\mex;%ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX%\mex\+wbc\simulink;%ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX%\share\WBToolbox;%ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX%\share\WBToolbox\images"
set "MATLABPATH=%MATLABPATH%;%ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX%\mex;%ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX%\mex\+wbc\simulink;%ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX%\mex\+wbc\examples;%ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX%\share\WBToolbox;%ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX%\share\WBToolbox\images"
@endcmakeif ROBOTOLOGY_USES_MATLAB
2 changes: 1 addition & 1 deletion cmake/template/setup.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,5 @@ export PYTHONPATH=${PYTHONPATH:+${PYTHONPATH}:}${ROBOTOLOGY_SUPERBUILD_INSTALL_P
export YARP_DATA_DIRS=$YARP_DATA_DIRS:${ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX}/share/RRbot
export GAZEBO_MODEL_PATH=$GAZEBO_MODEL_PATH:${ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX}/share/RRbot/robots
# Configure the Matlab path
export MATLABPATH=${MATLABPATH:+${MATLABPATH}:}${ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX}/mex:${ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX}/mex/+wbc/simulink:${ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX}/share/WBToolbox:${ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX}/share/WBToolbox/images
export MATLABPATH=${MATLABPATH:+${MATLABPATH}:}${ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX}/mex:${ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX}/mex/+wbc/simulink:${ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX}/mex/+wbc/examples:${ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX}/share/WBToolbox:${ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX}/share/WBToolbox/images
@endcmakeif ROBOTOLOGY_USES_MATLAB
5 changes: 3 additions & 2 deletions cmake/template/startup_robotology_superbuild.m.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ fprintf('\nMATLAB Toolbox\n');
installDir = '@YCM_EP_INSTALL_DIR@';
mexDir = [installDir, filesep, 'mex'];
simLibDir = [installDir, filesep, 'mex/+wbc/simulink'];
simModDir = [installDir, filesep, 'mex/+wbc/examples'];
shareDir = [installDir, filesep, 'share/WBToolbox'];
imgDir = [shareDir, filesep, 'images'];

for dirPath = {mexDir,simLibDir,shareDir,imgDir}
for dirPath = {mexDir,simLibDir,simModDir,shareDir,imgDir}
if exist(dirPath{1}, 'dir')
addpath(dirPath{1});
end
Expand All @@ -37,7 +38,7 @@ if (~savepath([fileDir, filesep, 'pathdef.m']))
'This should be enough to permanentely add all the MATLAB-Toolbox to ', ...
'your MATLAB installation.\n'], fileDir);
else
disp('There was an error generating pathdef.m To proceed please manually add the contents of variables mexDir, shareDir and imgDir to your matlabpath');
disp('There was an error generating pathdef.m To proceed please manually add the contents of variables mexDir, simLibDir, simModDir, shareDir and imgDir to your matlabpath');
end

% inform the user that it is possible to generate the goToWholeBodyControllers script
Expand Down
6 changes: 4 additions & 2 deletions conda/multisheller/whole-body-controllers_activate.msh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
if_(is_set("COMSPEC")).then_([
sys.list_append("MATLABPATH", path.join(env("CONDA_PREFIX"), "Library\\mex\\+wbc\\simulink"))
sys.list_append("MATLABPATH", path.join(env("CONDA_PREFIX"), "Library\\mex\\+wbc\\simulink")),
sys.list_append("MATLABPATH", path.join(env("CONDA_PREFIX"), "Library\\mex\\+wbc\\examples"))
]).else_([
sys.list_append("MATLABPATH", path.join(env("CONDA_PREFIX"), "mex/+wbc/simulink"))
sys.list_append("MATLABPATH", path.join(env("CONDA_PREFIX"), "mex/+wbc/simulink")),
sys.list_append("MATLABPATH", path.join(env("CONDA_PREFIX"), "mex/+wbc/examples"))
])
6 changes: 4 additions & 2 deletions conda/multisheller/whole-body-controllers_deactivate.msh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
if_(is_set("COMSPEC")).then_([
sys.list_remove("MATLABPATH", path.join(env("CONDA_PREFIX"), "Library\\mex\\+wbc\\simulink"))
sys.list_remove("MATLABPATH", path.join(env("CONDA_PREFIX"), "Library\\mex\\+wbc\\simulink")),
sys.list_remove("MATLABPATH", path.join(env("CONDA_PREFIX"), "Library\\mex\\+wbc\\examples"))
]).else_([
sys.list_remove("MATLABPATH", path.join(env("CONDA_PREFIX"), "mex/+wbc/simulink"))
sys.list_remove("MATLABPATH", path.join(env("CONDA_PREFIX"), "mex/+wbc/simulink")),
sys.list_remove("MATLABPATH", path.join(env("CONDA_PREFIX"), "mex/+wbc/examples"))
])
4 changes: 3 additions & 1 deletion doc/cmake-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,8 @@ Once this software has been compiled by the superbuild, you just need to add som
In particular you need to add to the MATLAB path:
* the `$ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX/mex` directory,
* the `$ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX/share/WBToolbox` directory and all its subdirectories (except the packages which are folder names starting with "+"),
* the library `$ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX/mex/+wbc/simulink`.
* the library `$ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX/mex/+wbc/simulink`,
* the controller model examples `$ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX/mex/+wbc/examples`.

#### Start MATLAB from the launcher or the application menu

Expand All @@ -292,6 +293,7 @@ You could add this line to your MATLAB script that uses the robotology-superbuil
~~~
addpath(['<ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX>' '/mex'])
addpath(['<ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX>' '/mex/+wbc/simulink'])
addpath(['<ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX>' '/mex/+wbc/examples'])
addpath(['<ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX>' '/share/WBToolbox'])
addpath(['<ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX>' '/share/WBToolbox/images'])
~~~
Expand Down
1 change: 1 addition & 0 deletions doc/environment-variables-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export GAZEBO_RESOURCE_PATH=${GAZEBO_RESOURCE_PATH}:${ROBOTOLOGY_SUPERBUILD_INST
For adding the multiple libraries to the MATLAB path, the environment variable `MATLABPATH` has to be appended with the following robotology-superbuild related directories:
* `$ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX/mex`
* `$ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX/mex/+wbc/simulink`
* `$ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX/mex/+wbc/examples`
* `$ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX/share/WBToolbox`
* `$ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX/share/WBToolbox/images`

Expand Down
19 changes: 10 additions & 9 deletions scripts/install_robotology_packages.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@ function install_robotology_packages(varargin)
default_install_prefix = fullfile(pwd,'robotology-matlab');
addOptional(p,'installPrefix', default_install_prefix);
parse(p,varargin{:});

% Build package installation directory
install_prefix = p.Results.installPrefix;

setup_script = fullfile(pwd, 'robotology_setup.m');

if exist(install_prefix)
fprintf('Directory %s already present. Please use it or delete to proceed with the install', install_prefix);
return;
end

fprintf('Installing robotology MATLAB/Simulink binaries in %s\n', install_prefix);

% The install url is created following
% The install url is created following
mambaforge_url_prefix = 'https://github.com/conda-forge/miniforge/releases/latest/download/';
if ispc
mambaforge_installer_name = 'Mambaforge-Windows-x86_64.exe';
Expand All @@ -35,7 +35,7 @@ function install_robotology_packages(varargin)
uname_m = strip(uname_m);
mambaforge_installer_name = sprintf('Mambaforge-%s-%s.sh', uname, uname_m);
end

fprintf('Downloading mambaforge installer \n');
mambaforge_installer_url = strcat(mambaforge_url_prefix, mambaforge_installer_name);
websave(mambaforge_installer_name, mambaforge_installer_url);
Expand All @@ -55,21 +55,21 @@ function install_robotology_packages(varargin)
robotology_install_prefix = install_prefix;
end
fprintf('Installation of mambaforge completed\n');



if ~exist(install_prefix, 'dir')
fprintf('Installation in %s failed for unknown reason, please open an issue at https://github.com/robotology/robotology-superbuild/issues/new\n', install_prefix);
return;
end

% Install all the robotology packages related to MATLAB or Simulink
fprintf('Installing robotology packages\n');
system(sprintf('%s install -y -c conda-forge -c robotology yarp-matlab-bindings idyntree wb-toolbox osqp-matlab whole-body-controllers matlab-whole-body-simulator icub-models', conda_full_path));
system(sprintf('%s install -y -c conda-forge -c robotology yarp-matlab-bindings idyntree wb-toolbox osqp-matlab whole-body-controllers matlab-whole-body-simulator icub-models', conda_full_path));
fprintf('Installation of robotology packages completed\n');

fprintf('Creating setup script in %s', setup_script);
% Generate robotology_setup.m
% Generate robotology_setup.m
setupID = fopen(setup_script,'w');
fprintf(setupID, '%% Specify OS-specific locations\n');
fprintf(setupID, 'if ispc\n');
Expand All @@ -86,6 +86,7 @@ function install_robotology_packages(varargin)
fprintf(setupID, '%% Add directory to MATLAB path\n');
fprintf(setupID, 'addpath(fullfile(robotology_install_prefix,"mex"));\n');
fprintf(setupID, 'addpath(fullfile(robotology_install_prefix,"mex/+wbc/simulink"));\n');
fprintf(setupID, 'addpath(fullfile(robotology_install_prefix,"mex/+wbc/examples"));\n');
fprintf(setupID, 'addpath(fullfile(robotology_install_prefix,"share/WBToolbox"));\n');
fprintf(setupID, 'addpath(fullfile(robotology_install_prefix,"share/WBToolbox/images"));\n');
fprintf(setupID, '\n');
Expand Down

0 comments on commit d94d8ca

Please sign in to comment.