Ask Your Question
0

Gazebo Error, OgreAdaptor.cc can not find rendering system

asked 2012-02-28 00:37:17 -0500

Erik_S gravatar image

updated 2012-02-29 01:25:03 -0500

Dear All,

I'm am still writing a C++ simulink file, i got communication up and running via ROSTOPICS(see this link).

However, due to the nature of my simulator/research i want to time simulink to run the same speed (x times real time). I've tried timers and other ros stuff, they just do not suffice (not accurate enough mostly). This is needed for causality.

Hence I'm trying to run/start gazebo myself from within my C++ simulink file, to be able to aces the simulator directly. And i was successful, but for some reason it is not running correctly any more(it was last week)!! Compilation is runs fine, but at runtime i get an error.

Right now I'm getting the following error in matlab:

/home/erik/ros/simulator_gazebo/gazebo/build/gazebo/server/rendering  /OgreAdaptor.cc:457 : Exception: unable to find rendering system

The error occurs after the following piece of code(basically the same as gazeboros.cpp).

/*Starting the Gazebo Simulator with all the neccesary paths*/
    gazebo::Simulator::Instance()->SetCreateOgreLog( optOgreLog );
    gazebo::Simulator::Instance()->SetGuiEnabled( optGuiEnabled );
    gazebo::Simulator::Instance()->SetRenderEngineEnabled( optRenderEngineEnabled );

  std::string ogre_package_name("ogre"); 
  std::string ogre_package_path = std::string("/home/s041723/ros/visualization_common/ogre/ogre/lib/OGRE");
  std::cerr << ogre_package_path << std::endl;

  gazebo::Simulator::Instance()->GetGazeboConfig()->AddOgrePaths(ogre_package_path);

  // set gazebo media paths by adding all packages that exports "gazebo_media_path" for gazebo
  gazebo::Simulator::Instance()->GetGazeboConfig()->ClearGazeboPaths();
  std::vector<std::string> gazebo_media_paths;
  ros::package::getPlugins("gazebo","gazebo_media_path",gazebo_media_paths);
  for (std::vector<std::string>::iterator iter=gazebo_media_paths.begin(); iter != gazebo_media_paths.end(); iter++)
  {
    ROS_DEBUG("med path %s",iter->c_str());
    gazebo::Simulator::Instance()->GetGazeboConfig()->AddGazeboPaths(iter->c_str());
  }

  // set gazebo plugins paths by adding all packages that exports "plugin" for gazebo
  gazebo::Simulator::Instance()->GetGazeboConfig()->ClearPluginPaths();
  std::vector<std::string> plugin_paths;
  ros::package::getPlugins("gazebo","plugin_path",plugin_paths);
  for (std::vector<std::string>::iterator iter=plugin_paths.begin(); iter != plugin_paths.end(); iter++)
  {
    ROS_DEBUG("plugin path %s",(*iter).c_str());
    gazebo::Simulator::Instance()->GetGazeboConfig()->AddPluginPaths(iter->c_str());
  }

  // set .gazeborc path to something else, so we don't pick up default ~/.gazeborc
  std::string gazeborc = ros::package::getPath("gazebo")+"/.do_not_use_gazeborc";
  setenv("GAZEBORC",gazeborc.c_str(),1);

    try
        {

            gazebo::Simulator::Instance()->LoadWorldFile(std::string("physics_setup.world"), optServerId);

            gazebo::Simulator::Instance()->SetTimeout(optTimeout);
            gazebo::Simulator::Instance()->SetPhysicsEnabled(optPhysicsEnabled);
        }
    catch (gazebo::GazeboError e)
        {
            std::cerr << "Error Loading Gazebo" << std::endl;
            std::cerr << e << std::endl;
            gazebo::Simulator::Instance()->Fini();
            ros::shutdown();
           // return -1;
      }

It crashes as soon as i call loadworldfile.

The weird thing is, i do not get this error when i compile and run the same outside of matlab. Which works perfectly fine.

Here is a piece of the stacktrace from the matlab error.

   Stack Trace (from fault):
[  0] 0xb76bd255     /usr/local/MATLAB/R2011b/bin/glnx86/libmwfl.so+00156245 _ZN2fl4diag15stacktrace_base7captureERKNS0_14thread_contextEj+000169
[  1] 0xb76c0175     /usr/local/MATLAB/R2011b/bin/glnx86/libmwfl.so+00168309
[  2] 0xb76c0569     /usr/local/MATLAB/R2011b/bin/glnx86/libmwfl.so+00169321 _ZN2fl4diag13terminate_logEPKcRKNS0_14thread_contextEb+000181
[  3] 0xb733b93f    /usr/local/MATLAB/R2011b/bin/glnx86/libmwmcr.so+00399679 _ZN2fl4diag13terminate_logEPKcPK8ucontextb+000096
[  4] 0xb7338996    /usr/local/MATLAB/R2011b/bin ...
(more)
edit retag flag offensive close merge delete

Comments

could it be a permissions issue? Maybe matlab starts some processes as a different user, try chmod 777 /dev/nvidia*?

hsu gravatar imagehsu ( 2012-02-28 06:50:58 -0500 )edit

The permissions for these files are crw-rw-rw-, so i dont really see an issue there.

Erik_S gravatar imageErik_S ( 2012-02-28 23:05:46 -0500 )edit

to clarify, you have a mex-version of gazeboros.cpp?

hsu gravatar imagehsu ( 2012-02-29 17:34:25 -0500 )edit

Yeah, basically i copied most of the 'main' from gazeboros.cpp into a S-function (C++). Which i mex compile. This file (the cpp S-function) is causing the headache at runtime inside matlab.

Erik_S gravatar imageErik_S ( 2012-03-01 22:48:28 -0500 )edit

can you try adding to ogrePaths the path to libOgreMain.so as well, as see if that helps?

hsu gravatar imagehsu ( 2012-03-02 03:03:17 -0500 )edit

Too bad, that didn't work either. Appreciate the help though!! For some reason in ogreadaptor.cc the line this->root->getAvailableRenderers(); returns empty when compiled in matlab. Maybe matlabs own openGL libs are interfering, allthough i would be strange since they didnt before.

Erik_S gravatar imageErik_S ( 2012-03-02 03:27:22 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2012-03-02 05:43:05 -0500

hsu gravatar image

hm, might have to dig into OgreRoot.cpp for that one.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2012-02-28 00:37:17 -0500

Seen: 319 times

Last updated: Feb 29 '12