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

New visualizer #21

Merged
merged 4 commits into from
Aug 27, 2024
Merged
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ log/
results/
_skbuild/
.gitlab-ci-local/
.polyscope.ini
imgui.ini

# Created by https://www.toptal.com/developers/gitignore/api/python,c++
# Edit at https://www.toptal.com/developers/gitignore?templates=python,c++
Expand Down
4 changes: 4 additions & 0 deletions src/mapmos/mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ def point_cloud_with_timestamps(self):
map_points, map_timestamps = self._internal_map._point_cloud_with_timestamps()
return np.asarray(map_points), np.asarray(map_timestamps)

def voxels_with_belief(self):
voxels, belief = self._internal_map._voxels_with_belief()
return np.asarray(voxels), np.asarray(belief)

def remove_voxels_far_from_location(self, location: np.ndarray):
self._internal_map._remove_far_away_points(location)

Expand Down
21 changes: 8 additions & 13 deletions src/mapmos/paper_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,19 +158,14 @@ def _run_pipeline(self):
torch.tensor(gt_labels, dtype=torch.int32),
)

belief_labels_scan = belief_labels_with_map
if self.visualize:
belief_map = self.belief.get_belief(map_points)
belief_labels_map = self.model.to_label(belief_map)
self.visualizer.update(
scan_points,
map_points,
pred_labels_scan,
pred_labels_map,
belief_labels_scan,
belief_labels_map,
self.odometry.last_pose,
)
self.visualizer.update(
scan_points,
map_points,
pred_labels_scan,
pred_labels_map,
self.belief,
self.odometry.last_pose,
)

# Probabilistic volumetric fusion with scan and moving map predictions and delay
self.buffer.append([scan_index, scan_points, gt_labels])
Expand Down
27 changes: 11 additions & 16 deletions src/mapmos/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def __init__(
# Visualizer
self.visualize = visualize
self.visualizer = MapMOSVisualizer() if visualize else StubVisualizer()

self.visualizer.set_voxel_size(self.config.mos.voxel_size_belief)
self.ply_writer = PlyWriter() if save_ply else StubWriter()
self.kitti_writer = KITTIWriter() if save_kitti else StubWriter()

Expand Down Expand Up @@ -174,22 +174,17 @@ def _run_pipeline(self):

start_time = time.perf_counter_ns()
self.belief.update_belief(points_stacked, logits_stacked)
belief_scan = self.belief.get_belief(scan_points)
self.belief.get_belief(scan_points)
self.times_belief.append(time.perf_counter_ns() - start_time)
belief_labels_scan = self.model.to_label(belief_scan)

if self.visualize:
belief_map = self.belief.get_belief(map_points)
belief_labels_map = self.model.to_label(belief_map)
self.visualizer.update(
scan_points,
map_points,
pred_labels_scan,
pred_labels_map,
belief_labels_scan,
belief_labels_map,
self.odometry.last_pose,
)

self.visualizer.update(
scan_points,
map_points,
pred_labels_scan,
pred_labels_map,
self.belief,
self.odometry.last_pose,
)

# Evaluate and save with delay
self.buffer.append([scan_index, scan_points, gt_labels])
Expand Down
11 changes: 11 additions & 0 deletions src/mapmos/pybind/VoxelHashMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,17 @@ std::tuple<std::vector<Eigen::Vector3d>, std::vector<int>> VoxelHashMap::Pointcl
return std::make_tuple(points, timestamps);
}

std::tuple<std::vector<VoxelHashMap::Voxel>, std::vector<double>> VoxelHashMap::VoxelsWithBelief()
const {
std::vector<Voxel> voxels;
std::vector<double> belief;
for (auto map_element : map_) {
voxels.push_back(map_element.first);
belief.push_back(map_element.second.belief.value_);
}
return make_tuple(voxels, belief);
}

void VoxelHashMap::Update(const std::vector<Eigen::Vector3d> &points,
const Eigen::Vector3d &origin,
const int timestamp) {
Expand Down
1 change: 1 addition & 0 deletions src/mapmos/pybind/VoxelHashMap.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ struct VoxelHashMap {
void RemovePointsFarFromLocation(const Eigen::Vector3d &origin);
std::vector<Eigen::Vector3d> Pointcloud() const;
std::tuple<std::vector<Eigen::Vector3d>, std::vector<int>> PointcloudWithTimestamps() const;
std::tuple<std::vector<Voxel>, std::vector<double>> VoxelsWithBelief() const;
std::vector<Eigen::Vector3d> GetPoints(const std::vector<Voxel> &query_voxels) const;

double voxel_size_;
Expand Down
1 change: 1 addition & 0 deletions src/mapmos/pybind/mapmos_pybind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ PYBIND11_MODULE(mapmos_pybind, m) {
.def("_remove_far_away_points", &VoxelHashMap::RemovePointsFarFromLocation, "origin"_a)
.def("_point_cloud", &VoxelHashMap::Pointcloud)
.def("_point_cloud_with_timestamps", &VoxelHashMap::PointcloudWithTimestamps)
.def("_voxels_with_belief", &VoxelHashMap::VoxelsWithBelief)
.def("_update_belief", &VoxelHashMap::UpdateBelief, "points"_a, "updates"_a)
.def("_get_belief", &VoxelHashMap::GetBelief, "points"_a);

Expand Down
Loading
Loading