fix filesystem warnings

This commit is contained in:
Vladyslav Usenko 2020-04-28 19:35:04 +02:00
parent b90f08eaeb
commit c5191cec35
3 changed files with 79 additions and 11 deletions

View File

@ -1,4 +1,70 @@
#pragma once
// Check for feature test macro for <filesystem>
#if defined(__cpp_lib_filesystem)
#define INCLUDE_STD_FILESYSTEM_EXPERIMENTAL 0
// Check for feature test macro for <experimental/filesystem>
#elif defined(__cpp_lib_experimental_filesystem)
#define INCLUDE_STD_FILESYSTEM_EXPERIMENTAL 1
// We can't check if headers exist...
// Let's assume experimental to be safe
#elif !defined(__has_include)
#define INCLUDE_STD_FILESYSTEM_EXPERIMENTAL 1
// Check if the header "<filesystem>" exists
#elif __has_include(<filesystem>)
// If we're compiling on Visual Studio and are not compiling with C++17, we need
// to use experimental
#ifdef _MSC_VER
// Check and include header that defines "_HAS_CXX17"
#if __has_include(<yvals_core.h>)
#include <yvals_core.h>
// Check for enabled C++17 support
#if defined(_HAS_CXX17) && _HAS_CXX17
// We're using C++17, so let's use the normal version
#define INCLUDE_STD_FILESYSTEM_EXPERIMENTAL 0
#endif
#endif
// If the marco isn't defined yet, that means any of the other VS specific
// checks failed, so we need to use experimental
#ifndef INCLUDE_STD_FILESYSTEM_EXPERIMENTAL
#define INCLUDE_STD_FILESYSTEM_EXPERIMENTAL 1
#endif
// Not on Visual Studio. Let's use the normal version
#else // #ifdef _MSC_VER
#define INCLUDE_STD_FILESYSTEM_EXPERIMENTAL 0
#endif
// Check if the header "<filesystem>" exists
#elif __has_include(<experimental/filesystem>)
#define INCLUDE_STD_FILESYSTEM_EXPERIMENTAL 1
// Fail if neither header is available with a nice error message
#else
#error Could not find system header "<filesystem>" or "<experimental/filesystem>"
#endif
// We priously determined that we need the exprimental version
#if INCLUDE_STD_FILESYSTEM_EXPERIMENTAL
#include <experimental/filesystem>
namespace basalt {
namespace fs = std::experimental::filesystem;
}
// We have a decent compiler and can use the normal version
#else
#include <filesystem>
namespace basalt {
namespace fs = std::filesystem;
}
#endif

View File

@ -237,13 +237,13 @@ void startRecording(const std::string &dir_path) {
dataset_dir = dir_path + "dataset_" + get_date() + "/";
fs::create_directory(dataset_dir);
fs::create_directory(dataset_dir + "mav0/");
fs::create_directory(dataset_dir + "mav0/cam0/");
fs::create_directory(dataset_dir + "mav0/cam0/data/");
fs::create_directory(dataset_dir + "mav0/cam1/");
fs::create_directory(dataset_dir + "mav0/cam1/data/");
fs::create_directory(dataset_dir + "mav0/imu0/");
basalt::fs::create_directory(dataset_dir);
basalt::fs::create_directory(dataset_dir + "mav0/");
basalt::fs::create_directory(dataset_dir + "mav0/cam0/");
basalt::fs::create_directory(dataset_dir + "mav0/cam0/data/");
basalt::fs::create_directory(dataset_dir + "mav0/cam1/");
basalt::fs::create_directory(dataset_dir + "mav0/cam1/data/");
basalt::fs::create_directory(dataset_dir + "mav0/imu0/");
cam_data[0].open(dataset_dir + "mav0/cam0/data.csv");
cam_data[1].open(dataset_dir + "mav0/cam1/data.csv");
@ -252,7 +252,7 @@ void startRecording(const std::string &dir_path) {
imu0_data.open(dataset_dir + "mav0/imu0/data.csv");
if (!manual_exposure) {
fs::create_directory(dataset_dir + "mav0/realsense0/");
basalt::fs::create_directory(dataset_dir + "mav0/realsense0/");
pose_data.open(dataset_dir + "mav0/realsense0/data.csv");
pose_data << "#timestamp [ns], p_RS_R_x [m], p_RS_R_y [m], p_RS_R_z [m], "
"q_RS_w [], q_RS_x [], q_RS_y [], q_RS_z []\n";

View File

@ -414,13 +414,15 @@ int main(int argc, char **argv) {
std::string save_button_name = "ui.save_aligned_dataset";
// Disable save_aligned_dataset button if GT data already exists
if (fs::exists(fs::path(dataset_path + "mav0/gt/data.csv"))) {
if (basalt::fs::exists(
basalt::fs::path(dataset_path + "mav0/gt/data.csv"))) {
save_button_name += "(disabled)";
}
pangolin::Var<std::function<void(void)>> save_aligned_dataset(
save_button_name, [&]() {
if (fs::exists(fs::path(dataset_path + "mav0/gt/data.csv"))) {
if (basalt::fs::exists(
basalt::fs::path(dataset_path + "mav0/gt/data.csv"))) {
std::cout << "Aligned ground-truth data already exists, skipping. "
"If you want to run the calibration again delete "
<< dataset_path << "mav0/gt/ folder." << std::endl;
@ -431,7 +433,7 @@ int main(int argc, char **argv) {
// output corrected mocap data
Sophus::SE3d T_mark_i;
if (use_calib) T_mark_i = mocap_calib.T_i_mark.inverse();
fs::create_directory(dataset_path + "mav0/gt/");
basalt::fs::create_directory(dataset_path + "mav0/gt/");
std::ofstream gt_out_stream;
gt_out_stream.open(dataset_path + "mav0/gt/data.csv");
gt_out_stream