Pull requests

#291 Merged
Repository
ffurrer ffurrer
Branch
default
Repository
osrf osrf
Branch
default

Added ClearModelPaths and AddModelPaths for the ModelPath, analog to the other system paths

Author
  1. Fadri Furrer
Reviewers
Description

This can be used to set up the environment for gazebo_simulator in ROS with the following patch for gazebo_simulator's gazebo_ros_paths_plugin:

Index: gazebo/src/gazebo_ros_paths_plugin.cpp
===================================================================
--- gazebo/src/gazebo_ros_paths_plugin.cpp  (revision 40361)
+++ gazebo/src/gazebo_ros_paths_plugin.cpp  (working copy)
@@ -151,7 +151,7 @@
       */

       // set gazebo media paths by adding all packages that exports "gazebo_media_path" for gazebo
-      gazebo::common::SystemPaths::Instance()->ClearGazeboPaths();
+      //gazebo::common::SystemPaths::Instance()->ClearGazeboPaths();
       gazebo::common::SystemPaths::Instance()->gazeboPathsFromEnv = false;
       std::vector<std::string> gazebo_media_paths;
       rosPackageGetPluginsDebug("gazebo","gazebo_media_path",gazebo_media_paths);
@@ -161,8 +161,8 @@
         gazebo::common::SystemPaths::Instance()->AddGazeboPaths(iter->c_str());
       }

-      // set gazebo plugins paths by adding all packages that exports "plugin" for gazebo
-      gazebo::common::SystemPaths::Instance()->ClearPluginPaths();
+      // set gazebo plugins paths by adding all packages that exports "plugin_path" for gazebo
+      //gazebo::common::SystemPaths::Instance()->ClearPluginPaths();
       gazebo::common::SystemPaths::Instance()->pluginPathsFromEnv = false;
       std::vector<std::string> plugin_paths;
       rosPackageGetPluginsDebug("gazebo","plugin_path",plugin_paths);
@@ -172,6 +172,17 @@
         gazebo::common::SystemPaths::Instance()->AddPluginPaths(iter->c_str());
       }

+      // set model paths by adding all packages that exports "gazebo_model_path" for gazebo
+      //gazebo::common::SystemPaths::Instance()->ClearModelPaths();
+      gazebo::common::SystemPaths::Instance()->modelPathsFromEnv = false;
+      std::vector<std::string> model_paths;
+      rosPackageGetPluginsDebug("gazebo","gazebo_model_path",model_paths);
+      for (std::vector<std::string>::iterator iter=model_paths.begin(); iter != model_paths.end(); iter++)
+      {
+        ROS_DEBUG("model path %s",(*iter).c_str());
+        gazebo::common::SystemPaths::Instance()->AddModelPaths(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);

Comments (1)

  1. Fadri Furrer author

    I'm not sure why you are clearing all the paths, but for me it was more convenient not to clear them such that all the gazebo stuff is still available.