Closed mkirby42 closed 6 months ago
Getting this for any examples using Moco track
root@ea861416502b:/opensim-core/Bindings/Python/examples/Moco# python3.8 exampleSlidingMass.py
[info] ========================================================================
[info] MocoCasADiSolver starting.
[info] Thu Sep 30 17:58:44 2021
[info] ------------------------------------------------------------------------
Costs: (total: 1)
goal. MocoFinalTimeGoal, enabled: true, mode: cost, weight: 1.0
Endpoint constraints: none
Kinematic constraints: none
Path constraints: none
States: (total: 2)
/slider/position/speed. bounds: [-50, 50] initial: 0 final: 0
/slider/position/value. bounds: [-5, 5] initial: 0 final: 1
Controls: (total: 1)
/actuator. bounds: [-50, 50]
Parameters: none
[info] Number of threads: 2
[info] Set log level to Info.
[info] Set log level to Info.
Traceback (most recent call last):
File "exampleSlidingMass.py", line 87, in <module>
solution = study.solve()
File "/root/opensim_install/lib/python3.8/site-packages/opensim/moco.py", line 4642, in solve
return _moco.MocoStudy_solve(self)
RuntimeError: std::exception in 'OpenSim::MocoSolution OpenSim::MocoStudy::solve() const': casVector should be 1-dimensional, but has size 0 x 0.
Thrown at MocoCasOCProblem.h:108 in convertToSimTKVector().
The examples work when using the conda env from here
When running
opensim.moco.GetMocoVersionAndDate()
I get 'version 4.3--, build date 05:13:50 Aug 19 2021'
in the docker container
and 'version 4.3-2021-08-27-4bc7ad9, build date 09:13:36 Aug 28 2021'
in the conda env
It seems that there is something wrong with the libtropter.so
file in the opensim installation directory. For me, copying libtropter.so
from the opensim build directory to the lib folder within the opensim installation directory solved this issue.
Duplicate of #3006
We're using the default Casadi solver. The issue seems to be a problem with the initial guess outputting an empty vector for the time duration of the problem. I wouldn't think the Tropter solver would be involved.
I also did not expect the tropter solver to be involved, but replacing the libtropter.so file was the only way to get the Moco Python Examples running. However, I have no idea what is the difference between both files...
Hi @mkirby42, thanks for providing more details on this issue. I'm not really sure why the Docker container fails, given that the examples work when installing OpenSim from the instructions for the TGCS workshop. Those instructions link to the latest version of OpenSim, and the Docker container includes a recent version of OpenSim as well. I don't think there's any differences between those versions that would cause this issue, so I think something funny is happening in the Docker container.
I think the problem is that OpenSim 4.3 is built with ipopt 3.12.8 as dependency (which provides libipopt.so.1.10.8), but the docker image only contains libipopt.so.1.9.9. Since the installation of OpenSim removes the runtime path from libtropter.so, the installed version makes use of the system-wide installed libraries (in the docker image, it thus uses /usr/lib/libipopt.so.1.9.9). This problem also occurs for manual builds of OpenSim 4.3 on Linux (Ubuntu, e.g., only supports ipopt 3.11.9, which also provides libipopt.so.1.9.9).
To circumvent this issue in the docker image, it suffices to replace the system ipopt library with the one used to build OpenSim:
cp /opensim_dependencies_install/ipopt/lib/*.so* /usr/lib
For manual builds this should also work, or one could replace the libtropter.so from $OPENSIM_INSTALL_DIR/lib with the libtropter.so from $OPENSIM_BUILD_DIR, which still depends on the libraries from opensim_dependencies_install.
A fix for this issue would probably require to adjust the ipopt dependencies here?
The issue seems to be a problem with the initial guess outputting an empty vector for the time duration of the problem.
@mkirby42 just to verify this, have you tried specifying your own initial guess as a workaround? You can use guess = solver.createGuess()
to create a guess that is compatible with the problem and then specify this guess using solver.setGuess(guess)
(optionally, you can make changes to the guess values before this step). The issue might be related to how MocoTrack handles initial guesses (since it manages it's own internal MocoStudy). Still not sure why this only happens in the Docker container, but this could narrow things down.
@fl0fischer are you seeing this same casVector zero-dimension issue, or is this a different issue related to the Docker container? The tropter/ipopt library issues seem off-topic from this thread. If so, please open a separate issue.
@fl0fischer are you seeing this same casVector zero-dimension issue, or is this a different issue related to the Docker container? The tropter/ipopt library issues seem off-topic from this thread. If so, please open a separate issue.
It's the same casVector zero-dimension issue, it occurs both with docker and manual Linux builds, and I've verified that the above two workarounds solve this issue in both cases.
Hi @fl0fischer, thanks for clarifying. Good to know that this is Linux-specific and unrelated to Docker. Apologies for thinking this was off-topic, I thought you were having general issues with libtropter.so
that were independent of the zero-dimension CasADi. It is very strange that these are related. Out of curiosity, how did you know to replace libtropter.so
in the first place, did you encounter an error when building locally?
It does seem like updating how handle IPOPT dependencies for Linux could be the fix. @fl0fischer, is this something you'd be willing to try? I don't have a Linux build currently setup for myself, and you've done a good job tracking down the source of this issue already.
It was basically trial and error, once I've noticed that the issue is related to the libraries in the opensim install dir, I removed each library separately and found out that the error just appears when the new libtropter.so file is created and used (executing the building tests with install dir already included in the LD_LIBRARY_PATH helped to figure this out).
I would suggest to replace the CMakeLists.txt with this file, which copies all relevant libraries from ipopt and adol-c to the opensim installation dir. I built the latest OpenSim version from this git on a Ubuntu 20.04 system using this patched CMakeLists.txt and everything worked fine.
In the docker image, replacing the installed ipopt library with libipopt.so.1.10.8
from the dependencies dir also seems to solve this issue:
cp /opensim_dependencies_install/ipopt/lib/lib* /opensim_install/lib/
@aymanhab here is the issue I was referring to yesterday. If this is something you are able to test on your Ubuntu build, let me know.
@aymanhab pinging you here again per our dev meeting conversation.
I'll make fresh Ubuntu 18 build to try and will let you know
@nickbianco Can we close this one?
@aymanhab did you ever get to try this on your Ubuntu build?
Hi there, I just wanted to follow up as I have been having a similar issue. I am running my own simulations on my Windows desktop and when I try to repeat the simulation on a Linux HPC, I get the casVector error midway through.
In my code I am using guess = solver.createGuess() as suggested and I can run the exampleMocoTrack script without issues. My desktop is running OpenSim 4.4-2022-06-11-bfc372a and version 4.4 is on the HPC if that could be a difference. Are there any potential fixes for this? Thanks
@aymanhab, I'm looking to close out this issue. I think it was resolved via #3092 a while ago.
@GraceEMc, does this issue still persist for you on the latest versions of OpenSim?
Unless @GraceEMc reports otherwise and can reproduce I'd agree to close .
Hey @fl0fischer, we're looking to close out this issue since it seems to have been resolved some time ago. Let us know if more recent versions of OpenSim (e.g., 4.5) work as expected in your Docker containers or if you still need to copy libraries manually.
I haven't had any issues with v4.5. Thanks!
Thanks @GraceEMc! I'll go ahead and close this then.
Using all the code provided in the example
Running in latest docker container
Data files provided in the examples
Code