From 5d9c4893272d3ca063bdb68057ae6c1b07937323 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Joan=20Sol=C3=A0?= <jsola@iri.upc.edu>
Date: Wed, 18 Apr 2018 20:35:58 +0200
Subject: [PATCH] fix assert when empty file name

---
 src/problem.cpp | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/src/problem.cpp b/src/problem.cpp
index 856fde6f3..86d424bad 100644
--- a/src/problem.cpp
+++ b/src/problem.cpp
@@ -99,10 +99,10 @@ SensorBasePtr Problem::installSensor(const std::string& _sen_type, //
                                      const Eigen::VectorXs& _extrinsics, //
                                      const std::string& _intrinsics_filename)
 {
-    assert(file_exists(_intrinsics_filename) && "Cannot install sensor: intrinsics' YAML file does not exist.");
 
     if (_intrinsics_filename != "")
     {
+        assert(file_exists(_intrinsics_filename) && "Cannot install sensor: intrinsics' YAML file does not exist.");
         IntrinsicsBasePtr intr_ptr = IntrinsicsFactory::get().create(_sen_type, _intrinsics_filename);
         return installSensor(_sen_type, _unique_sensor_name, _extrinsics, intr_ptr);
     }
@@ -143,8 +143,6 @@ ProcessorBasePtr Problem::installProcessor(const std::string& _prc_type, //
                                            const std::string& _corresponding_sensor_name, //
                                            const std::string& _params_filename)
 {
-    assert(file_exists(_params_filename) && "Cannot install processor: parameters' YAML file does not exist.");
-
     SensorBasePtr sen_ptr = getSensorPtr(_corresponding_sensor_name);
     if (sen_ptr == nullptr)
         throw std::runtime_error("Sensor not found. Cannot bind Processor.");
@@ -152,6 +150,7 @@ ProcessorBasePtr Problem::installProcessor(const std::string& _prc_type, //
         return installProcessor(_prc_type, _unique_processor_name, sen_ptr, nullptr);
     else
     {
+        assert(file_exists(_params_filename) && "Cannot install processor: parameters' YAML file does not exist.");
         ProcessorParamsBasePtr prc_params = ProcessorParamsFactory::get().create(_prc_type, _params_filename);
         return installProcessor(_prc_type, _unique_processor_name, sen_ptr, prc_params);
     }
-- 
GitLab