Skip to content

Commit 77b3563

Browse files
authored
Merge pull request #46 from VRichardJP/patch-2
Fix MapNode crash when target directory does not exist
2 parents 75c875f + bd16def commit 77b3563

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

src/dlio/map.cc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212

1313
#include "dlio/map.h"
1414

15+
#include <filesystem>
16+
1517
dlio::MapNode::MapNode(ros::NodeHandle node_handle) : nh(node_handle) {
1618

1719
this->getParams();
@@ -81,6 +83,12 @@ bool dlio::MapNode::savePcd(direct_lidar_inertial_odometry::save_pcd::Request& r
8183
float leaf_size = req.leaf_size;
8284
std::string p = req.save_path;
8385

86+
if (!std::filesystem::is_directory(p)) {
87+
std::cout << "Could not find directory " << p << std::endl;
88+
res->success = false;
89+
return;
90+
}
91+
8492
std::cout << std::setprecision(2) << "Saving map to " << p + "/dlio_map.pcd"
8593
<< " with leaf size " << to_string_with_precision(leaf_size, 2) << "... "; std::cout.flush();
8694

0 commit comments

Comments
 (0)