diff --git a/core/src/point_clouds.cpp b/core/src/point_clouds.cpp index 33ca9853..f0725cec 100644 --- a/core/src/point_clouds.cpp +++ b/core/src/point_clouds.cpp @@ -43,7 +43,7 @@ bool PointClouds::load( std::getline(infile, line); std::istringstream iss(line); - int num_scans; + int num_scans = 0; iss >> num_scans; std::cout << "number of scans: " << num_scans << std::endl; @@ -133,13 +133,13 @@ bool PointClouds::update_poses_from_RESSO(const std::string& folder_with_point_c if (!infile.good()) { std::cout << "problem with file: '" << poses_file_name << "' (!infile.good())" << std::endl; - // return false; + return false; } std::string line; std::getline(infile, line); std::istringstream iss(line); - int num_scans; + int num_scans = 0; iss >> num_scans; std::cout << "number of scans: " << num_scans << std::endl; @@ -226,13 +226,13 @@ bool PointClouds::update_poses_from_RESSO_inverse(const std::string& folder_with if (!infile.good()) { std::cout << "problem with file: '" << poses_file_name << "' (!infile.good())" << std::endl; - // return false; + return false; } std::string line; std::getline(infile, line); std::istringstream iss(line); - int num_scans; + int num_scans = 0; iss >> num_scans; std::cout << "number of scans: " << num_scans << std::endl; @@ -330,7 +330,7 @@ bool PointClouds::update_initial_poses_from_RESSO(const std::string& folder_with std::getline(infile, line); std::istringstream iss(line); - int num_scans; + int num_scans = 0; iss >> num_scans; std::cout << "number of scans: " << num_scans << std::endl; diff --git a/core/src/session.cpp b/core/src/session.cpp index af012137..3f882d63 100644 --- a/core/src/session.cpp +++ b/core/src/session.cpp @@ -219,17 +219,25 @@ bool Session::load(const std::string& file_name, bool is_decimate, double bucket std::cout << "updated: " << point_clouds_container.point_clouds.size() << " point_clouds" << std::endl; } - if (!point_clouds_container.update_poses_from_RESSO(working_directory.c_str(), poses_file_name.c_str())) + // fallback + std::string poses_source_file_name = poses_file_name; + std::error_code ec; + if (!fs::exists(poses_file_name, ec) || fs::file_size(poses_file_name, ec) == 0) + { + std::cout << "poses file '" << poses_file_name << "' is missing or empty, using initial poses from '" + << initial_poses_file_name << "'" << std::endl; + poses_source_file_name = initial_poses_file_name; + } + + if (!point_clouds_container.update_poses_from_RESSO(working_directory.c_str(), poses_source_file_name.c_str())) { std::cout << __FILE__ << " " << __LINE__ << std::endl; std::cout << "check input files" << std::endl; return false; } - else - { - std::cout << "updated: " << point_clouds_container.point_clouds.size() << " point_clouds" << std::endl; - point_clouds_container.poses_file_name = poses_file_name; - } + + std::cout << "updated: " << point_clouds_container.point_clouds.size() << " point_clouds" << std::endl; + point_clouds_container.poses_file_name = poses_file_name; } pose_graph_loop_closure.edges = loop_closure_edges;