Coder Social home page Coder Social logo

ami-iit / mystica Goto Github PK

View Code? Open in Web Editor NEW
9.0 6.0 0.0 142 KB

mystica is a Matlab library for simulating multi-body robots relying on a maximal coordinate approach

License: BSD 3-Clause "New" or "Revised" License

MATLAB 99.62% Objective-C 0.30% M 0.08%
matlab multibody-simulation parallel-robot robotics casadi

mystica's Introduction

mystica

Size CI

Multi bodY SimulaTor maxImal CoordinAtes

mystica is a MATLAB library to simulate the kinematics and dynamics of multibody systems. mystica computes the system evolution by modeling the problem using a state definition that we define maximal. The maximal representation consists of a set of non-minimum variables πͺ complemented by the holonomic constraint g(πͺ) = 0.


⚠️ REPOSITORY UNDER DEVELOPMENT ⚠️
The libraries implemented in this repository are still experimental, and we cannot guarantee a stable API.


Table of Contents

πŸ”¨ Dependencies

Other requisites are:

Both CasADi and yamlmatlab are downloaded and configured in the Installation section.

πŸ’Ύ Installation

  1. Clone the repo:
git clone https://github.com/ami-iit/mystica.git
cd mystica
  1. Run the install() function in MATLAB.
install()

The install() function downloads mambaforge. mambaforge is a package manager that downloads and configures our dependencies in a conda environment called mystica.

If you already have mambaforge If you already have mambaforge configured, you can call the install() function by defining the mambaforge_prefix value:
install('mambaforge_prefix',<your mambaforge path prefix>)

⚠️ Known issue For some versions of Ubuntu and MATLAB, MATLAB is not able to load the required libraries like CasADi (see issue). A possible workaround is to launch matlab with LD_PRELOAD:

LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libstdc++.so.6 matlab

πŸš€ Usage

Before every usage, remember to run the autogenerated MATLAB file called deps/setup.m to set up the MATLABPATH.

Alternatively, you can launch MATLAB from the terminal after activating the conda environment called mystica:

conda activate mystica
matlab

Here's a snippet of code to simulate the kinematics of a 4-bar linkage mechanism:

model = mystica.model.getModel4BarLinkage();
stgs = mystica.stgs.getDefaultSettingsSimKinRel(model);
data = mystica.runSimKinRel('model', model, 'stgs', stgs, 'mBodyPosQuat_0', model.getMBodyPosQuatRestConfiguration, 'nameControllerClass', 'mystica.controller.ExampleKinRel');
mystica.viz.visualizeKinRel('model', model, 'data', data, 'stgs', stgs)

Other examples can be found in the examples directory.

If you want to delve deeper into the code, we have prepared this document as an entry point to explain and describe our variables.

βš™οΈ Contributing

mystica is an open-source project, and is thus built with your contributions. We strongly encourage you to open an issue with your feature request. Once the issue has been opened, you can also proceed with a pull-request. πŸš€

Citing this work

If you find the work useful, please consider citing:

@ARTICLE{9793615,
  author={Bergonti, Fabio and Nava, Gabriele and Fiorio, Luca and L’Erario, Giuseppe and Pucci, Daniele},
  journal={IEEE Transactions on Robotics},
  title={Modeling and Control of Morphing Covers for the Adaptive Morphology of Humanoid Robots},
  year={2022},
  volume={38},
  number={5},
  pages={3300-3313},
  doi={10.1109/TRO.2022.3170281}}

Maintainer

This repository is maintained by:

@FabioBergonti

Size CI

mystica's People

Contributors

danielepucci avatar fabiobergonti avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

mystica's Issues

Error installing casadi via mystica in linux

@FabioBergonti commented on Wed May 18 2022

I tried to install mystica on a linux machine (see documentation).
I ran the autogenerated deps/setup.m file that configure matlabpath (see documentation)
But when I call a basic casadi function I got an error

>> casadi.SX.sym('x')
Invalid MEX-file '/home/icub/Software/fbergonti/mystica/deps/envs/imorph/mex/casadiMEX.mexa64':
/usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.26' not found (required by
/home/icub/Software/fbergonti/mystica/deps/envs/imorph/mex/casadiMEX.mexa64)

