Skip to content
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

MATLAB/Simulink whole-body-controllers models compilation failing when using conda on macOS #707

Open
nunoguedelha opened this issue May 3, 2021 · 7 comments
Assignees
Labels

Comments

@nunoguedelha
Copy link
Collaborator

nunoguedelha commented May 3, 2021

Short description

The Simulink whole-body-controllers models compilation is failing after installing the robotology-superbuild based on conda-forge:
image

Platform environment

Hardware: MacBook Pro
OS: MacOS Catalina 10.15.7
robotolgy-superbuild: commit 8c45dd3, source installation + dependencies installed with conda-forge (https://github.com/robotology/robotology-superbuild/blob/master/doc/conda-forge.md#source-installation)
MATLAB/Simulink: R2020b/10.2
Simulink model: floating-base-balancing-torque-control

Procedure to reproduce the issue

Procedure to reproduce the issue running the example model floating-base-balancing-torque-control:

  1. Install the superbuild following https://github.com/robotology/robotology-superbuild/blob/master/doc/conda-forge.md#source-installation.
  2. Run MATLAB from ~/Documents/MATLAB.
  3. Set working directory to [getenv('ROBOTOLOGY_SUPERBUILD_SOURCE_DIR'),'/src/whole-body-controllers/controllers/floating-base-balancing-torque-control'].
  4. Open the model torqueControlBalancing.mdl
  5. Compile (⌘+D on MacOS, CTRL+D on Linux and Windows I guess).

Workaround

Before compiling:

  1. close the model without saving.
  2. run in the command window.
>> clear all.
>> path(pathdef).
  1. open the model again.
  2. Compile.
@nunoguedelha nunoguedelha changed the title MATLAB MATLAB/Simulink whole-body-controllers models compilation failing when downloaded with the superbuild (source install with conda) May 3, 2021
@nunoguedelha
Copy link
Collaborator Author

It doesn't seem to be related to whole-body-controllers repo.

@nunoguedelha nunoguedelha self-assigned this May 8, 2021
@traversaro
Copy link
Member

@DanielePucci experienced the same problem following the one-line installation, for him the error was:

Warning: Unsupported robot model. Supported models are listed below:
- iCubGazeboV2_5 [2 similar]
kinDynListDimensions =
  15×1 cell array
    {1×2 double}
    {1×2 double}
    {1×2 double}
    {1×2 double}
    {1×2 double}
    {1×2 double}
    {1×2 double}
    {1×2 double}
    {1×2 double}
    {1×2 double}
    {1×2 double}
    {1×2 double}
    {1×2 double}
    {1×2 double}
    {1×2 double}
Error evaluating 'InitFcn' callback of SubSystem block (mask) 'torqueControlBalancingWithSimu/Robot Simulator/RobotDynWithContacts'. 
Callback string is '%% initialize the simulation
mwbs.RobotDynamicsWithContacts.initRobotDynamicsWithContactsCB;'
Caused by:
Invalid MEX-file '/Users/danielepucci/src/matlab/robotology-matlab/mex/yarpMEX.mexmaci64': dlopen(/Users/danielepucci/src/matlab/robotology-matlab/mex/yarpMEX.mexmaci64, 6): Library not loaded: @rpath/libpng16.16.dylib
  Referenced from: /Users/danielepucci/src/matlab/robotology-matlab/lib/libYARP_sig.3.4.5.dylib
  Reason: Incompatible library version: libYARP_sig.3.dylib requires version 54.0.0 or later, but libpng16.16.dylib provides version 52.0.0 
Component:Simulink | Category:Model error
Error evaluating 'InitFcn' callback of mwbs.Visualizers.robotVisualizer.RobotVisualizer block (mask) 'torqueControlBalancingWithSimu/Robot Visualizer/RobotVisualizer'. 
Callback string is 'mwbs.Visualizers.robotVisualizer.initRobotVisualizer'
Caused by:
Invalid MEX-file '/Users/danielepucci/src/matlab/robotology-matlab/mex/yarpMEX.mexmaci64': dlopen(/Users/danielepucci/src/matlab/robotology-matlab/mex/yarpMEX.mexmaci64, 6): Library not loaded: @rpath/libpng16.16.dylib
  Referenced from: /Users/danielepucci/src/matlab/robotology-matlab/lib/libYARP_sig.3.4.5.dylib
  Reason: Incompatible library version: libYARP_sig.3.dylib requires version 54.0.0 or later, but libpng16.16.dylib provides version 52.0.0 
Component:Simulink | Category:Model error

@traversaro
Copy link
Member

@DanielePucci I did not remember that @nunoguedelha had found a workaround, if you like you can test it.

@DanielePucci
Copy link
Contributor

DanielePucci commented Jun 7, 2021

I tried the workaround, and what follows is what I did

  1. I opened Matlab
  2. I launched the command floatingBaseBalancingTorqueControlWithSimulator and the output was
Unable to resolve the name floatingBaseBalancingTorqueControlWithSimulator.torqueControlBalancingWithSimu.
  1. I was not sure what to do (I felt that it was supposed to work, but probably I was wrong) so I launched again robotology_setup and there was no output
  2. Then, I launched floatingBaseBalancingTorqueControlWithSimulator.torqueControlBalancingWithSimu that now worked and opened the model
  3. I clicked on Play on the Simulink model with the output
torqueControlBalancingWithSimu 
 Simulation  1  2  2 
10:58 AM Elapsed: 7 sec
Warning: Unsupported robot model. Supported models are listed below:
- iCubGazeboV2_5 [2 similar]
kinDynListDimensions =
  15×1 cell array
    {1×2 double}
    {1×2 double}
    {1×2 double}
    {1×2 double}
    {1×2 double}
    {1×2 double}
    {1×2 double}
    {1×2 double}
    {1×2 double}
    {1×2 double}
    {1×2 double}
    {1×2 double}
    {1×2 double}
    {1×2 double}
    {1×2 double}
Error evaluating 'InitFcn' callback of SubSystem block (mask) 'torqueControlBalancingWithSimu/Robot Simulator/RobotDynWithContacts'. 
Callback string is '%% initialize the simulation
mwbs.RobotDynamicsWithContacts.initRobotDynamicsWithContactsCB;'
Caused by:
Invalid MEX-file '/Users/danielepucci/src/matlab/robotology-matlab/mex/yarpMEX.mexmaci64': dlopen(/Users/danielepucci/src/matlab/robotology-matlab/mex/yarpMEX.mexmaci64, 6): Library not loaded: @rpath/libpng16.16.dylib
  Referenced from: /Users/danielepucci/src/matlab/robotology-matlab/lib/libYARP_sig.3.4.5.dylib
  Reason: Incompatible library version: libYARP_sig.3.dylib requires version 54.0.0 or later, but libpng16.16.dylib provides version 52.0.0 
Component:Simulink | Category:Model error
Error evaluating 'InitFcn' callback of mwbs.Visualizers.robotVisualizer.RobotVisualizer block (mask) 'torqueControlBalancingWithSimu/Robot Visualizer/RobotVisualizer'. 
Callback string is 'mwbs.Visualizers.robotVisualizer.initRobotVisualizer'
Caused by:
Invalid MEX-file '/Users/danielepucci/src/matlab/robotology-matlab/mex/yarpMEX.mexmaci64': dlopen(/Users/danielepucci/src/matlab/robotology-matlab/mex/yarpMEX.mexmaci64, 6): Library not loaded: @rpath/libpng16.16.dylib
  Referenced from: /Users/danielepucci/src/matlab/robotology-matlab/lib/libYARP_sig.3.4.5.dylib
  Reason: Incompatible library version: libYARP_sig.3.dylib requires version 54.0.0 or later, but libpng16.16.dylib provides version 52.0.0 
Component:Simulink | Category:Model error
  1. Then I followed the workaround in the first comment, but there was another action I had to take (not save the file). More precisely, I did the following.
    6.1 I closed the model, then to the question Save "torqueControlBalancingWithSimu" before closing? I clicked on No
    6.2 In the command window I ran:
>> clear all
>> path(pathdef)

6.3 Then I opened the model again re-launching floatingBaseBalancingTorqueControlWithSimulator.torqueControlBalancingWithSimu but I got the output

Unable to resolve the name floatingBaseBalancingTorqueControlWithSimulator.torqueControlBalancingWithSimu.

6.4 So, I launched again robotology_setup and then floatingBaseBalancingTorqueControlWithSimulator.torqueControlBalancingWithSimu. No it worked
image

  • I have to say that it was awesome to see the Yoga running in Matlab with our simulation infrastructure. I did not know if it was supposed to finish, or how long the simulation was supposed to run. So, when the robot arrived back to two-fee standing, then I sopped. Probably, if we have to send this demo to someone, it would be better to fix a simulation time and show the percentage of the demo

@traversaro
Copy link
Member

The fact that clear all makes the problem goes aways may indicate that there is some shared library that was loaded by MATLAB and that is unloaded when your run clear all.

@traversaro
Copy link
Member

Things that it would be nice to check (eventually remainder for myself):

  • Try if the workaround works just with clear mex
  • Print inmem('-completenames') in the situation after the compilation of the model failed, and after the compilation of the model was successful

@traversaro traversaro changed the title MATLAB/Simulink whole-body-controllers models compilation failing when downloaded with the superbuild (source install with conda) MATLAB/Simulink whole-body-controllers models compilation failing when using conda on macOS Jun 7, 2021
@nunoguedelha
Copy link
Collaborator Author

Hi @DanielePucci , thanks again for your feedback. Thanks @traversaro for the great support. I'm answering here to some of Dani's observations during his tests..

  1. I launched the command floatingBaseBalancingTorqueControlWithSimulator and the output was
Unable to resolve the name floatingBaseBalancingTorqueControlWithSimulator.torqueControlBalancingWithSimu.

Most probably, you already know by now why this wasn't working, but just to be sure, I try to explain here:
If I understood correctly, this is a new MATLAB session, so the MATLAB Path has been reset to the default value and unless you saved the MATLAB path to a pathdef.m file, the default value does not contain the paths:

<robotology_install_prefix>/mex
<robotology_install_prefix>/mex/+wbc/simulink
<robotology_install_prefix>/mex/+wbc/examples
<robotology_install_prefix>/share/WBToolbox
<robotology_install_prefix>/share/WBToolbox/images

where <robotology_install_prefix>/mex/+wbc/examples would be the path containing the model to test. That's why MATLAB couldn't resolve the model name.

6.3 Then I opened the model again re-launching floatingBaseBalancingTorqueControlWithSimulator.torqueControlBalancingWithSimu but I got the output

Unable to resolve the name floatingBaseBalancingTorqueControlWithSimulator.torqueControlBalancingWithSimu.

This is due to similar reasons. At startup, or when you run path(pathdef), the MATLAB path is initialized from a pathdef.m if it exists, and the environment variable MATLABPATH. This variable is not set in script robotology_setup as we add the paths directly through the addpath command. For that reason you have to run robotology_setup again after running path(pathdef).

Note: When following the Binary Installation from the Conda Robotology Channel or the Source Installation, the environment variable MATLABPATH is set then applied at MATLAB startup.

Probably, if we have to send this demo to someone, it would be better to fix a simulation time and show the percentage of the demo.

good point, will do it ASAP.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants