Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <gazebo/common/SystemPaths.hh>
00023 #include <gazebo/common/Plugin.hh>
00024
00025 #include <ros/ros.h>
00026 #include <ros/package.h>
00027
00028 #include <map>
00029
00030 namespace gazebo
00031 {
00032
00033 typedef std::vector<std::string> V_string;
00034 typedef std::map<std::string, std::string> M_string;
00035
00036 class GazeboRosPathsPlugin : public SystemPlugin
00037 {
00038 public:
00039 GazeboRosPathsPlugin()
00040 {
00041 this->LoadPaths();
00042 }
00043
00044 ~GazeboRosPathsPlugin()
00045 {
00046 };
00047
00048 void Init()
00049 {
00050 }
00051
00052 void Load(int argc, char** argv)
00053 {
00054 }
00055
00060 void LoadPaths()
00061 {
00062
00063 gazebo::common::SystemPaths::Instance()->gazeboPathsFromEnv = false;
00064 std::vector<std::string> gazebo_media_paths;
00065 ros::package::getPlugins("gazebo_ros","gazebo_media_path",gazebo_media_paths);
00066 for (std::vector<std::string>::iterator iter=gazebo_media_paths.begin(); iter != gazebo_media_paths.end(); iter++)
00067 {
00068 ROS_DEBUG("med path %s",iter->c_str());
00069 gazebo::common::SystemPaths::Instance()->AddGazeboPaths(iter->c_str());
00070 }
00071
00072
00073 gazebo::common::SystemPaths::Instance()->pluginPathsFromEnv = false;
00074 std::vector<std::string> plugin_paths;
00075 ros::package::getPlugins("gazebo_ros","plugin_path",plugin_paths);
00076 for (std::vector<std::string>::iterator iter=plugin_paths.begin(); iter != plugin_paths.end(); iter++)
00077 {
00078 ROS_DEBUG("plugin path %s",(*iter).c_str());
00079 gazebo::common::SystemPaths::Instance()->AddPluginPaths(iter->c_str());
00080 }
00081
00082
00083 gazebo::common::SystemPaths::Instance()->modelPathsFromEnv = false;
00084 std::vector<std::string> model_paths;
00085 ros::package::getPlugins("gazebo_ros","gazebo_model_path",model_paths);
00086 for (std::vector<std::string>::iterator iter=model_paths.begin(); iter != model_paths.end(); iter++)
00087 {
00088 ROS_DEBUG("model path %s",(*iter).c_str());
00089 gazebo::common::SystemPaths::Instance()->AddModelPaths(iter->c_str());
00090 }
00091
00092
00093 std::string gazeborc = ros::package::getPath("gazebo_ros")+"/.do_not_use_gazeborc";
00094 setenv("GAZEBORC",gazeborc.c_str(),1);
00095 }
00096
00097 };
00098
00099
00100 GZ_REGISTER_SYSTEM_PLUGIN(GazeboRosPathsPlugin)
00101
00102 }
00103