lis-epfl / robogen

RoboGen - Robot generation through artificial evolution
http://www.robogen.org
GNU General Public License v3.0
27 stars 16 forks source link

Simulator build on Mac OS 10.8.3 #1

Closed Mikaz-fr closed 11 years ago

Mikaz-fr commented 11 years ago

Ok I'll start with some feedback, I'll try to do a complete step by step manual for Mac OS when everything will be working on my machine.

So I was able to compile and install the dependencies, problems rised when I tried to compiled the simulator code. The first command:

cmake -DCMAKE_BUILD_TYPE=Release ../src

Couldn't pass, I think because of dependancies. So I had to modify CustomPath.cmake so it could find everything. I seted UTILS_PATH:

set(UTILS_PATH "/usr/local")

And added a duplicated sets of defines:

if (APPLE)
    [...]
endif()

if (WIN32)
    [...]
endif()

That allowed me to configure correctly, but when I tried to to compile with:

make -j4

I had a new bunch of error, mainly because some lib file where not found to build the executables. Thus I modified the config to the following (libpng.lib -> libpng.a, libprotobuf.lib -> libprotobuf.a, ode_double.lib -> libode.a):

if (APPLE)

    # ZLIB
    set (ZLIB_ROOT ${UTILS_PATH})

    # PNG
    set (PNG_PNG_INCLUDE_DIR ${UTILS_PATH})
    set (PNG_LIBRARY "${UTILS_PATH}/lib/libpng.a")

    # OSG
    set(ENV{OSG_DIR} ${UTILS_PATH} )

    # Protobuf
    set (PROTOBUF_INCLUDE_DIR "${UTILS_PATH}/include")
    set (PROTOBUF_LIBRARY "${UTILS_PATH}/lib/libprotobuf.a")
    set (PROTOBUF_LIBRARY_DEBUG "${UTILS_PATH}/lib/libprotobufd.lib")
    set (PROTOBUF_PROTOC_EXECUTABLE "${UTILS_PATH}/bin/protoc")

    # BOOST
    set (BOOST_ROOT ${UTILS_PATH})
    set (Boost_USE_STATIC_LIBS ON)

    # ODE
    set (ODE_INCLUDE_PATH "${UTILS_PATH}/include")
    set (ODE_LIBRARIES "${UTILS_PATH}/lib/libode.a")

endif()

I am not sure if the library I replaced are the same, but that's the only ones I was able to find, and the compilation passed like that.

But now when I try to launch an executable, i.e. :

./robogen-file-viewer ../examples/r1.txt ../examples/conf.txt

I have a white window that popup and close immediatly and the following message in the console:

[...]
Obstacles in this range will not be generated

Segmentation fault: 11

Which make me think something went bad :)

If any one have some info or feedback for me that would help, because I'm kind of stuck here. Good luck

amaesani commented 11 years ago

Could you post the full output of the simulator? Also, it would be great if you could debug it and let me know at what line it exactly fails. The majority of the problems on Mac Os X usually arise from the graphic engine... Check this page maybe http://www.openscenegraph.org/projects/osg/wiki/Support/Tutorials/MacOSXTips to see if OpenSceneGraph was compiled/installed correctly. I suspect that the crash is due to OpenSceneGraph not able to properly instance a window in which to display the 3d visualization.

Mikaz-fr commented 11 years ago