Error in casadi.GenSX.sym (line 432)
     [varargout{1:nargout}] = casadiMEX(315, varargin{:});

@FabioBergonti commented on Wed May 18 2022

Here the autogenerated setup.m

% Specify OS-specific locations
if ispc
    env_sep = ";";
else
    env_sep = ":";
end

% Install prefix (hardcoded at generation time)
pckgs_install_prefix = "/home/icub/Software/fbergonti/mystica/deps/envs/imorph";
install_prefix       = "/home/icub/Software/fbergonti/mystica/deps";
mystica_fullpath     = "/home/icub/Software/fbergonti/mystica";

% AddPath packages installed with conda
addpath(fullfile(pckgs_install_prefix,"mex"));

% AddPath github repositories
addpath(fullfile(install_prefix,"yamlmatlab"));

% AddPath mystica
addpath(mystica_fullpath);

% Add to the env:"PATH" the directory with the packages installed with conda
setenv("PATH",strcat(fullfile(pckgs_install_prefix,"bin"), env_sep, getenv("PATH")));

@FabioBergonti commented on Wed May 18 2022

@traversaro
Have you ever seen something similar?


@traversaro commented on Wed May 18 2022

It is probably an incompatibility problem between libstdc++ of either:

  • MATLAB
  • System
  • conda-forge

Can you provide more info (operating system, mamba list, MATLAB version) to simplify the debugging?


@traversaro commented on Wed May 18 2022

Related errors:


@FabioBergonti commented on Thu May 19 2022

Hi @traversaro
Here the requested info

  • mamba list
# packages in environment at /home/ironcub/code/fbergonti/mystica/deps/envs/mystica:
#
# Name                    Version                   Build  Channel
_libgcc_mutex             0.1                 conda_forge    conda-forge
_openmp_mutex             4.5                       2_gnu    conda-forge
ampl-mp                   3.1.0             h2cc385e_1006    conda-forge
bzip2                     1.0.8                h7f98852_4    conda-forge
ca-certificates           2022.5.18            ha878542_0    conda-forge
casadi                    3.5.5           py310h597d7ca_9    conda-forge
casadi-matlab-bindings    3.5.5.2             h27087fc_53    robotology
ipopt                     3.14.6               h630875f_0    conda-forge
ld_impl_linux-64          2.36.1               hea4e1c9_2    conda-forge
libblas                   3.9.0           14_linux64_openblas    conda-forge
libcblas                  3.9.0           14_linux64_openblas    conda-forge
libedit                   3.1.20191231         he28a2e2_2    conda-forge
libffi                    3.4.2                h7f98852_5    conda-forge
libgcc-ng                 12.1.0              h8d9b700_16    conda-forge
libgfortran-ng            12.1.0              h69a702a_16    conda-forge
libgfortran5              12.1.0              hdcd56e2_16    conda-forge
libgomp                   12.1.0              h8d9b700_16    conda-forge
libiconv                  1.16                 h516909a_0    conda-forge
liblapack                 3.9.0           14_linux64_openblas    conda-forge
libnsl                    2.0.0                h7f98852_0    conda-forge
libopenblas               0.3.20          pthreads_h78a6416_0    conda-forge
libosqp                   0.6.2                h9c3ff4c_3    conda-forge
libstdcxx-ng              12.1.0              ha89aaad_16    conda-forge
libuuid                   2.32.1            h7f98852_1000    conda-forge
libzlib                   1.2.11            h166bdaf_1014    conda-forge
metis                     5.1.0             h58526e2_1006    conda-forge
mumps-include             5.2.1               ha770c72_11    conda-forge
mumps-seq                 5.2.1               h2104b81_11    conda-forge
ncurses                   6.3                  h27087fc_1    conda-forge
numpy                     1.22.3          py310h4ef5377_2    conda-forge
openssl                   3.0.3                h166bdaf_0    conda-forge
pip                       22.1               pyhd8ed1ab_0    conda-forge
python                    3.10.4          h2660328_0_cpython    conda-forge
python_abi                3.10                    2_cp310    conda-forge
readline                  8.1                  h46c0cb4_0    conda-forge
scotch                    6.0.9                hb2e6521_2    conda-forge
setuptools                62.3.1          py310hff52083_0    conda-forge
sqlite                    3.38.5               h4ff8645_0    conda-forge
tk                        8.6.12               h27826a3_0    conda-forge
tzdata                    2022a                h191b570_0    conda-forge
unixodbc                  2.3.10               h583eb01_0    conda-forge
wheel                     0.37.1             pyhd8ed1ab_0    conda-forge
xz                        5.2.5                h516909a_1    conda-forge
zlib                      1.2.11            h166bdaf_1014    conda-forge
  • system: Ubuntu 20.04.3 LTS
  • matlab: r2020b

