-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Export MATLABPATH from the setup scripts #160
Conversation
@gabrielenava @nunoguedelha What do you thinkg about this? |
README.md
Outdated
#### Start MATLAB from the terminal | ||
|
||
You can add the folders by modifying the `startup.m` or the `MATLABPATH` environmental variable [as described in official MATLAB documentation](https://www.mathworks.com/help/matlab/matlab_env/add-folders-to-matlab-search-path-at-startup.html). | ||
In you are using the `setup.sh` script for configuring your environment, `MATLABPATH` is automatically populated with these directories. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In you are using the `setup.sh` script for configuring your environment, `MATLABPATH` is automatically populated with these directories. | |
In you are using the `setup.sh` or `setup.bat` script for configuring your environment, `MATLABPATH` is automatically populated with these directories. |
If I understand correctly, |
To use this software, you can simply enable its compilation using the `ROBOTOLOGY_USES_MATLAB` CMake option. | ||
Once this software has been compiled by the superbuild, you just need to add some directories of the robotology-superbuild install (typically `$ROBOTOLOGY_SUPERBUILD_ROOT/build/install`) to [the MATLAB path](https://www.mathworks.com/help/matlab/matlab_env/what-is-the-matlab-search-path.html). | ||
In particular you need to add to the MATLAB path the `$ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX/mex` directory and all the subdirectories `$ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX/share/WBToolbox`. | ||
|
||
As an example, you could add this line to your MATLAB script that uses the robotology-superbuild matlab software: | ||
#### Start MATLAB from the launcher or the application menu |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this may be misleading. If MATLAB is launched from launcher of the application menu, who is setting the ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX
env var? @gabrielenava @nunoguedelha any opinion?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I personally never used that script, I know that @gabrielenava does use it, let's wait his feedback.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Btw, those instructions were there before, probably they had to be updated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually never started Matlab from the launcher. On a new installation, I always run the startup_robotology_superbuild.m
. However, note that if one uses the startup_robotology_superbuild.m
, it is required to open matlab from the folder where the `pathdef.m file is, otherwise the required folders are not added to the path.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, if I understood, with this PR it will be possible to set the required Matlab path using the setup.sh
file instead/ as an alternative to:
-
manually add the required folder to the MATLABPATH;
-
run the
startup_robotology_superbuild.m
if theWBToolbox
is installed through therobotology-superbuild
, or thestartup.m
file if theWBToolbox
is external to the superbuild. Note that as I said before, if the user decides to choose this last method it is required to always start matlab from the folder where thepathdef.m
file is. This is not necessary (as far as I understood, as I always followed this third option) if the user decides to choose one of the other two options.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we please open new issue if problem exist instead of posting in closed issues? :''(
Sorry, I was confused by the old issue, the problem is discussed in #64 .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just have a question, if two projects need the pathdef.m
, is there any possibility that the second project overrides the file created by the first?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just have a question, if two projects need the
pathdef.m
, is there any possibility that the second project overrides the file created by the first?
Short answer would be "Yes", but I' not sure what you mean, so here is a short explanation of how pathdef.m
is handled...
A pathdef.m
file is created or overwritten whenever:
- you hit "save" in the MATLAB "set path" menu window -> the file is then created or overwritten in the folder defined by the
userpath
MATLAB function, - whenever you execute in MATLAB the command
savepath
, and providing the target file explicitely: for instancesavepath([fileDir, filesep, 'pathdef.m'])
.
The pathdef.m
used is the the one located in the same folder where you launch MATLAB from.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that as far as I know this issue still occurs on Ubuntu 18.04, therefore even running the
setup.sh
file the user will have to manually address this before being able to use the toolbox properly....
then if the user does not run matlab from the folder where thepathdef.m
is, he will be able to useWBToolbox
but notwhole-body-controllers
.I think from the Simulink controllers point that's it.
Just to clarify, the constraint on where we launch MATLAB from is applicable only if we launch MATLAB from the terminal, and that section mentions running a startup.m
file and gives a reference to the MATLAB documentation.
WARNING: we are mixing things here. The startup.m
file the MATLAB documentation refers to is a special file that doesn't have to be explicitely run by the user, but is loaded at startup under certain conditions (the MATLAB documentation is not clear about this. I documented it in a wiki here and in my comments about launching MATLAB from the terminal). If the file name has that exact syntax and is found by MATLAB, it will be executed at startup.
If some startup file like the one from the superbuild or the one from the WB-toolbox creates a pathdef.m
in the folder defined by userpath
, then it will always be loaded at startup when MATLAB is launched from the GUI in MacOS (from the launchpad or "Applications" Finder folder).
I don't know how it works on Linux but I assume you can configure the startup folder in the properties of the shortcut you create for MATLAB.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regarding MATLABPATH...
On MacOS: when launching MATLAB application through the GUI (launchepad,...), the usual way to set environment variables (MATLABPATH=<some path>
) has no effect. You need to use the command launchctl setenv <variable> <value>
as documented in my wiki, adding to the ~/.bash_profile
the lines:
export MATLABPATH=<some-path>
launchctl setenv MATLABPATH $MATLABPATH
I updated the instructions, imho we cover too many cases and this might create confusion. However, this would worth a separate discussion. |
CMakeLists.txt
Outdated
@@ -132,6 +132,7 @@ if(ROBOTOLOGY_ENABLE_DYNAMICS) | |||
endif() | |||
if(ROBOTOLOGY_USES_MATLAB) | |||
if(NOT ROBOTOLOGY_NOT_USE_SIMULINK) | |||
set(ROBOTOLOGY_USES_SIMULINK TRUE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This logic is quite strange to me, isn't it better to have just a variable called "ROBOTOLOGY_USES_SIMULINK" instead of "ROBOTOLOGY_USES_SIMULINK" and "ROBOTOLOGY_NOT_USE_SIMULINK"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The rationale for this is described in the readme at https://github.com/robotology/robotology-superbuild/blob/98500f5f57fff4d14044379e0edd4a8f1d3bbd33/README.md#system-dependencies-7 . Basically, based on my limited experience the vast majority of our users have Matlab+Simulink installed on their computer, so we just require them to set ROBOTOLOGY_USES_MATLAB
to TRUE
to enable both software that requires MATLAB and software that requires Simulink. There are (a few, fortunatly) cases in which the user has matlab but no Simulink: in that case, the user select the additional option ROBOTOLOGY_NOT_USE_SIMULINK
(that default to false) to avoid compiling the software that depends on Simulink.
I don't think that adding a ROBOTOLOGY_USES_SIMULINK
and requiring all users to set it to ON
manually in addition to ROBOTOLOGY_USES_MATLAB
would be helpful.
See robotology-legacy/codyco-superbuild#65 (comment) for when the option was added. The r
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gabrielenava I add to Silvio's reply that due to limitations of the cmakeif
command that you can find in the scripts, specifying a condition (e.g. cmakeif NOT MYVAR
) is not supported. After cmakeif
there must be a single cmake variable that can be either TRUE
or FALSE
. For this reason I had to introduce this extra ROBOTOLOGY_USES_SIMULINK
variable.
To use this software, you can simply enable its compilation using the `ROBOTOLOGY_USES_MATLAB` CMake option. | ||
Once this software has been compiled by the superbuild, you just need to add some directories of the robotology-superbuild install (typically `$ROBOTOLOGY_SUPERBUILD_ROOT/build/install`) to [the MATLAB path](https://www.mathworks.com/help/matlab/matlab_env/what-is-the-matlab-search-path.html). | ||
In particular you need to add to the MATLAB path the `$ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX/mex` directory and all the subdirectories `$ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX/share/WBToolbox`. | ||
|
||
As an example, you could add this line to your MATLAB script that uses the robotology-superbuild matlab software: | ||
#### Start MATLAB from the launcher or the application menu |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually never started Matlab from the launcher. On a new installation, I always run the startup_robotology_superbuild.m
. However, note that if one uses the startup_robotology_superbuild.m
, it is required to open matlab from the folder where the `pathdef.m file is, otherwise the required folders are not added to the path.
To use this software, you can simply enable its compilation using the `ROBOTOLOGY_USES_MATLAB` CMake option. | ||
Once this software has been compiled by the superbuild, you just need to add some directories of the robotology-superbuild install (typically `$ROBOTOLOGY_SUPERBUILD_ROOT/build/install`) to [the MATLAB path](https://www.mathworks.com/help/matlab/matlab_env/what-is-the-matlab-search-path.html). | ||
In particular you need to add to the MATLAB path the `$ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX/mex` directory and all the subdirectories `$ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX/share/WBToolbox`. | ||
|
||
As an example, you could add this line to your MATLAB script that uses the robotology-superbuild matlab software: | ||
#### Start MATLAB from the launcher or the application menu |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, if I understood, with this PR it will be possible to set the required Matlab path using the setup.sh
file instead/ as an alternative to:
-
manually add the required folder to the MATLABPATH;
-
run the
startup_robotology_superbuild.m
if theWBToolbox
is installed through therobotology-superbuild
, or thestartup.m
file if theWBToolbox
is external to the superbuild. Note that as I said before, if the user decides to choose this last method it is required to always start matlab from the folder where thepathdef.m
file is. This is not necessary (as far as I understood, as I always followed this third option) if the user decides to choose one of the other two options.
To use this software, you can simply enable its compilation using the `ROBOTOLOGY_USES_MATLAB` CMake option. | ||
Once this software has been compiled by the superbuild, you just need to add some directories of the robotology-superbuild install (typically `$ROBOTOLOGY_SUPERBUILD_ROOT/build/install`) to [the MATLAB path](https://www.mathworks.com/help/matlab/matlab_env/what-is-the-matlab-search-path.html). | ||
In particular you need to add to the MATLAB path the `$ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX/mex` directory and all the subdirectories `$ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX/share/WBToolbox`. | ||
|
||
As an example, you could add this line to your MATLAB script that uses the robotology-superbuild matlab software: | ||
#### Start MATLAB from the launcher or the application menu |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that as far as I know this issue still occurs on Ubuntu 18.04, therefore even running the setup.sh
file the user will have to manually address this before being able to use the toolbox properly.
Also, there are two things that should be properly documented:
-
again: that if the user choose to run the
startup.m
orstartup_robotology_superbuild.m
it is required to always run Matlab from the folder where thepathdef.m
is; -
I recently decided to convert the whole-body-controllers library in a package that can be pointed by the matlab path and used by any Simulink model in any folder. This implies that the user that wants to use
whole-body-controllers
also need to follow these instructions. Note that there are 2 possibilities: manually add the library to the matlabpath or run yet-another-one startup.m script. If the user does the following combo:
-
WBToolbox: set the required Matlab path using the setup.sh or manually add the required folders to the MATLABPATH;
-
wbc library: run the
startup.m
;
then if the user does not run matlab from the folder where the pathdef.m
is, he will be able to use WBToolbox
but not whole-body-controllers
.
I think from the Simulink controllers point that's it.
addpath([getenv('ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX') '/share/WBToolbox']) | ||
addpath('<ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX>' '/mex']) | ||
addpath('<ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX>' '/share/WBToolbox']) | ||
addpath('<ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX>' '/share/WBToolbox/images']) | ||
~~~ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I reviewed a bit the section, and I think we can just remove this addpath
calls in this section (if someone is interested in those, they are already described in the previous section), and just leave the docs on how to run startup_robotology_superbuild.m
under "Start MATLAB from the launcher or the application menu". This removes the ambiguity of using ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX
env variable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I did not realized that you stopped using getenv
. Then I think we can go forward with the PR (as soon as @gabrielenava and @nunoguedelha green light it) and do more cleanup in separate PRs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would consider separately the case where :
- the
<ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX>/mex
folder is required -> always when MATLAB is used and we plan to use MATLAB bindings, - the
.../share/WBToolbox
and.../share/WBToolbox/images
folder is required -> always when Simulink is used.
@gabrielenava if the usage procedure of |
@gabrielenava In general, if you think this PR is an improvements and is not going to create problems, let's approve it. Furthere improvements/bug fix can done in subsequent PRs. |
@traversaro Addressed your comments, let me know when I have green light and I will perform an interactive rebase. |
Thanks @diegoferigo . I would wait for the approval of @gabrielenava and @nunoguedelha . |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refer to embedded comments.
#### Start MATLAB from the terminal | ||
|
||
You can add the folders by modifying the `startup.m` or the `MATLABPATH` environmental variable [as described in official MATLAB documentation](https://www.mathworks.com/help/matlab/matlab_env/add-folders-to-matlab-search-path-at-startup.html). | ||
If you are using the `setup.sh` or `setup.bat` script for configuring your environment, `MATLABPATH` is automatically populated with these directories. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be specified here that if the setup.sh
script is used instead of editing the ~/.bash_profile
, the following requirements apply:
- for the environment variables to be set in any new opened terminal, the line
source setup.sh
has to be added to thebash_profile
, - for the MATLABPATH variable to be imported in any future sessions of MATLAB, the MATLAB application has to be run from new terminal, or a terminal where that variable has already been set.
~~~ | ||
Anyway we strongly suggest that you add this directories to the MATLAB path in robust way, | ||
for example by modifying the `startup.m` or the `MATLABPATH` enviromental variable [as described in official MATLAB documentation](https://www.mathworks.com/help/matlab/matlab_env/add-folders-to-matlab-search-path-at-startup.html). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not explained in the MATLAB documentation how the startup.m
file is handled by MATLAB at startup. I documented it further in a personal wiki, Matlab Search Path (for now).
In a few words...
A single and only startup.m
is processed by MATLAB at startup, and it is the first found by the application, in the following search order:
- local folder from where Matlab is launched,
- folder defined by 'userpath',
- folder defined by 'MATLABPATH' variable.
That order can be fully redefined in a pathdef.m
function file, which is loaded only if MATLAB is launched from the same parent folder as the pathdef.m
file.
In case the startup.m
file is found, the respective defined paths (through addpath
statements) are added to the top of the MATLAB path, and this, whatever method we use to launch MATLAB, and whether the pathdef.m
file is used or not at startup.
addpath([getenv('ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX') '/share/WBToolbox']) | ||
addpath('<ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX>' '/mex']) | ||
addpath('<ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX>' '/share/WBToolbox']) | ||
addpath('<ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX>' '/share/WBToolbox/images']) | ||
~~~ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would consider separately the case where :
- the
<ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX>/mex
folder is required -> always when MATLAB is used and we plan to use MATLAB bindings, - the
.../share/WBToolbox
and.../share/WBToolbox/images
folder is required -> always when Simulink is used.
To use this software, you can simply enable its compilation using the `ROBOTOLOGY_USES_MATLAB` CMake option. | ||
Once this software has been compiled by the superbuild, you just need to add some directories of the robotology-superbuild install (typically `$ROBOTOLOGY_SUPERBUILD_ROOT/build/install`) to [the MATLAB path](https://www.mathworks.com/help/matlab/matlab_env/what-is-the-matlab-search-path.html). | ||
In particular you need to add to the MATLAB path the `$ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX/mex` directory and all the subdirectories `$ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX/share/WBToolbox`. | ||
|
||
As an example, you could add this line to your MATLAB script that uses the robotology-superbuild matlab software: | ||
#### Start MATLAB from the launcher or the application menu |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just have a question, if two projects need the
pathdef.m
, is there any possibility that the second project overrides the file created by the first?
Short answer would be "Yes", but I' not sure what you mean, so here is a short explanation of how pathdef.m
is handled...
A pathdef.m
file is created or overwritten whenever:
- you hit "save" in the MATLAB "set path" menu window -> the file is then created or overwritten in the folder defined by the
userpath
MATLAB function, - whenever you execute in MATLAB the command
savepath
, and providing the target file explicitely: for instancesavepath([fileDir, filesep, 'pathdef.m'])
.
The pathdef.m
used is the the one located in the same folder where you launch MATLAB from.
~~~ | ||
Anyway we strongly suggest that you add this directories to the MATLAB path in robust way, | ||
for example by modifying the `startup.m` or the `MATLABPATH` enviromental variable [as described in official MATLAB documentation](https://www.mathworks.com/help/matlab/matlab_env/add-folders-to-matlab-search-path-at-startup.html). | ||
|
||
Another way is to run (only once) the script `startup_robotology_superbuild.m` in the `$ROBOTOLOGY_SUPERBUILD_ROOT/build` folder. This should be enough to permanently add the required paths for all the toolbox that use MATLAB. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note:
The pathdef.m
is saved in the path userpath
. In MacOS, when the application launched from the launchpad, the startup folder is defined by userpath
also. For this reason it is necessary that the userpath
value has not been changed since the moment when startup_robotology_superbuild.m
script was run in a previous MATLAB session. But it's unlikely that it happens unless the user knows what he's doing...
To use this software, you can simply enable its compilation using the `ROBOTOLOGY_USES_MATLAB` CMake option. | ||
Once this software has been compiled by the superbuild, you just need to add some directories of the robotology-superbuild install (typically `$ROBOTOLOGY_SUPERBUILD_ROOT/build/install`) to [the MATLAB path](https://www.mathworks.com/help/matlab/matlab_env/what-is-the-matlab-search-path.html). | ||
In particular you need to add to the MATLAB path the `$ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX/mex` directory and all the subdirectories `$ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX/share/WBToolbox`. | ||
|
||
As an example, you could add this line to your MATLAB script that uses the robotology-superbuild matlab software: | ||
#### Start MATLAB from the launcher or the application menu |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that as far as I know this issue still occurs on Ubuntu 18.04, therefore even running the
setup.sh
file the user will have to manually address this before being able to use the toolbox properly....
then if the user does not run matlab from the folder where thepathdef.m
is, he will be able to useWBToolbox
but notwhole-body-controllers
.I think from the Simulink controllers point that's it.
Just to clarify, the constraint on where we launch MATLAB from is applicable only if we launch MATLAB from the terminal, and that section mentions running a startup.m
file and gives a reference to the MATLAB documentation.
WARNING: we are mixing things here. The startup.m
file the MATLAB documentation refers to is a special file that doesn't have to be explicitely run by the user, but is loaded at startup under certain conditions (the MATLAB documentation is not clear about this. I documented it in a wiki here and in my comments about launching MATLAB from the terminal). If the file name has that exact syntax and is found by MATLAB, it will be executed at startup.
If some startup file like the one from the superbuild or the one from the WB-toolbox creates a pathdef.m
in the folder defined by userpath
, then it will always be loaded at startup when MATLAB is launched from the GUI in MacOS (from the launchpad or "Applications" Finder folder).
I don't know how it works on Linux but I assume you can configure the startup folder in the properties of the shortcut you create for MATLAB.
|
||
@cmakeif ROBOTOLOGY_USES_MATLAB | ||
rem Configure the Matlab | ||
set "MATLABPATH=%MATLABPATH%;%ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX%/mex;%ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX%/share/WBToolbox;%ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX%/share/WBToolbox/images" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the System Dependencies section we have:
Note: tipically we assume that a user that selects the
ROBOTOLOGY_USES_MATLAB
also has Simulink installed in his computer.
If this is not the case, you can enable the advanced CMake optionROBOTOLOGY_NOT_USE_SIMULINK
to compile all the subprojects that depend on MATLAB, but disable the subprojecs that depend on Simulink (i.e. the
wb-toolbox Simulink Library) if you have enabled theROBOTOLOGY_ENABLE_DYNAMICS
CMake options.
So why in the robotology-superbuild/CMakeLists.txt
is the WB-Toolbox downloaded and compiled outside the ROBOTOLOGY_USES_MATLAB
option flag. Shouldn't it be in the if(ROBOTOLOGY_USES_MATLAB)...if(NOT ROBOTOLOGY_NOT_USE_SIMULINK)
section, along with the whole-body-controllers
?
...and MATLABPATH content should reflect that.
#### Start MATLAB from the terminal | ||
|
||
You can add the folders by modifying the `startup.m` or the `MATLABPATH` environmental variable [as described in official MATLAB documentation](https://www.mathworks.com/help/matlab/matlab_env/add-folders-to-matlab-search-path-at-startup.html). | ||
If you are using the `setup.sh` or `setup.bat` script for configuring your environment, `MATLABPATH` is automatically populated with these directories. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bottom line, the best would be to:
- either use a
startup.m
file located inuserpath
(it's actually the most portable and systematic solution), either the environment variable we set in the~/.bashrc
or~/.bash_profile
in a way it is visible for MATLAB launched from terminal or launchpad(*). - append to the file or the variable, through the
setup.sh
, whatever path dependencies are needed.
I think that for the sake of simplicity, a common chosen method (valid for both ways of launching MATLAB) should be "enforced" and the remaining methods presented as options.
(*) for MacOS, launchctl
does the deal. I have no idea how it works on Linux or Windows.
I think @nunoguedelha and @gabrielenava raise super-interesting points, that for the large part actually applies to the README before this PR. As several of this modifications are probably not necessary once we do a general cleanup of the Matlab part of the README (see for example all the section commented in #160 (comment)) I would be inclined to go forward and merge this PR, and then incorporate all the feedback in the cleanup of the Matlab section of the README. What do you think @nunoguedelha @gabrielenava ? |
I agree. Concerning the |
Perfect timing :-) |
@traversaro I agree, let's discuss what is the best approach in another issue. From what I understood, also thanks to @nunoguedelha and @gabrielenava comments, there is no optimal solution. All of them have some drawback. I define optimal solution the one that meets the following features:
|
As discussed with @nunoguedelha f2f, we can merge this in its current form. @diegoferigo do you want to cleanup the commits? Otherwise I can merge in its current form. |
Using the .m script is useful especially when Matlab is executed the desktop file. Instead, when it is opened from the command line, exporting this env var is enough.
I squashed what I had to squash, ready to go 👍 |
This PR introduces the possibility of configuring the environment in such a way that if Matlab is executed from the terminal and the setup scripts are used, no manual actions are required.
Note that I only tested the behavior in Ubuntu.
Related to #159 (comment).