From 6a8202411e3ea00fc22b197c248caac56f271fd9 Mon Sep 17 00:00:00 2001 From: azhural Date: Thu, 5 Apr 2018 18:45:41 +0200 Subject: [PATCH] strip comments from parsed urdf (#695) Remove comments from urdf before trying to find packages. Otherwise non-existant packages will produce a fatal error, even though they are not used. --- gazebo_ros/src/gazebo_ros_api_plugin.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/gazebo_ros/src/gazebo_ros_api_plugin.cpp b/gazebo_ros/src/gazebo_ros_api_plugin.cpp index 2459ac08f..61b02e6af 100644 --- a/gazebo_ros/src/gazebo_ros_api_plugin.cpp +++ b/gazebo_ros/src/gazebo_ros_api_plugin.cpp @@ -576,6 +576,18 @@ bool GazeboRosApiPlugin::spawnURDFModel(gazebo_msgs::SpawnModel::Request &req, if (pos1 != std::string::npos && pos2 != std::string::npos) model_xml.replace(pos1,pos2-pos1+2,std::string("")); } + + // Remove comments from URDF + { + std::string open_comment(""); + size_t pos1; + while((pos1 = model_xml.find(open_comment,0)) != std::string::npos){ + size_t pos2 = model_xml.find(close_comment,0); + if (pos2 != std::string::npos) + model_xml.replace(pos1,pos2-pos1+3,std::string("")); + } + } // Now, replace package://xxx with the full path to the package {