@@ -89,34 +89,28 @@ SensorMap parseSensors(const std::string &xml_string, const SensorParserMap &par
89
89
90
90
SensorParserMap getSensorParsers (const std::vector<std::string> &allowed)
91
91
{
92
- static boost::mutex PARSER_PLUGIN_LOCK;
93
- static boost::shared_ptr<pluginlib::ClassLoader<urdf::SensorParser> > PARSER_PLUGIN_LOADER;
94
- boost::mutex::scoped_lock _ (PARSER_PLUGIN_LOCK);
95
-
92
+ pluginlib::ClassLoader<urdf::SensorParser> loader (" urdf" , " urdf::SensorParser" );
96
93
SensorParserMap parserMap;
97
94
try
98
95
{
99
- if (!PARSER_PLUGIN_LOADER)
100
- PARSER_PLUGIN_LOADER.reset (new pluginlib::ClassLoader<urdf::SensorParser>(" urdf" , " urdf::SensorParser" ));
101
-
102
- const std::vector<std::string> &classes = PARSER_PLUGIN_LOADER->getDeclaredClasses ();
103
- for (std::size_t i = 0 ; i < classes.size () ; ++i)
104
- {
105
- // skip this class if not listed in allowed
106
- if (!allowed.empty () && std::find (allowed.begin (), allowed.end (), classes[i]) == allowed.end ())
107
- continue ;
108
-
109
- urdf::SensorParserSharedPtr parser;
110
- try {
111
- parser = PARSER_PLUGIN_LOADER->createInstance (classes[i]);
112
- } catch (const pluginlib::PluginlibException& ex) {
113
- ROS_ERROR_STREAM (" Failed to create sensor parser: " << classes[i] << " \n " << ex.what ());
114
- }
115
- parserMap.insert (std::make_pair (classes[i], parser));
116
- ROS_DEBUG_STREAM (" added sensor parser: " << classes[i]);
96
+ const std::vector<std::string> &classes = loader.getDeclaredClasses ();
97
+ for (std::size_t i = 0 ; i < classes.size () ; ++i)
98
+ {
99
+ // skip this class if not listed in allowed
100
+ if (!allowed.empty () && std::find (allowed.begin (), allowed.end (), classes[i]) == allowed.end ())
101
+ continue ;
102
+
103
+ urdf::SensorParserSharedPtr parser;
104
+ try {
105
+ parser = loader.createInstance (classes[i]);
106
+ } catch (const pluginlib::PluginlibException& ex) {
107
+ ROS_ERROR_STREAM (" Failed to create sensor parser: " << classes[i] << " \n " << ex.what ());
117
108
}
118
- if (parserMap.empty ())
119
- ROS_WARN_STREAM (" No sensor parsers found" );
109
+ parserMap.insert (std::make_pair (classes[i], parser));
110
+ ROS_DEBUG_STREAM (" added sensor parser: " << classes[i]);
111
+ }
112
+ if (parserMap.empty ())
113
+ ROS_WARN_STREAM (" No sensor parsers found" );
120
114
}
121
115
catch (const pluginlib::PluginlibException& ex)
122
116
{
0 commit comments