From b6186a8f75fe7a60fe0999cdfde96a797655920b Mon Sep 17 00:00:00 2001 From: Nate Koenig Date: Mon, 2 May 2022 09:09:45 -0700 Subject: [PATCH] Fix running simulation with no world specified on the command line (#1463) Signed-off-by: Nate Koenig Co-authored-by: Nate Koenig --- include/ignition/gazebo/ServerConfig.hh | 3 ++- src/ServerConfig.cc | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/include/ignition/gazebo/ServerConfig.hh b/include/ignition/gazebo/ServerConfig.hh index 7311d092e8..2afae36d32 100644 --- a/include/ignition/gazebo/ServerConfig.hh +++ b/include/ignition/gazebo/ServerConfig.hh @@ -172,7 +172,8 @@ namespace ignition /// Setting the SDF file will override any value set by `SetSdfString`. /// /// \param[in] _file Full path to an SDF file. - /// \return (reserved for future use) + /// \return True if the file was set, false if the file was not set. + /// The file will not be set if the provide _file string is empty. public: bool SetSdfFile(const std::string &_file); /// \brief Get the SDF file that has been set. An empty string will be diff --git a/src/ServerConfig.cc b/src/ServerConfig.cc index 1024eb5d11..d410168d09 100644 --- a/src/ServerConfig.cc +++ b/src/ServerConfig.cc @@ -327,6 +327,9 @@ ServerConfig::~ServerConfig() = default; ////////////////////////////////////////////////// bool ServerConfig::SetSdfFile(const std::string &_file) { + if (_file.empty()) + return false; + this->dataPtr->source = ServerConfig::SourceType::kSdfFile; this->dataPtr->sdfFile = _file; this->dataPtr->sdfString = "";