diff --git a/urdf/src/sensor.cpp b/urdf/src/sensor.cpp index 08a9a1e3..a7819b71 100644 --- a/urdf/src/sensor.cpp +++ b/urdf/src/sensor.cpp @@ -91,12 +91,12 @@ SensorParserMap getSensorParsers(const std::vector &allowed) { static boost::mutex PARSER_PLUGIN_LOCK; static boost::shared_ptr > PARSER_PLUGIN_LOADER; - static SensorParserMap defaultParserMap; - boost::mutex::scoped_lock _(PARSER_PLUGIN_LOCK); + + SensorParserMap parserMap; try { - if (!PARSER_PLUGIN_LOADER) { + if (!PARSER_PLUGIN_LOADER) PARSER_PLUGIN_LOADER.reset(new pluginlib::ClassLoader("urdf", "urdf::SensorParser")); const std::vector &classes = PARSER_PLUGIN_LOADER->getDeclaredClasses(); @@ -112,18 +112,17 @@ SensorParserMap getSensorParsers(const std::vector &allowed) } catch(const pluginlib::PluginlibException& ex) { ROS_ERROR_STREAM("Failed to create sensor parser: " << classes[i] << "\n" << ex.what()); } - defaultParserMap.insert(std::make_pair(classes[i], parser)); + parserMap.insert(std::make_pair(classes[i], parser)); ROS_DEBUG_STREAM("added sensor parser: " << classes[i]); } - if (defaultParserMap.empty()) + if (parserMap.empty()) ROS_WARN_STREAM("No sensor parsers found"); - } } catch(const pluginlib::PluginlibException& ex) { ROS_ERROR_STREAM("Exception while creating sensor plugin loader " << ex.what()); } - return defaultParserMap; + return parserMap; } SensorParserMap getSensorParser(const std::string &name)