@traversaro commented on Thu May 19 2022

So, GLIBCXX_3.4.26 was added in gcc/libstcxx in 2018 : https://github.com/gcc-mirror/gcc/blob/master/libstdc%2B%2B-v3/ChangeLog-2018#L1072 and release in GCC 9.1 that was released in May 2019 (see https://gcc.gnu.org/gcc-9/). Apparently casadiMEX.so requires at least that version, but something is not providing it.

I have a version similar to yours, and I tried to see which version of libstdcxx is not providing it.

The apt version has ~430 symbols with that version:

readelf -s /usr/lib/x86_64-linux-gnu/libstdc++.so.6 | grep "GLIBCXX_3.4.26" | wc -l

The conda version has ~431 symbols

(casadi) traversaro@IITICUBLAP257:~/mambaforge/envs/casadi/lib$ readelf -s $CONDA_PREFIX/lib/libstdc++.so.6 | grep "GLIB
CXX_3.4.26" | wc -l
431

The MATLAB vendored version has ~0 symbols:

readelf -s /usr/local/MATLAB/R2020b/sys/os/glnxa64/libstdc++.so.6.0.25 | grep "GLIBCXX_3.4.26" | wc -l
0

So, it is clear that the problem is in the MATLAB vendored version that is not new enough, i.e. the problem usually described in robotology/robotology-superbuild#64 , I think it can be solved with one of this three tricks that are widespread in the lab:

  • Install the matlab-support package with apt (sudo apt install matlab-support, I am not sure this actually works)
  • Always launch matlab with LD_PRELOAD, i.e. add
alias matlab="LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libstdc++.so.6 matlab"

in .bashrc

  • Rename /usr/local/MATLAB/R2020b/sys/os/glnxa64/libstdc++.so.6 to /usr/local/MATLAB/R2020b/sys/os/glnxa64/libstdc++.so.6.back

@FabioBergonti commented on Thu May 19 2022

I tried to run matlab with LD_PRELOAD

LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libstdc++.so.6 matlab

and it worked πŸŽ‰πŸŽ‰

Thanks @traversaro


@FabioBergonti commented on Thu May 19 2022

I opened a PR in mystica to document this problem #5
Closing this issue


@FabioBergonti commented on Fri May 20 2022

I continued the investigation by installing only casadi via mamba.

mamba create -p casadi
mamba activate ./casadi
mamba install -y -c conda-forge -c robotology casadi-matlab-bindings "libblas=*=*openblas"
matlab

I executed this test with these machines:

  • iiticubws022 with Ubuntu 20.04.3 LTS and Matlab R2021a
    casadi worked without the need of running matlab with LD_PRELOAD
  • iiticubws050 with Ubuntu 18.04.6 LTS and Matlab R2019b
    it didn't work even with LD_PRELOAD. I got the same error
>> casadi.SX.sym('x')
Invalid MEX-file '/home/icub/Software/fbergonti/mystica/casadi/mex/casadiMEX.mexa64':
/usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.26' not found (required by
/home/icub/Software/fbergonti/mystica/casadi/mex/casadiMEX.mexa64)

Error in casadi.GenSX.sym (line 432)
     [varargout{1:nargout}] = casadiMEX(315, varargin{:});

Here the mamba list

