-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add map editing examples for C++ API
- Loading branch information
1 parent
7392f41
commit a908112
Showing
9 changed files
with
127 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#include <memory> | ||
|
||
#include <wavemap/core/common.h> | ||
#include <wavemap/core/utils/edit/crop.h> | ||
#include <wavemap/io/file_conversions.h> | ||
|
||
int main(int, char**) { | ||
// Load the map | ||
const std::filesystem::path home_dir = CHECK_NOTNULL(getenv("HOME")); | ||
const std::filesystem::path input_map_path = home_dir / "your_map.wvmp"; | ||
wavemap::MapBase::Ptr map_base; | ||
bool success = wavemap::io::fileToMap(input_map_path, map_base); | ||
CHECK(success); | ||
|
||
// Downcast it to a concrete map type | ||
auto map = std::dynamic_pointer_cast<wavemap::HashedWaveletOctree>(map_base); | ||
CHECK_NOTNULL(map); | ||
|
||
// Crop the map | ||
const wavemap::Point3D t_W_center{-2.2, -1.4, 0.0}; | ||
const wavemap::FloatingPoint radius = 3.0; | ||
auto thread_pool = std::make_shared<wavemap::ThreadPool>(); // Optional | ||
wavemap::edit::crop_to_sphere(*map, t_W_center, radius, 0, thread_pool); | ||
|
||
// Save the map | ||
const std::filesystem::path output_map_path = | ||
home_dir / "your_map_cropped.wvmp"; | ||
success &= wavemap::io::mapToFile(*map, output_map_path); | ||
CHECK(success); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#include <memory> | ||
|
||
#include <wavemap/core/common.h> | ||
#include <wavemap/core/utils/edit/multiply.h> | ||
#include <wavemap/io/file_conversions.h> | ||
|
||
int main(int, char**) { | ||
// Load the map | ||
const std::filesystem::path home_dir = CHECK_NOTNULL(getenv("HOME")); | ||
const std::filesystem::path input_map_path = home_dir / "your_map.wvmp"; | ||
wavemap::MapBase::Ptr map_base; | ||
bool success = wavemap::io::fileToMap(input_map_path, map_base); | ||
CHECK(success); | ||
|
||
// Downcast it to a concrete map type | ||
auto map = std::dynamic_pointer_cast<wavemap::HashedWaveletOctree>(map_base); | ||
CHECK_NOTNULL(map); | ||
|
||
// Use the multiply method to implement exponential forgetting | ||
const wavemap::FloatingPoint decay_factor = 0.9; | ||
auto thread_pool = std::make_shared<wavemap::ThreadPool>(); // Optional | ||
wavemap::edit::multiply(*map, decay_factor, thread_pool); | ||
|
||
// Save the map | ||
const std::filesystem::path output_map_path = | ||
home_dir / "your_map_decayed.wvmp"; | ||
success &= wavemap::io::mapToFile(*map, output_map_path); | ||
CHECK(success); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#include <memory> | ||
|
||
#include <wavemap/core/common.h> | ||
#include <wavemap/core/utils/edit/crop.h> | ||
#include <wavemap/core/utils/edit/sum.h> | ||
#include <wavemap/core/utils/edit/transform.h> | ||
#include <wavemap/io/file_conversions.h> | ||
|
||
int main(int, char**) { | ||
// Load the map | ||
const std::filesystem::path home_dir = CHECK_NOTNULL(getenv("HOME")); | ||
const std::filesystem::path input_map_path = home_dir / "your_map.wvmp"; | ||
wavemap::MapBase::Ptr map_base; | ||
bool success = wavemap::io::fileToMap(input_map_path, map_base); | ||
CHECK(success); | ||
|
||
// Downcast it to a concrete map type | ||
auto map = std::dynamic_pointer_cast<wavemap::HashedWaveletOctree>(map_base); | ||
CHECK_NOTNULL(map); | ||
|
||
// Crop the map | ||
const wavemap::Point3D t_W_center{-2.2, -1.4, 0.0}; | ||
const wavemap::FloatingPoint radius = 3.0; | ||
auto thread_pool = std::make_shared<wavemap::ThreadPool>(); // Optional | ||
wavemap::edit::crop_to_sphere(*map, t_W_center, radius, 0, thread_pool); | ||
|
||
// Create a translated copy | ||
wavemap::Transformation3D T_AB; | ||
T_AB.getPosition() = {5.0, 5.0, 0.0}; | ||
auto map_translated = wavemap::edit::transform(*map, T_AB, thread_pool); | ||
|
||
// Merge them together | ||
wavemap::edit::sum(*map, *map_translated); | ||
|
||
// Save the map | ||
const std::filesystem::path output_map_path = | ||
home_dir / "your_map_merged.wvmp"; | ||
success &= wavemap::io::mapToFile(*map, output_map_path); | ||
CHECK(success); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters