Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update data download, demo configs, and readme #69

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 6 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,9 @@ The datasets described in the paper and used for the demo can be downloaded from

A utility script is provided to directly download the flat data:
```
roscd panoptic_mapping_utils
export FLAT_DATA_DIR="/home/$USER/Documents" # Or whichever path you prefer.
chmod +x panoptic_mapping_utils/scripts/download_flat_dataset.sh
./panoptic_mapping_utils/scripts/download_flat_dataset.sh
roscd panoptic_mapping_utils/scripts
chmod +x download_flat_dataset.sh
./download_flat_dataset.sh "/home/$USER/data" # Or whichever destination you prefer.
```

To run the RIO demos, the [original dataset](https://waldjohannau.github.io/RIO/) needs to be downloaded and augmented with [our supplementary data](https://projects.asl.ethz.ch/datasets/doku.php?id=panoptic_mapping). Instructions on which scenes to download and how to combine them are found on our dataset page.
Expand All @@ -216,12 +215,8 @@ To run the RIO demos, the [original dataset](https://waldjohannau.github.io/RIO/
## Running the Panoptic Mapper
This example explains how to run the Panoptic Multi-TSDF mapper on the flat dataset.

1. First, download the flat dataset:
```
export FLAT_DATA_DIR="/home/$USER/Documents" # Or whichever path you prefer.
chmod +x panoptic_mapping_utils/scripts/download_flat_dataset.sh
./panoptic_mapping_utils/scripts/download_flat_dataset.sh
```
1. If not already done so, download the flat dataset as explained [here](#datasets).

2. Replace the data `base_path` in `launch/run.launch (L10)` and `file_name` in `config/mapper/flat_groundtruth.yaml (L15)` to the downloaded path.
3. Run the mapper:
```
Expand All @@ -246,13 +241,7 @@ This example explains how to run the Panoptic Multi-TSDF mapper on the flat data
## Monolithic Semantic Mapping
Panoptic Mapping supports also the monolithic use case. This example explains how to run the Panoptic Single-TSDF mapper on the flat dataset.

1. If not already done so, download the flat dataset:

```
export FLAT_DATA_DIR="/home/$USER/Documents" # Or whichever path you prefer.
chmod +x panoptic_mapping_utils/scripts/download_flat_dataset.sh
./panoptic_mapping_utils/scripts/download_flat_dataset.sh
```
1. If not already done so, download the flat dataset as explained [here](#datasets).

2. Replace the data `base_path` in `launch/run.launch (L10)` and `file_name` in `config/mapper/single_tsdf.yaml (L15)` to the downloaded path.

Expand Down
143 changes: 121 additions & 22 deletions panoptic_mapping/include/panoptic_mapping/3rd_party/config_utilities.hpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/**
AUTHOR: Lukas Schmid <schmluk@mavt.ethz.ch>
AUTHOR: Lukas Schmid <schmluk@ethz.ch>
AFFILIATION: Autonomous Systems Lab (ASL), ETH Zürich
SOURCE: https://github.com/ethz-asl/config_utilities
VERSION: 1.2.2
VERSION: 1.3.1
LICENSE: BSD-3-Clause

Copyright 2020 Autonomous Systems Lab (ASL), ETH Zürich.
Expand Down Expand Up @@ -34,7 +34,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

// Raises a redefined warning if different versions are used. v=MMmmPP.
#define CONFIG_UTILITIES_VERSION 010202
#define CONFIG_UTILITIES_VERSION 010301

/**
* Depending on which headers are available, ROS dependencies are included in
Expand Down Expand Up @@ -64,6 +64,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <iomanip>
#include <map>
#include <memory>
#include <mutex>
#include <sstream>
#include <string>
#include <type_traits>
Expand All @@ -79,7 +80,9 @@ namespace config_utilities {
/**
* ==================== Settings ====================
*/
namespace internal {
// Forward declaration of access to all global tools.
struct Global;

/**
* @brief Global Settings for how config_utilities based configs behave. These
* can be dynamically set and changed throughout a project.
Expand Down Expand Up @@ -111,12 +114,6 @@ struct GlobalSettings {
private:
GlobalSettings() = default;
};
} // namespace internal

// Access.
inline internal::GlobalSettings& GlobalSettings() {
return internal::GlobalSettings::instance();
}

/**
* ==================== Utilities ====================
Expand Down Expand Up @@ -148,7 +145,7 @@ class RequiredArguments {
// Write old arguments.
*argc = old_args.size() + added_args.size();
argv_aux_ = std::vector<std::unique_ptr<char>>(*argc);
for (int i = 0; i < old_args.size(); ++i) {
for (size_t i = 0; i < old_args.size(); ++i) {
argv_aux_[i].reset(new char[std::strlen((*argv)[i]) + 1]);
strcpy(argv_aux_[i].get(), (*argv)[i]);
}
Expand Down Expand Up @@ -178,6 +175,7 @@ class RequiredArguments {
* ==================== Internal Utilities ====================
*/
namespace internal {

// Printing utilities.
inline std::string printCenter(const std::string& text, int width,
char symbol) {
Expand Down Expand Up @@ -430,8 +428,62 @@ struct VariableConfigInternal : public VariableConfigVerificator {
std::string type_ = "Not Setup";
std::unique_ptr<ConfigInternal> config_ = nullptr;

virtual void createConfig(const ParamMap& params, bool optional){};
virtual void createConfig(const ParamMap& params, bool optional) = 0;
};

/**
* ==================== Global Tracking of Configs ====================
*/

// Class to globally track all configs (or other things). Register the object in
// the global tracking databaseand remove it upon tracker destruction. This
// incurrs that the tracker should have the same lifespan as the tracked object.
// NOTE(schmluk): This is currently not thread safe.
template <typename T>
struct GlobalTracker {
public:
// Tracking via constructor and destructor. Objects are tracked in temporal
// order of creation.
explicit GlobalTracker(T* object) : object_(object) {
index_ = objects_.size();
objects_.push_back(this);
}

virtual ~GlobalTracker() {
objects_.erase(objects_.begin() + index_);
for (size_t i = index_; i < objects_.size(); ++i) {
objects_[i]->index_ = i;
}
}

GlobalTracker(const GlobalTracker& other) = delete;

GlobalTracker& operator=(const GlobalTracker& other) = delete;

GlobalTracker(GlobalTracker&& other) = delete;

GlobalTracker& operator=(GlobalTracker&& other) = delete;

// Access by copying the object pointers. NOTE(schmluk): Objects may seize to
// exist afterward. Maybe use ownership (shared_ptr) or so in the future?
static std::vector<T*> getObjects() {
std::vector<T*> result;
result.reserve(objects_.size());
for (GlobalTracker<T>* tracker : objects_) {
result.push_back(tracker->object_);
}
return result;
}

private:
T* object_;
size_t index_;
static std::vector<GlobalTracker<T>*> objects_;
};

template <typename T>
std::vector<GlobalTracker<T>*> GlobalTracker<T>::objects_;

} // namespace internal

/**
Expand All @@ -447,7 +499,7 @@ class ConfigChecker {
public:
explicit ConfigChecker(std::string module_name)
: name_(std::move(module_name)),
print_width_(GlobalSettings().print_width) {}
print_width_(GlobalSettings::instance().print_width) {}

/**
* @brief Return whether the config checker is valid, i.e. whether none of the
Expand All @@ -462,7 +514,7 @@ class ConfigChecker {
}
if (print_warnings) {
std::string sev = "Warning: ";
int length = print_width_ - sev.length();
const size_t length = print_width_ - sev.length();
std::string warning =
"\n" + internal::printCenter(name_, print_width_, '=');
for (std::string w : warnings_) {
Expand Down Expand Up @@ -634,10 +686,12 @@ struct ConfigInternal : public ConfigInternalVerificator {
public:
// Constructors.
explicit ConfigInternal(std::string name)
: name_(std::move(name)), meta_data_(new MetaData()) {}
: name_(std::move(name)), meta_data_(new MetaData()), tracker_(this) {}

ConfigInternal(const ConfigInternal& other)
: name_(other.name_), meta_data_(new MetaData(*(other.meta_data_))) {}
: name_(other.name_),
meta_data_(new MetaData(*(other.meta_data_))),
tracker_(this) {}

ConfigInternal& operator=(const ConfigInternal& other) {
name_ = other.name_;
Expand All @@ -646,7 +700,9 @@ struct ConfigInternal : public ConfigInternalVerificator {
}

ConfigInternal(ConfigInternal&& other)
: name_(other.name_), meta_data_(std::move(other.meta_data_)) {}
: name_(other.name_),
meta_data_(std::move(other.meta_data_)),
tracker_(this) {}

ConfigInternal& operator=(ConfigInternal&& other) {
if (&other != this) {
Expand All @@ -656,6 +712,10 @@ struct ConfigInternal : public ConfigInternalVerificator {
return *this;
}

// NOTE(schmluk): It's important the destructor is explicitly defined,
// otherwise trackers won't be destructed properly?
virtual ~ConfigInternal() = default;

// Public interaction with configs.

/**
Expand Down Expand Up @@ -1011,14 +1071,15 @@ struct ConfigInternal : public ConfigInternalVerificator {
return;
}
if (!meta_data_->use_printing_to_get_values) {
meta_data_->messages->emplace_back(
std::string(meta_data_->indent, ' ').append(text));
meta_data_->messages->emplace_back(
std::string(meta_data_->indent, ' ').append(text));
}
}

private:
friend std::unordered_map<std::string, std::string> getValues(
const ConfigInternal& config);
friend Global;

std::unordered_map<std::string, std::string> getValues() const {
// This is only used within printing, so meta data exists.
Expand Down Expand Up @@ -1091,7 +1152,7 @@ struct ConfigInternal : public ConfigInternalVerificator {
}

// First line could be shorter.
int length = GlobalSettings::instance().print_width - header.length();
size_t length = GlobalSettings::instance().print_width - header.length();
if (f.length() > length) {
meta_data_->messages->emplace_back(header + f.substr(0, length));
f = f.substr(length);
Expand Down Expand Up @@ -1162,7 +1223,7 @@ struct ConfigInternal : public ConfigInternalVerificator {
meta_data_->default_values.reset(nullptr);
meta_data_->indent = indent_prev;
meta_data_->merged_setup_currently_active = false;

meta_data_->global_printing_processed = true;
return result;
};

Expand Down Expand Up @@ -1616,6 +1677,7 @@ struct ConfigInternal : public ConfigInternalVerificator {
bool merged_setup_set_params = false;
bool merged_setup_currently_active = false;
bool use_printing_to_get_values = false;
bool global_printing_processed = false;

MetaData() = default;
MetaData(const MetaData& other) { indent = other.indent; }
Expand All @@ -1624,7 +1686,8 @@ struct ConfigInternal : public ConfigInternalVerificator {
std::string name_;
std::string param_namespace_ = "~";
std::unique_ptr<MetaData> meta_data_;
}; // namespace internal
GlobalTracker<ConfigInternal> tracker_;
};

// This is a dummy operator, configs provide toString().
inline std::ostream& operator<<(std::ostream& os, const ConfigInternal&) {
Expand All @@ -1635,11 +1698,47 @@ inline std::ostream& operator<<(std::ostream& os,
const VariableConfigVerificator&) {
return os;
}
} // namespace internal

/**
* ==================== Global Tools ====================
*/

// Access to global functionalities.
struct Global {
// Access to settings.
static GlobalSettings& Settings() { return GlobalSettings::instance(); }

// Print all configs in temporal order. NOTE(schmluk): VariableConfigs are not
// tracked by global trackers, since they always contain a standard config if
// setup.
static std::string printAllConfigs() {
std::string result;
for (internal::ConfigInternal* config :
internal::GlobalTracker<internal::ConfigInternal>::getObjects()) {
// Prime all configs for printing.
config->meta_data_->global_printing_processed = false;
}
for (internal::ConfigInternal* config :
internal::GlobalTracker<internal::ConfigInternal>::getObjects()) {
// Only print every config once, e.g. in case of member configs.
if (config->meta_data_->global_printing_processed) {
continue;
}
const std::string msg = config->toString();
result = result + msg.substr(0, msg.find_last_of("\n")) + "\n";
}
result = result + std::string(GlobalSettings::instance().print_width, '=');
return result;
}
};

/**
* ==================== Exposure Utilities ===================
*/

namespace internal {

inline void setupConfigFromParamMap(const ParamMap& params,
ConfigInternal* config) {
CHECK_NOTNULL(config);
Expand Down
6 changes: 2 additions & 4 deletions panoptic_mapping_ros/config/mapper/flat_detectron.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@ global_frame_name: world
visualization_interval: -1.0
data_logging_interval: -1.0
print_timing_interval: 0.0
max_input_queue_length: 1000
ros_spinning_threads: 8
max_input_queue_length: 30

labels:
type: csv
file_name: /home/lukas/Documents/Datasets/flat_dataset/detectron_labels.csv
file_name: /home/lukas/data/flat_dataset/detectron_labels.csv

camera:
verbosity: 1
Expand Down Expand Up @@ -73,7 +72,6 @@ tsdf_integrator:
max_weight: 10000
interpolation_method: adaptive # nearest, bilinear, adaptive
foreign_rays_clear: true
integration_threads: 8
allocate_neighboring_blocks: true

# Class Projective
Expand Down
6 changes: 2 additions & 4 deletions panoptic_mapping_ros/config/mapper/flat_groundtruth.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@ global_frame_name: world
visualization_interval: -1.0
data_logging_interval: -1.0
print_timing_interval: 0.0
max_input_queue_length: 1000
ros_spinning_threads: 8
max_input_queue_length: 30

labels:
type: csv
file_name: /home/lukas/Documents/Datasets/flat_dataset/groundtruth_labels.csv
file_name: /home/lukas/data/flat_dataset/groundtruth_labels.csv

camera:
verbosity: 1
Expand Down Expand Up @@ -72,7 +71,6 @@ tsdf_integrator:
max_weight: 10000
interpolation_method: adaptive # nearest, bilinear, adaptive
foreign_rays_clear: true
integration_threads: 8
allocate_neighboring_blocks: true

# Class Projective
Expand Down
Loading