# packages in environment at /home/icub/Software/fbergonti/mystica/casadi:
#
# Name                    Version                   Build  Channel
_libgcc_mutex             0.1                 conda_forge    conda-forge
_openmp_mutex             4.5                       2_gnu    conda-forge
ampl-mp                   3.1.0             h2cc385e_1006    conda-forge
bzip2                     1.0.8                h7f98852_4    conda-forge
ca-certificates           2022.5.18.1          ha878542_0    conda-forge
casadi                    3.5.5           py310h597d7ca_9    conda-forge
casadi-matlab-bindings    3.5.5.2             h27087fc_53    robotology
ipopt                     3.14.6               h630875f_0    conda-forge
ld_impl_linux-64          2.36.1               hea4e1c9_2    conda-forge
libblas                   3.9.0           14_linux64_openblas    conda-forge
libcblas                  3.9.0           14_linux64_openblas    conda-forge
libedit                   3.1.20191231         he28a2e2_2    conda-forge
libffi                    3.4.2                h7f98852_5    conda-forge
libgcc-ng                 12.1.0              h8d9b700_16    conda-forge
libgfortran-ng            12.1.0              h69a702a_16    conda-forge
libgfortran5              12.1.0              hdcd56e2_16    conda-forge
libgomp                   12.1.0              h8d9b700_16    conda-forge
libiconv                  1.16                 h516909a_0    conda-forge
liblapack                 3.9.0           14_linux64_openblas    conda-forge
libnsl                    2.0.0                h7f98852_0    conda-forge
libopenblas               0.3.20          pthreads_h78a6416_0    conda-forge
libosqp                   0.6.2                h9c3ff4c_3    conda-forge
libstdcxx-ng              12.1.0              ha89aaad_16    conda-forge
libuuid                   2.32.1            h7f98852_1000    conda-forge
libzlib                   1.2.11            h166bdaf_1014    conda-forge
metis                     5.1.0             h58526e2_1006    conda-forge
mumps-include             5.2.1               ha770c72_11    conda-forge
mumps-seq                 5.2.1               h2104b81_11    conda-forge
ncurses                   6.3                  h27087fc_1    conda-forge
numpy                     1.22.3          py310h4ef5377_2    conda-forge
openssl                   3.0.3                h166bdaf_0    conda-forge
pip                       22.0.4             pyhd8ed1ab_0    conda-forge
python                    3.10.4          h2660328_0_cpython    conda-forge
python_abi                3.10                    2_cp310    conda-forge
readline                  8.1                  h46c0cb4_0    conda-forge
scotch                    6.0.9                hb2e6521_2    conda-forge
setuptools                62.3.2          py310hff52083_0    conda-forge
sqlite                    3.38.5               h4ff8645_0    conda-forge
tk                        8.6.12               h27826a3_0    conda-forge
tzdata                    2022a                h191b570_0    conda-forge
unixodbc                  2.3.10               h583eb01_0    conda-forge
wheel                     0.37.1             pyhd8ed1ab_0    conda-forge
xz                        5.2.5                h516909a_1    conda-forge
zlib                      1.2.11            h166bdaf_1014    conda-forge

@FabioBergonti commented on Fri May 20 2022

I tried to repeat on iiticubws050 the analysis done by @traversaro before

readelf -s /usr/lib/x86_64-linux-gnu/libstdc++.so.6 | grep "GLIBCXX_3.4.26" | wc -l
> 0

Does this mean that GLIBCXX_3.4.26 is not available in the installed library libstdc++.so.6?

readelf -s $CONDA_PREFIX/lib/libstdc++.so.6 | grep "GLIBCXX_3.4.26" | wc -l
> 431
readelf -s /usr/local/MATLAB/R2019b/sys/os/glnxa64/libstdc++.so.6.0.22 | grep "GLIBCXX_3.4.26" | wc -l
> 0

@traversaro commented on Fri May 20 2022

It seems that iiticubws050 is a Ubuntu 18.04, that so has an older GCC/libstdc++.so.6 . If there you are getting the same error, probably it is better to do the LD_PREALOAD trick with $CONDA_PREFIX/lib/libstdc++.so.6 .


@FabioBergonti commented on Fri May 20 2022

It seems that iiticubws050 is a Ubuntu 18.04

indeed

If there you are getting the same error, probably it is better to do the LD_PREALOAD trick with $CONDA_PREFIX/lib/libstdc++.so.6

Yes! Running Matlab with LD_PRELOAD=$CONDA_PREFIX/lib/libstdc++.so.6 matlab solved the issue.

Thanks @traversaro

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.