-
Notifications
You must be signed in to change notification settings - Fork 12
update Rerun API V0.18.2 #16
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
30c8339
chore: bump rerun API compatibiliy to 0.18.2
tfoldi 503b5a4
format: apply clang-format
tfoldi 9e4cead
chore: use img_data_as_collection everywhere
tfoldi b9e280f
chore: trying to find out the proper way to use Adapters
tfoldi b36a0e4
feat: add rgb8 color mode for pc2
tfoldi b0f5a35
chore: apply suggestions from code review
tfoldi eeb63ae
style: reformat
tfoldi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 |
---|---|---|
|
@@ -116,11 +116,7 @@ void log_image( | |
cv::Mat img = cv_bridge::toCvCopy(msg)->image; | ||
rec.log( | ||
entity_path, | ||
rerun::DepthImage( | ||
{static_cast<size_t>(img.rows), static_cast<size_t>(img.cols)}, | ||
rerun::TensorBuffer::u16(img) | ||
) | ||
.with_meter(1000) | ||
rerun::DepthImage(rerun::Collection<uint16_t>(img), width_height(img)).with_meter(1000) | ||
); | ||
} else if (msg->encoding == "32FC1") { | ||
cv::Mat img = cv_bridge::toCvCopy(msg)->image; | ||
|
@@ -132,15 +128,14 @@ void log_image( | |
} | ||
rec.log( | ||
entity_path, | ||
rerun::DepthImage( | ||
{static_cast<size_t>(img.rows), static_cast<size_t>(img.cols)}, | ||
rerun::TensorBuffer::f32(img) | ||
) | ||
.with_meter(1.0) | ||
rerun::DepthImage(rerun::Collection<float>(img), width_height(img)).with_meter(1.0) | ||
); | ||
} else { | ||
cv::Mat img = cv_bridge::toCvCopy(msg, "rgb8")->image; | ||
rec.log(entity_path, rerun::Image(tensor_shape(img), rerun::TensorBuffer::u8(img))); | ||
rec.log( | ||
entity_path, | ||
rerun::Image::from_rgb24(rerun::Collection<uint8_t>(img), width_height(img)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems related to this issue: But I think this code this is fine, since it borrows data that lives longer than |
||
); | ||
} | ||
} | ||
|
||
|
@@ -156,7 +151,11 @@ void log_pose_stamped( | |
rec.log( | ||
entity_path, | ||
rerun::Transform3D( | ||
rerun::Vector3D(msg->pose.position.x, msg->pose.position.y, msg->pose.position.z), | ||
rerun::components::Translation3D( | ||
msg->pose.position.x, | ||
msg->pose.position.y, | ||
msg->pose.position.z | ||
), | ||
rerun::Quaternion::from_wxyz( | ||
msg->pose.orientation.w, | ||
msg->pose.orientation.x, | ||
|
@@ -200,7 +199,7 @@ void log_tf_message( | |
rec.log( | ||
tf_frame_to_entity_path.at(transform.child_frame_id), | ||
rerun::Transform3D( | ||
rerun::Vector3D( | ||
rerun::components::Translation3D( | ||
transform.transform.translation.x, | ||
transform.transform.translation.y, | ||
transform.transform.translation.z | ||
|
@@ -228,7 +227,7 @@ void log_odometry( | |
rec.log( | ||
entity_path, | ||
rerun::Transform3D( | ||
rerun::Vector3D( | ||
rerun::components::Translation3D( | ||
msg->pose.pose.position.x, | ||
msg->pose.pose.position.y, | ||
msg->pose.pose.position.z | ||
|
@@ -278,7 +277,7 @@ void log_transform( | |
rec.log( | ||
entity_path, | ||
rerun::Transform3D( | ||
rerun::Vector3D( | ||
rerun::components::Translation3D( | ||
msg->transform.translation.x, | ||
msg->transform.translation.y, | ||
msg->transform.translation.z | ||
|
@@ -307,8 +306,8 @@ void log_point_cloud2( | |
// TODO(leo) if not specified, check if 2D points or 3D points | ||
// TODO(leo) allow arbitrary color mapping | ||
|
||
size_t x_offset, y_offset, z_offset; | ||
bool has_x{false}, has_y{false}, has_z{false}; | ||
size_t x_offset, y_offset, z_offset, rgb_offset; | ||
bool has_x{false}, has_y{false}, has_z{false}, has_rgb{false}; | ||
|
||
for (const auto& field : msg->fields) { | ||
if (field.name == "x") { | ||
|
@@ -332,6 +331,15 @@ void log_point_cloud2( | |
return; | ||
} | ||
has_z = true; | ||
} else if (field.name == options.colormap_field.value_or("rgb")) { | ||
if (field.datatype == sensor_msgs::msg::PointField::UINT32 || | ||
field.datatype == sensor_msgs::msg::PointField::FLOAT32) { | ||
has_rgb = true; | ||
rgb_offset = field.offset; | ||
} else { | ||
rec.log(entity_path, rerun::TextLog("Only UINT32 and FLOAT32 rgb field supported")); | ||
continue; | ||
} | ||
} | ||
} | ||
|
||
|
@@ -346,6 +354,10 @@ void log_point_cloud2( | |
std::vector<rerun::Position3D> points(msg->width * msg->height); | ||
std::vector<rerun::Color> colors; | ||
|
||
if (has_rgb) { | ||
colors.reserve(msg->width * msg->height); | ||
} | ||
|
||
for (size_t i = 0; i < msg->height; ++i) { | ||
for (size_t j = 0; j < msg->width; ++j) { | ||
auto point_offset = i * msg->row_step + j * msg->point_step; | ||
|
@@ -354,7 +366,12 @@ void log_point_cloud2( | |
std::memcpy(&position.xyz.xyz[0], &msg->data[point_offset + x_offset], sizeof(float)); | ||
std::memcpy(&position.xyz.xyz[1], &msg->data[point_offset + y_offset], sizeof(float)); | ||
std::memcpy(&position.xyz.xyz[2], &msg->data[point_offset + z_offset], sizeof(float)); | ||
points.emplace_back(std::move(position)); | ||
if (has_rgb) { | ||
uint8_t bgra[4]; | ||
std::memcpy(&bgra, &msg->data[point_offset + rgb_offset], sizeof(uint32_t)); | ||
colors.emplace_back(rerun::Color(bgra[2], bgra[1], bgra[0])); | ||
} | ||
points[i * msg->width + j] = position; | ||
} | ||
} | ||
|
||
|
@@ -372,10 +389,14 @@ void log_point_cloud2( | |
&msg->data[i * msg->row_step + j * msg->point_step + colormap_field.offset], | ||
sizeof(float) | ||
); | ||
values.emplace_back(value); | ||
values[i * msg->width + j] = value; | ||
} | ||
} | ||
colors = colormap(values, options.colormap_min, options.colormap_max); | ||
} else if (options.colormap == "rgb") { | ||
if (!has_rgb) { | ||
rec.log(entity_path, rerun::TextLog("RGB colormap specified but no RGB field present")); | ||
} | ||
} else if (options.colormap) { | ||
rec.log("/", rerun::TextLog("Unsupported colormap specified: " + options.colormap.value())); | ||
} | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I honestly don't know what is the proper way to use CollectionAdapters here. Without contstructor/casting it does not compile and I yet to find a recent example that works