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

Cant instantiate the solver; "OsqpEigen::Solver solver" #93

Open
dhruvthanki opened this issue Apr 24, 2021 · 8 comments
Open

Cant instantiate the solver; "OsqpEigen::Solver solver" #93

dhruvthanki opened this issue Apr 24, 2021 · 8 comments

Comments

@dhruvthanki
Copy link

dhruvthanki commented Apr 24, 2021

This is how I build the wrapper: (I am using windows btw)

git clone https://github.com/robotology/osqp-eigen.git
cd osqp-eigen
mkdir build && cd build
cmake ../
cmake --build . --config Debug

This is my CmakeLists.txt file:

cmake_minimum_required(VERSION "3.20.0")

project("-----")

find_package (Eigen3 3.3 REQUIRED NO_MODULE)
find_package(osqp REQUIRED)
find_package(OsqpEigen REQUIRED PATHS "C:/Users/Dhruv/Documents/GitHub/osqp-eigen/build")

include_directories("C:/Users/Dhruv/Documents/mujoco200_win64/include")
link_directories("C:/Users/Dhruv/Documents/mujoco200_win64/bin")

add_executable("${PROJECT_NAME}" "main.cpp")

target_link_libraries("${PROJECT_NAME}" 
mujoco200
mujoco200nogl
glfw3
glfw3static
Eigen3::Eigen
osqp::osqpstatic
# osqp::osqp
OsqpEigen::OsqpEigen)

osqp-sol

I am able to compile and run the "osqp" example problems from their website. I am able to include the OsqpEigen.h in my project. When I just instantiate the solver using the wrapper, I am able to build and run the .exe but no output that I was expecting is generated. Just builds and runs with zero errors and nothing happens.

#include <iostream>
#include <Eigen/Core>
#include "osqp.h"
#include "OsqpEigen/OsqpEigen.h"

int main(void){
    std::cout << "Hello1" << std::endl;

    // instantiate the solver
    OsqpEigen::Solver solver;
 
    std::cout << "Hello2" << std::endl;

    return 1;
}
@S-Dafarra
Copy link
Collaborator

Hi @dhruvthanki, thanks for the issue. Just to understand, what does your program print? The Solver object does not print anything and it is supposed to do nothing until you set the problem and call the solve method.

@dhruvthanki
Copy link
Author

So if I just compile and run the above code, should it print the following in the terminal or not?

Hello1
Hello2

@S-Dafarra
Copy link
Collaborator

So if I just compile and run the above code, should it print the following in the terminal or not?

Hello1
Hello2

I think so! Does it get stuck before?

@dhruvthanki
Copy link
Author

If I run it without instantiating the solver in the main, I get the first output. If I run it with the instantiation, I get the second output:
111111

@S-Dafarra
Copy link
Collaborator

Ok, that seems to be crashing then.
I wonder if that is because you are linking also osqpstatic. OsqpEigen is already linking osqp. Can you try to not link to osqpStatic?

If that is not the case, can you try to launch the tests of OsqpEigen?

@dhruvthanki
Copy link
Author

dhruvthanki commented Apr 24, 2021

I build the MPCExample and launched the MPCExample.exe.
No changes to the CmakeLists.txt that was in the example dir.
No Error while building, no error while running.
The display output option is turned on.

solver.settings()->setVerbosity(true);

2222222

@traversaro
Copy link
Member

Can you try to avoid linking the osqp::osqpstatic target? As @S-Dafarra mentioned, OsqpEigen::OsqpEigen already links the shared target osqp::osqp, and mixing the two can create strange behaviors.

@S-Dafarra
Copy link
Collaborator

S-Dafarra commented Apr 26, 2021

If also the example crashes, I think that OsqpEigen did not compile correctly. Can you list the commands you used to compile osqp and OsqpEigen, as suggested in #77 (comment)?

Probably it would be better to start with some clean builds.

Also, make sure you don't have any other osqp installations on your system. Some projects, like acados, are used to ship a version of osqp that is not compatible with OsqpEigen (see #81 for example).

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

No branches or pull requests

3 participants