Reintroduce pointcloud render without Float_V message (backport #755)#759
Open
mergify[bot] wants to merge 1 commit intoign-gui6from
Open
Reintroduce pointcloud render without Float_V message (backport #755)#759mergify[bot] wants to merge 1 commit intoign-gui6from
mergify[bot] wants to merge 1 commit intoign-gui6from
Conversation
🦟 Bug fix [This bug](#494 (comment)) ## Summary Re-introduce point cloud rendering without the Float_V message. <img width="1198" height="996" alt="Screenshot From 2026-03-17 11-49-46" src="https://github.com/user-attachments/assets/fe538b5b-d93a-429b-9900-3b13345dece1" /> I tested it with the following program: ```C++ #include <iostream> #include <cmath> #include <thread> #include <chrono> #include <gz/msgs/pointcloud_packed.pb.h> #include <gz/msgs/PointCloudPackedUtils.hh> #include <gz/transport/Node.hh> int main(int argc, char** argv) { // Create a transport node. gz::transport::Node node; // Define the topic to publish on. std::string topic = "/sphere_points"; // Create a publisher for PointCloudPacked messages. auto pub = node.Advertise<gz::msgs::PointCloudPacked>(topic); if (!pub) { std::cerr << "Error advertising topic [" << topic << "]" << std::endl; return -1; } // Sphere parameters double radius = 1.0; int num_theta = 20; int num_phi = 40; // Prepare the message gz::msgs::PointCloudPacked msg; // Initialize header msg.mutable_header()->mutable_stamp()->set_sec(0); msg.mutable_header()->mutable_stamp()->set_nsec(0); // Initialize PointCloudPacked gz::msgs::InitPointCloudPacked(msg, "frame_id", false, {{"xyz", gz::msgs::PointCloudPacked::Field::FLOAT32}}); int num_points = (num_theta + 1) * num_phi; msg.set_width(num_points); msg.set_height(1); msg.set_is_dense(true); msg.mutable_data()->resize(num_points * msg.point_step()); gz::msgs::PointCloudPackedIterator<float> iterX(msg, "x"); gz::msgs::PointCloudPackedIterator<float> iterY(msg, "y"); gz::msgs::PointCloudPackedIterator<float> iterZ(msg, "z"); const double PI = std::acos(-1.0); for (int i = 0; i <= num_theta; ++i) { double theta = PI * i / num_theta; for (int j = 0; j < num_phi; ++j) { double phi = 2.0 * PI * j / num_phi; double x = radius * std::sin(theta) * std::cos(phi); double y = radius * std::sin(theta) * std::sin(phi); double z = radius * std::cos(theta); *iterX = static_cast<float>(x); *iterY = static_cast<float>(y); *iterZ = static_cast<float>(z); ++iterX; ++iterY; ++iterZ; } } std::cout << "Publishing a sphere with " << num_points << " points on topic [" << topic << "]" << std::endl; // Publish the message in a loop while (true) { if (!pub.Publish(msg)) { std::cerr << "Failed to publish message" << std::endl; } std::this_thread::sleep_for(std::chrono::milliseconds(1000)); } return 0; } ``` TODO: Color support: I think we should not implement the color rendering support here, rather perhaps we should have some PointCloud representation in `gz-math`. For now there is rudimentary support for colors in this PR. --------- Signed-off-by: Arjo Chakravarty <arjoc@intrinsic.ai> Signed-off-by: Arjo Chakravarty <arjo129@gmail.com> Co-authored-by: Ian Chen <ichen@openrobotics.org> Co-authored-by: Ian Chen <iche@google.com> (cherry picked from commit d8b6a54) # Conflicts: # src/plugins/point_cloud/PointCloud.cc
Author
|
Cherry-pick of d8b6a54 has failed: To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally |
11 tasks
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
🦟 Bug fix
This bug
Summary
Re-introduce point cloud rendering without the Float_V message.
I tested it with the following program:
TODO: Color support: I think we should not implement the color rendering support here, rather perhaps we should have some PointCloud representation in
gz-math. For now there is rudimentary support for colors in this PR.Checklist
codecheckpassed (See contributing)Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining
Signed-off-byandGenerated-bymessages.Backports: If this is a backport, please use Rebase and Merge instead.
This is an automatic backport of pull request #755 done by [Mergify](https://mergify.com).