Reintroduce pointcloud render without Float_V message#755
Conversation
Signed-off-by: Arjo Chakravarty <arjoc@intrinsic.ai>
…pointcloud_render
…issing Signed-off-by: Arjo Chakravarty <arjoc@intrinsic.ai>
Co-authored-by: Ian Chen <ichen@openrobotics.org> Signed-off-by: Arjo Chakravarty <arjo129@gmail.com>
Co-authored-by: Ian Chen <iche@google.com> Signed-off-by: Arjo Chakravarty <arjo129@gmail.com>
|
@Mergifyio backport gz-sim10 gz-sim9 gz-sim8 ign-gazebo6 |
❌ No backport have been createdDetails
GitHub error:
GitHub error:
GitHub error:
GitHub error: |
|
https://github.com/Mergifyio backport gz-sim10 gz-sim9 gz-sim8 ign-gazebo6 |
❌ No backport have been createdDetails
GitHub error:
GitHub error:
GitHub error:
GitHub error: |
|
@Mergifyio backport gz-gui10 gz-gui8 gz-gui9 ign-gui6 @arjo129 oops, I did the same thing you did thinking it was a github outage. Btw, check out https://gazebosim.org/docs/latest/maintainers/#backporting for quickly generating the mergifyio command for a given PR. |
✅ Backports have been createdDetails
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
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 |
🦟 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)
🦟 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
🦟 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)
🦟 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
🦟 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. --------- (cherry picked from commit d8b6a54) Signed-off-by: Arjo Chakravarty <arjoc@intrinsic.ai> Signed-off-by: Arjo Chakravarty <arjo129@gmail.com> Co-authored-by: Arjo Chakravarty <arjoc@intrinsic.ai> Co-authored-by: Ian Chen <ichen@openrobotics.org> Co-authored-by: Ian Chen <iche@google.com>
🦟 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. --------- (cherry picked from commit d8b6a54) Signed-off-by: Arjo Chakravarty <arjoc@intrinsic.ai> Signed-off-by: Arjo Chakravarty <arjo129@gmail.com> Co-authored-by: Arjo Chakravarty <arjoc@intrinsic.ai> Co-authored-by: Ian Chen <ichen@openrobotics.org> Co-authored-by: Ian Chen <iche@google.com>
🦟 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.