The way we need to generate library paths with env.sh seem really clunky - basically, I either need to use the folder
{acados}/examples/acados_matlab_octave/my_example
to store my own examples, or modify this file by hand…
And if I’m doing that, woudln’t there be a better solution, once I know where my acados is? Thus far I’ve simply hard-coded the path to acados folder, but still run the env.sh every time before opening matlab…
Can we instead place this somewhere in bash and make it run once our system starts? What would be the downsides of that? (sorry, I’m not an expert in Linux)
Hello Anton,
You are totally free to add acados related to your ~/.bashrc or equivalent,
the env.sh was meant to work in the general case without requiring users to mess with their shell configuration files.
For more involved users the natural next step is to add lines or includes in ~/.bashrc
I would add something like:
export ACADOS_INSTALL_DIR=<your/acados/path/(the one cotaining lib/ and include/)>
export ACADOS_SOURCE_DIR=<your/acados_source/path>
# casadi and mex path
export MATLABPATH=$MATLABPATH:$ACADOS_SOURCE_DIR/external/casadi-matlab/
export MATLABPATH=$MATLABPATH:$ACADOS_SOURCE_DIR/interfaces/acados_matlab_octave/
export MATLABPATH=$MATLABPATH:$ACADOS_SOURCE_DIR/interfaces/acados_matlab_octave/acados_template_mex/
# acados shared library
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ACADOS_INSTALL_DIR/lib
# ocp description and non-linear functions libraries
MODELS=('<path/to/ocp1' '<path/to/ocp2>' '...' ) # assuming ocp descriptions are not necessarily in the acados/examples folder
for MODEL in "${MODELS[@]}"; do export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$MODEL/build; done
I agree this is not so “elegant”, but it the only thing we are aware of which can work with MATLAB,
if you know how to set those environment variables (in order to be accessible to the linker ) from MATLAB please let us know
This script runs before MATLAB links to the libraries specified in LD_LIBRARY_PATH. So when I launch MATLAB now, the environment variables are set as required by acados.
Maybe you could add some procedure to acados’ installation that perform above steps automatically / adds the lines to MATLAB’s .matlab7rc.sh script. Then the procedure of sourcing the env.sh is not required to be performed by the user.