That's sound like a possible assumption, I'll try to give a second look that way soon. Here is the full output (even if I don't think that help with the crash):

./robogen-file-viewer ../examples/r1.txt ../examples/conf.txt
Node: 0 id: L0 type: lightsensor
Node: 1 id: L1 type: lightsensor
Node: 2 id: W3 type: passivewheel
Node: 3 id: F5 type: fixedbrick
Node: 4 id: L6 type: lightsensor
Node: 5 id: C7 type: passivecardan
Node: 6 id: J8 type: activewheel
Node: 7 id: C9 type: passivecardan
Node: 8 id: K11 type: activecardan
Node: 9 id: T12 type: touchsensor
Node: 10 id: C13 type: passivecardan
Node: 11 id: F14 type: fixedbrick
Node: 12 id: H15 type: passivehinge
Root node! 13
Node: 13 id: K16 type: activecardan
Edge: F5 -> W3
Edge: F5 -> L1
Edge: F5 -> L0
Edge: C7 -> L6
Edge: C9 -> J8
Edge: C13 -> T12
Edge: F14 -> C13
Edge: F14 -> K11
Edge: F14 -> C9
Edge: F14 -> C7
Edge: F14 -> F5
Edge: H15 -> F14
Edge: K16 -> H15
Connect: H15 with K16(0, 1)
Connect: F14 with H15(0, 1)
Connect: C13 with F14(0, 5)
Connect: K11 with F14(0, 4)
Connect: C9 with F14(0, 3)
Connect: C7 with F14(0, 2)
Connect: F5 with F14(0, 1)
Connect: T12 with C13(0, 1)
Connect: J8 with C9(0, 1)
Connect: L6 with C7(0, 1)
Connect: W3 with F5(0, 4)
Connect: L1 with F5(0, 2)
Connect: L0 with F5(0, 1)
Sensors: 5, motors: 5
OSensors: 5, Omotors: 5
S: 5
M: 5
The robot is enclosed in the AABB(minX, maxX, minY, maxY, minZ, maxZ) (-0.109443, 0.107943, -0.172809, -0.00837891, 0.145216, 0.305761)
Obstacles in this range will not be generated

Segmentation fault: 11
Mikaz-fr commented 11 years ago

I had a look at the tips, but they are pretty old (version 1.2 from 2006) thus it doesn't correspond much to what we have now. I checked with the sample provided with OSG and I am able to open windows with 3d models without issue. Could the segmentation fault come from something else?

amaesani commented 11 years ago

Thanks a lot for checking the samples shipped with OSG. This excludes that the issue is caused by OSG itself. I will try to get a running version of MAC OS X as soon as possible and get back to you.

In the meanwhile, do you have installed/know how to use a debugger? It could be of great help if you could check it using a debugger, at least to know where it is crashing in the code.

Mikaz-fr commented 11 years ago

I never used a debugger outside an IDE, the only one I know is kdbg, should I look for that or do you have a better reference? I don't have a full grasp on how the tools work together yet. ./robogen-test and ./robogen-file-viewer crash with segmentation fault after flashing with a white window. ./robogen-simulator and ./robogen-server* ask for a port so I haven't been any further yet.

I'll try to have a look to robogen-ea to see if I run into similar issues.

amaesani commented 11 years ago

Which IDE are you using under MAC?

If Eclipse or Xcode you can use cmake to generate a project that you can directly import into your IDE. For example for Xcode:

   cmake -DCMAKE_BUILD_TYPE=Debug -G"Xcode" ROBOGEN_SOURCE_DIR

Check here for all the list of supported IDEs. http://cmake.org/cmake/help/v2.8.8/cmake.html#section_Generators

prfernando commented 11 years ago

I tested the robogen-simulator software on my macbook pro running Mac OSX 10.6.8. I was able to compile a Debug version of the software using cmake (not for a specific IDE). The result of running the file viewer on an example is attached below: $> RobogenSimulator-build-test1/robogen-file-viewer ./r1.txt ./conf.txt robogen-file-viewer(41653,0x7fff707b2cc0) malloc: * error for object 0x7fff706de500: pointer being freed was not allocated * set a breakpoint in malloc_error_break to debug Abort trap

Program does try to launch a graphical window and then quits with the above error message. One reason for this issue is the incompatibility of implementation of C++ string library (fully dynamic string on Mac) which can also be triggered by enabling _GLIBCXX_DEBUG flag in some libraries and not in others! Just to clarify, the issue is not a problem in the simulator source code (or any source code for that matter). It is due to incompatible libraries being used together. To fix this issue, try to compile all the dependent libraries using Apple's gcc software (explicitly specify the compiler when building all the libraries). If you use macports, etc., try not to use these libraries. Instead self-build your own libraries (Boost, etc.) and use them instead as it is supposed to be dangerous to change the compiler that macports uses. Currently I have not yet fixed the issue on my mac, but will try to do so soon.

@Mikaz-fr : Let me know if you were able to fix this issue.

Best, Pradeep.

Mikaz-fr commented 11 years ago

Ok, some progress on my side. First to answer: @amaesani : I don't use any IDE so far, I may try with Xcode when I understand fully what I'm doing. @prfernando : I used homebrew to handle the library, I found it relatively easy to use and I'll try to write an helping doc when thing will be working on my side.

So when I was trying to install Paradiseo for robogen-ea (that's another problem) I found out that my gcc (installed with from the latest Xcode) was far to be up to date. I updated it to 4.8 and I recompiled the robogen-simulator project specifying this new gcc (I didn't recompiled any dependencies). I have a great number of "warnings" that I don't understand, if you have an idea looking at the ouput (http://pastebin.com/wM0FL6G8) please let me know. Anyway the compilation passed and this time I was able to open a example with file view:

robogen-file-viewer1

As you can see there is some models not loading, I still have to investigate why. And also when I closed the window I had the same error output:

robogen-file-viewer(12168,0x7fff73b6d180) malloc: *** error for object 0x10a0d2da0: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
Abort trap: 6

This is encouraging progresses.

Also something we haven't discuss from my first message is why the library doesn't have the same name on my mac so I had to create a special rule in CustomPath.cmake. Some error might come from this too?

amaesani commented 11 years ago

Great job!

1) The warnings you see are all generated when compiling the robogen.pb.* These files are automatically generated by the google protobuf compiler, so we cannot do much about it. As far as I can see they are all triggered by the -Wshadow option in GCC, which checks for shadowed declarations. that means, if you have for example a class

class A {
int myVar;

    void myFunction(int myVar) {
        // Do Something
    }

}

it is complaining because the parameter name of one of the parameters of myFunction, namely myVar, has the same name of a variable of A.

2) About the models. Do you have the models/ folder in the same folder as the executable (robogen-file-viewer?). If not copy it there. If yes, it might be due to the lack of the STL plugin for OSG. In such a case, you must ensure that the STL plugin was compiled correctly and is in the path of your executable as well.

3) About the library names: on each platform dynamic/static libraries extensions might be different (e.g. Linux .so, MAC OS .dylib for dynamic libraries and so on...), so you did well to create an appropriate rule for MAC OS in the CustomPath.cmake.

Mikaz-fr commented 11 years ago

1) Ok I won't worry about this warnings anymore (I also have it in robogen-ea)

2) You're right, I deleted everything to recompile and this time I forgot to copy the /models folder. It's working fine now.

3) I'll open another thread with some instructions how to compile for mac when I'll be done writing it, and I'll include this rule.

There is still this malloc error issue remaining, but I think @prfernando is investigating it.

amaesani commented 11 years ago

Perfect, if you want you can push your modified version of CustomPath.cmake and directly modify the Readme.md for instructions on how to compile for MAC OS X.

Thanks a lot for your contribution, I'll insert you right now in the credits (just add your name/emaiil, you should see it at the beginning of the Readme.md file!

Regards, Andrea