Skip to content

Commit

Permalink
feat: update to colorize points by their distances (#15)
Browse files Browse the repository at this point in the history
Signed-off-by: ktro2828 <[email protected]>
  • Loading branch information
ktro2828 authored Jul 20, 2024
1 parent 5bead7a commit 756f353
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions awviz/src/rerun_ros_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@

#include <cmath>
#include <cstdint>
#include <cstring>
#include <string>
#include <vector>

Expand Down Expand Up @@ -90,15 +89,14 @@ void logPointCloud(
sensor_msgs::PointCloud2ConstIterator<float> itr_y(*msg, "y");
sensor_msgs::PointCloud2ConstIterator<float> itr_z(*msg, "z");

// TODO(ktro2828): update method retrieving colormap values
std::vector<rerun::Position3D> points(msg->width * msg->height);
std::vector<float> values(msg->width * msg->height);
std::vector<float> distances(msg->width * msg->height);
for (; itr_x != itr_x.end(); ++itr_x, ++itr_y, ++itr_z) {
points.emplace_back(*itr_x, *itr_y, *itr_z);
values.emplace_back(*itr_z);
distances.emplace_back(std::hypot(*itr_x, *itr_y, *itr_z));
}

auto colors = colormap(values);
auto colors = colormap(distances);
stream.log(entity, rerun::Points3D(points).with_colors(colors));
}

Expand Down

0 comments on commit 756f353

Please sign in to comment.