robotology / icub-tutorials

Tutorials on iCub code
19 stars 9 forks source link

Problems compiling iDyn/oneChainDynamics #2

Closed DermyO closed 8 years ago

DermyO commented 8 years ago

Hi, I tried to launch the oneChainDynamics function but I have a "Segmentation fault (core dumped)" error. By testing the code (main.cpp), I can see that the problem is localized when the arm is supposed to be created: "iCubArmDyn armTorsoDyn("right");". What I am doing wrong?

pattacini commented 8 years ago

Hi @misaki43

I've launched oneChainDynamics and it runs smoothly providing this output. I've tested it both in Windows and in Linux successfully.

Did you make sure that the tutorials are linking against the most recent version of icub-main bundle on your machine?

DermyO commented 8 years ago

Hi, No I didn't verify it, but I don't know how to check (?)

Someone told me after my post that iDyn might not work anymore and that I should use iDynTree: is anyone else better aware of it?

pattacini commented 8 years ago

It should suffice checking the content of ICUB_DIR cmake variable while cmaking the icub-tutorials project.

As far as I know, iDyn is still fully operative: indeed, it's being used by a bunch of our crucial modules (e.g. wholeBodyDynamics).

However, iDynTree does extend iDyn providing a more comprehensive approach to robot dynamics.

Therefore, if your aim is to learn how to deal with robot dynamics, my warm suggestion is to start from iDynTree straightaway.

DermyO commented 8 years ago

I don't undertand but in the cmake variable I have "ICUB_DIR /usr/lib/ICUB", is that you want I check? But ok I will try iDynTree directly, thanks!

pattacini commented 8 years ago

Then you're using an installed version of icub-main. This means that in the past you did one of the following:

  1. sudo apt-get install icub.
  2. you cloned the repository and then you make install it (as root?).
  3. you downloaded and compiled the repository via super-build.
Case 1

That tutorial should work fine even if the icub installed version might be a bit old, since iDyn hasn't changed recently. Anyway, you could consider going with the latest code of icub-main, thus refer to case 2.

Case 2

Locate the icub-main sources on your drive and do git pull and (sudo) make install. It's important to make sure that the install part is done, otherwise the libraries in /usr/lib won't get updated. To verify that, you could inspect the date and the time of those products in /usr/lib.

Case 3

Unfortunately I'm not an expert of the super-build mechanism, hence I'd rather point you to @drdanz or @traversaro.

DermyO commented 8 years ago

Hi! I have changed some other things that should resolve my previous problem (it is why I don't answer before) and I tried again to launch wholeBodyDynamics. Now, I have a new problem that appears during the "make":

61: error: invalid initialization of non-const reference of type ‘yarp::sig::Vector&’ from an rvalue of type ‘yarp::sig::Vector’ printVector("Joint Angles - real ", armTorsoDyn.getAng()); ^ /home/user/Software/src/icub-tutorials/src/iDyn/oneChainDynamics/main.cpp:37:6: error: in passing argument 2 of ‘void printVector(std::string, yarp::sig::Vector&)’ void printVector(string s, Vector &v) ^ make[2]: * [oneChainDynamics/CMakeFiles/oneChainDynamics.dir/main.cpp.o] Error 1 make[1]: * [oneChainDynamics/CMakeFiles/oneChainDynamics.dir/all] Error 2 make: *\ [all] Error 2"

This error wasn't there before, that is strange. Have you an idea?

Note: I read:

iDyn depends only on YARP and iKin. In order to include iDyn and use it in your software, make sure you include the following line in the CMakeLists.txt: TARGET_LINK_LIBRARIES(${PROJECTNAME} ... iDyn ...) Of course if you are developing outside the iCub project (e.g. in contrib), you may also add these lines: FIND_PACKAGE(YARP) FIND_PACKAGE(ICUB) In your code the iDyn namespace must be declared, and the header files needed must be included:

So I added in the CMakeLists.txt in the i"icub-tutorial/src/iDyn" folder the next lines:

TARGET_LINK_LIBRARIES(/home/user/Software/src/icub-tutorial/src/iDyn) FIND_PACKAGE(YARP) FIND_PACKAGE(ICUB)

Is it what I was supposed to do?

pattacini commented 8 years ago

Sorry, I forgot to mention that in the meantime I've revived a couple of iDyn related tutorials in the icub-tutorials/src/iDyn path, hence I had to streamline a bit the code and you ought to update icub-tutorials as well.

Simply, make sure that you have the freshest icub-main and icub-tutorials on your machine; they should compile successfully. No need for tuning cmake files.

DermyO commented 8 years ago

Ok thanks it is working now! This issue is resolved.

Happy new year

pattacini commented 8 years ago

Great. Happy new year @misaki43