robomechanics / quad-sdk

Software tools for agile quadrupeds, developed by the Robomechanics Lab at Carnegie Mellon University.
https://robomechanics.github.io/quad-sdk/
MIT License
694 stars 132 forks source link

NMPC solving fail , not similar to #288 #410

Closed MusubaPy closed 8 months ago

MusubaPy commented 9 months ago

Hello gentlemen,

I hope this message finds you well. First and foremost, I want to express my gratitude for your excellent work. However, I have encountered an issue that I am unsure how to resolve:

"NMPC solving fail"

I was able to address this error by executing "catkin clean" followed by a subsequent "catkin build." However, rebuilding the project twice each time I enter the docker environment is not ideal due to the associated costs. Strangely, the SECOND rebuild of the project seems to be the resolution for this error. I have reviewed previous open issues, but unfortunately, they did not provide a satisfactory solution.

Here's a summary of my actions:

I am building your project in a Docker container with Ubuntu 18.04 and ROS Melodic. Additionally, I possess an academic license for HSL.

1) Cloned your repository: git clone https://github.com/robomechanics/quad-sdk.git ~/catkin_ws/src/

2) Cloned the Ipopt stable/3.13 repository into quad-sdk/external/ipopt/coinbrew/: git clone https://github.com/coin-or/Ipopt.git ~/catkin_ws/src/quad-sdk/external/ipopt/coinbrew/

3) Cloned the ThirdParty-HSL repository and placed it in quad-sdk/external/ipopt/coinbrew/ThirdParty/HSL, including the coinhsl folder: git clone git@github.com:coin-or-tools/ThirdParty-HSL.git ~/catkin_ws/src/quad-sdk/external/ipopt/coinbrew/ThirdParty/HSL

4) Build the project:

cd ~/catkin_ws/src/quad-sdk/
./src/$DIR_NAME/setup.sh

cd ./src/$DIR_NAME/external/ipopt/coinbrew/Ipopt/
./configure
make
make install

cd ../ThirdParty/HSL
./configure
make
make install

cd ./../../../../../../../
catkin build

5) Additionally, I update and upgrade the system packages:

apt update
apt -y upgrade

6) Finally, I source the bash files:

source ~/.bashrc
source ~/../catkin_ws/devel/setup.bash

Despite following these steps, the "NMPC solving fail" error persists even after the initial build. But after performing

catkin clean
catkin build

the problem is solved. What can I do to build the project only once? Your insight to solve this problem would be greatly appreciated.

Thank you for your time and assistance.

Best regards

elpimous commented 9 months ago

hi friend, first, could you change nmpccontroller.cpp L168 " app->Options()->SetIntegerValue("print_level", 0);" to value =5 it will verbose ipopt feedback during run.

Launch code and see error !

perhaps could you try to run : chmod +x setup.sh && ./setup.sh !!! (https://github.com/robomechanics/quad-sdk/wiki/1.-Getting-Started-with-Quad-SDK)

MusubaPy commented 9 months ago

@elpimous Thank you for the prompt response.

Certainly, I run

"chmod +x setup.sh && ./setup.sh"

at step 4 (otherwise, nothing would work for me). The only thing is I manually build Ipopt and HSL because after building through coinbrew, I encounter other errors like

"IpIpoptData.hpp: No such file or directory."

Similar to your issue #337, I have the following output:

For the solver ma57:

[ WARN] [1701951487.372194932, 33.386000000]: NMPC solving fail [robot_1/plan_publisher-4] killing on exit [robot_1/rosbag_record_archive-3] killing on exit [robot_1/rosbag_record-2] killing on exit [robot_1/local_planner-1] killing on exit Exception of type: OPTION_INVALID in file "IpAlgBuilder.cpp" at line 295: Exception message: Selected linear solver MA57 not available. Tried to obtain MA57 from shared library "libhsl.so", but the following error occured: libhsl.so: cannot open shared object file: No such file or directory

EXIT: Invalid option encountered.

For the solver ma27:

[ WARN] [1701952546.122275918, 23.120000000]: NMPC solving fail [robot_1/plan_publisher-4] killing on exit [robot_1/rosbag_record_archive-3] killing on exit Exception of type: OPTION_INVALID in file "IpAlgBuilder.cpp" at line 268: Exception message: Selected linear solver MA27 not available. Tried to obtain MA27 from shared library "libhsl.so", but the following error occured: libhsl.so: cannot open shared object file: No such file or directory

EXIT: Invalid option encountered.

Although the build proceeds without errors and these libraries are correctly located:

quad-sdk/external/ipopt/coinbrew/ThirdParty/HSL/coinhsl/ma57/ma57d.f
quad-sdk/external/ipopt/coinbrew/ThirdParty/HSL/coinhsl/ma27/ma27d.f

Also at build time, these solvers are correctly detected:

make[2]: Entering directory '/catkin_ws/src/quad-sdk/external/ipopt/coinbrew/Ipopt/src/Algorithm' CXX IpAdaptiveMuUpdate.lo CXX IpAlgBuilder.lo CXX IpAlgorithmRegOp.lo CXX IpAugRestoSystemSolver.lo ....

configure: pkg-config path is "/usr/local/lib/pkgconfig:/opt/ros/melodic/lib/pkgconfig" checking for MC19... yes checking for MA27... yes checking for MA28... yes checking for MA57... yes checking for MA77... yes

I'll repeat once again that the error occurs only after the initial project build. After the second project build, everything starts working correctly. In both cases, the same scripts are executed.

elpimous commented 9 months ago

Try replacing L 207.ma57 to ma27

MusubaPy commented 9 months ago

Yes, I have already tried changing the solver in L208 to ma57 and ma27 with rebuilding the project. You can also see the output in my previous post.

MusubaPy commented 9 months ago

Perhaps the attached files, will help you reproduce the error:

1) It is necessary to put "coinhsl" in the folder "requirements" 2) (optionally) install docker using ./install_docker.sh 3) ./build_docker.sh -n (This is where the workspace and cloning repositories will be created.) 4) ./run_docker.sh -n

Inside docker:

cd catkin_ws/
./build.sh
source ~/.bashrc
source devel/setup.bash

docker.zip

MusubaPy commented 8 months ago

Hello, gentlemen.

In the end, I managed to solve the issue with the need for two builds of the project. This solution worked for me: https://github.com/casadi/casadi/issues/2769

In short

What I ended up doing was compiling the HSL code using ThirdParty-HSL, which is one of the options that Ipopt gives in its documentation. The shared library libcoinshsl.so gets created in /usr/local/lib, but since Ipopt looks for libhsl.so make a symbolic link from libcoinhsl.so to libhsl.so. ln -s /usr/local/lib/libcoinhsl.so /usr/local/lib/libhsl.so Then make sure Ipopt knows where to look. export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib