gazebosim / gazebo-classic

Gazebo classic. For the latest version, see https://github.com/gazebosim/gz-sim
http://classic.gazebosim.org/
Other
1.15k stars 477 forks source link

Gazebo9 compile error with ogre1.11 #2475

Open osrf-migration opened 6 years ago

osrf-migration commented 6 years ago

Original report (archived issue) by CatchMe (Bitbucket: CatchMe_).


I got the following error when try to compile gazebo9 with ogre1.11 on Archlinux:

#!c++

/usr/include/OGRE/OgreSimpleRenderable.h:76:22: note:   no known conversion for argument 1 from ‘std::__cxx11::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const MaterialPtr&’ {aka ‘const Ogre::SharedPtr<Ogre::Material>&’}

in

#!bash

src/gazebo-9.0.0/gazebo/rendering/ApplyWrenchVisual.cc:178:57: error: no matching function for call to ‘gazebo::rendering::DynamicLines::setMaterial(std::__cxx11::string&)’
   dPtr->torqueLine->setMaterial(dPtr->unselectedMaterial);
#!bash

Building CXX object gazebo/rendering/CMakeFiles/gazebo_rendering.dir/ApplyWrenchVisual.cc.o

Then I used this patch

#!patch

--- src/gazebo-9.0.0/gazebo/rendering/ApplyWrenchVisual.cc  2018-01-26 00:25:48.b08146bc5bb3d274e85b2f20961ff9ec369a44fa +0200
+++ ApplyWrenchVisual.cc    2018-05-28 17:58:27.411689473 +0200
@@ -17,7 +17,7 @@

 #include <ignition/math/Color.hh>
 #include <ignition/math/Matrix4.hh>
-
+#include <OGRE/OgreMaterialManager.h>
 #include "gazebo/common/MeshManager.hh"

 #include "gazebo/rendering/Material.hh"
@@ -175,7 +175,7 @@
   // Torque line
   dPtr->torqueLine = dPtr->torqueVisual->
       CreateDynamicLine(rendering::RENDERING_LINE_LIST);
-  dPtr->torqueLine->setMaterial(dPtr->unselectedMaterial);
+  dPtr->torqueLine->setMaterial(Ogre::MaterialManager::getSingleton().getByName(dPtr->unselectedMaterial));
   dPtr->torqueLine->AddPoint(0, 0, 0);
   dPtr->torqueLine->AddPoint(0, 0, 0.1);

and it compiled, but got these errorsfor Building CXX object gazebo/rendering/CMakeFiles/gazebo_rendering.dir/Camera.cc.o :

#!error

/src/gazebo-9.0.0/gazebo/rendering/Camera.cc:1616:9: error: ‘class Ogre::AxisAlignedBox’ has no member named ‘transformAffine’; did you mean ‘transform’?
     box.transformAffine(_visual->GetSceneNode()->_getFullTransform());

src/gazebo-9.0.0/gazebo/rendering/Camera.cc:1832:32: error: ‘class Ogre::RenderTarget’ has no member named ‘getAverageFPS’
     return this->renderTarget->getAverageFPS();

src/gazebo-9.0.0/gazebo/rendering/Camera.cc:1840:30: error: ‘class Ogre::RenderTarget’ has no member named ‘getTriangleCount’; did you mean ‘mFrameCount’?
   return this->renderTarget->getTriangleCount();

I don't why didi it compile before ogre1.11 and now not?

Thanks in advance

osrf-migration commented 6 years ago

Original comment by CatchMe (Bitbucket: CatchMe_).


osrf-migration commented 6 years ago

Original comment by Nicolai Waniek (Bitbucket: rochus).


I tried to compile gazebo 9.0.0 against ogre 1.11 on Arch Linux as well and fixed all the compilation errors using the ogre documentation (see below for link to files).

Please note that this leaves a multitude of deprecation warnings unaddressed. Moreover, I'm neither a gazebo nor an ogre developer, and only followed ogre 1.11's documentation and tried to get rid of the compilation errors. At the moment, gazebo compiles and starts, but gives me only a black screen instead of the 3D view. That may be the result of one of the changes that I introduced. In addition, there are some things were I question gazebo's implementation. For instance, gazebo has almost completely re-implemented (copied?) the ShaderHelper classes (ogre: part of the Terrain component, gazebo: within Heightmap.cc). Because ogre 1.11 doesn't expose the symbols for ShaderHelper* any longer in libOgreTerrain.so, gazebo cannot derive its own classes from it. However, because from a source-code level it's almost a 1:1 copy, I don't see the point in having this part of code in gazebo... To solve the compilation issues, I simply removed gazebo's classes that were derived from ShaderHelper*. That, however, could be one of the reasons why I get a black screen right now.

You see, the "patch" just fixes the compilation issues, and should be considered only as a starting point right now.

AUR package discussion: https://aur.archlinux.org/packages/gazebo/ PKGBUILD: https://gist.github.com/rochus/547b26bc85a39195e3d1833280798855 ogre-1.11.patch: https://gist.github.com/rochus/003b156bcc8368c8c353be12b748986e

osrf-migration commented 6 years ago

Original comment by Ian Chen (Bitbucket: Ian Chen, GitHub: iche033).


Regarding the ShaderHelper code in Heightmap.cc. I think the ogre terrain GLSL shader generation code wasn't quite working at the time so we had to subclass it and make some fixes. Over time, we made more changes for it to work on OSX. That was a while ago so hopefully it's better now with ogre-1.11.

osrf-migration commented 6 years ago

Original comment by Fan Jiang (Bitbucket: proffan).


@rochus Tried to compile on Arch Linux with your patch today. Found out that Gazebo still needs one patch in gazebo/rendering/RenderEngine.cc at line 427:

+++
#if (OGRE_VERSION >= ((1 << 16) | (11 << 8) | 0))
    plugins.push_back(path+"/Codec_EXR");
    plugins.push_back(path+"/Codec_FreeImage");
#endif

    plugins.push_back(path+"/RenderSystem_GL");
    plugins.push_back(path+"/Plugin_ParticleFX");
    plugins.push_back(path+"/Plugin_BSPSceneManager");
    plugins.push_back(path+"/Plugin_OctreeSceneManager");

Plus you need to use asp export ogre to get the PKGBUILD of Ogre 1.11 and change the cmake options:

  cmake .. \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DOGRE_BUILD_DEPENDENCIES=FALSE \
    -DCMAKE_BUILD_TYPE=RelWithDebInfo \
    -DOpenGL_GL_PREFERENCE=GLVND \
    -DOGRE_BUILD_PLUGIN_FREEIMAGE=TRUE

Confirmed that Gazebo 9.0.0 works seamlessly after these patches.