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

Add likelihood field 3d model version #440

Open
wants to merge 79 commits into
base: main
Choose a base branch
from

Conversation

pvela2017
Copy link
Contributor

@pvela2017 pvela2017 commented Oct 1, 2024

Proposed changes

Describe the big picture of your changes here to communicate to the maintainers why we should accept this pull request.
If it fixes a bug or resolves a feature request, be sure to link to that issue.

Type of change

  • 🐛 Bugfix (change which fixes an issue)
  • 🚀 Feature (change which adds functionality)
  • 📚 Documentation (change which fixes or extends documentation)

💥 Breaking change! Explain why a non-backwards compatible change is necessary or remove this line entirely if not applicable.

Checklist

Put an x in the boxes that apply. This is simply a reminder of what we will require before merging your code.

  • Lint and unit tests (if any) pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)
  • All commits have been signed for DCO

Additional comments

Anything worth mentioning to the reviewers.

Added a ROS point cloud interface for float data type and it respective testcase

Signed-off-by: Pablo Vela <[email protected]>
Changed description names to be more natural and specified pointcloud requirements

Signed-off-by: Pablo Vela <[email protected]>
Signed-off-by: Pablo Vela <[email protected]>
Signed-off-by: Pablo Vela <[email protected]>
Added new testcases to cover all the cases

Signed-off-by: Pablo Vela <[email protected]>
Signed-off-by: Pablo Vela <[email protected]>
Signed-off-by: Pablo Vela <[email protected]>
Signed-off-by: Pablo Vela <[email protected]>
Signed-off-by: Pablo Vela <[email protected]>
Signed-off-by: Pablo Vela <[email protected]>
Signed-off-by: Pablo Vela <[email protected]>
Signed-off-by: Pablo Vela <[email protected]>
Signed-off-by: Pablo Vela <[email protected]>
Signed-off-by: Pablo Vela <[email protected]>
Signed-off-by: Pablo Vela <[email protected]>
Signed-off-by: Pablo Vela <[email protected]>
Signed-off-by: Pablo Vela <[email protected]>
Signed-off-by: Pablo Vela <[email protected]>
Signed-off-by: Pablo Vela <[email protected]>
Signed-off-by: Pablo Vela <[email protected]>
@hidmic hidmic self-requested a review November 25, 2024 11:45
Copy link
Collaborator

@hidmic hidmic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work @pvela2017! As I said offline, we are likely moving OpenVDB out of Beluga core (solely because OpenVDB packaging is terrible). I'll take it from here.

In the meantime, CC'ing @nahueespinosa for another take.

Comment on lines 134 to 136
return [this, pointcloud_size, points = std::move(transformed_points)](const state_type& state) -> weight_type {
std::vector<float> distances;
distances.reserve(pointcloud_size);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pvela2017 nit: we can fetch pointcloud_size as points.size().

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think points type changed to Eigen after transforming the points to base_link frame.

But now reserve was removed according to this so no need for this variable.

Changed in 2aabb60

Copy link
Member

@nahueespinosa nahueespinosa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome!

[[nodiscard]] auto operator()(measurement_type&& measurement) const {
const size_t pointcloud_size = measurement.points().size();
// Transform each point from the sensor frame to the origin frame
auto transformed_points = ranges::views::all(measurement.points()) |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: ranges::views::all should not be needed. The transform view will do the conversion.

Suggested change
auto transformed_points = ranges::views::all(measurement.points()) |
auto transformed_points = measurement.points() |

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed in 2aabb60

@@ -54,6 +54,7 @@
*
* \section SensorModelLinks See also
* - beluga::LikelihoodFieldModel
* - beluga::Likelihood3DFieldModel
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* - beluga::Likelihood3DFieldModel
* - beluga::LikelihoodFieldModel3

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed in 2aabb60

ranges::to<std::vector>();

return [this, pointcloud_size, points = std::move(transformed_points)](const state_type& state) -> weight_type {
std::vector<float> distances;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

meta: It doesn't seem like we need to dynamically allocate the distances since we will iterate over them only once. Non-blocking though.

Copy link
Contributor Author

@pvela2017 pvela2017 Nov 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed in 2aabb60

edit: I was thinking, if we dont allocate memory for the distances, wouldn't it loose performance since everytime the vector is getting full it would have to allocate more memory? Since there are a lot of points this would happen several time or would this be negligible?

/// Parameter type that the constructor uses to configure the likelihood field model.
using param_type = LikelihoodFieldModel3Param;

/// Constructs a Likelihood3DFieldModel instance.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are other instances that need replacement.

Suggested change
/// Constructs a Likelihood3DFieldModel instance.
/// Constructs a LikelihoodFieldModel3 instance.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed in 2aabb60

Signed-off-by: Pablo Vela <[email protected]>
Signed-off-by: Pablo Vela <[email protected]>
Signed-off-by: Pablo Vela <[email protected]>
@hidmic hidmic mentioned this pull request Dec 31, 2024
7 tasks
@hidmic
Copy link
Collaborator

hidmic commented Dec 31, 2024

Ready to go once pvela2017#2 goes in. FYI @glpuga @nahueespinosa.

@pvela2017
Copy link
Contributor Author

@hidmic

I forgot that setting the checker as const generate problems when running the build-and-test.sh script, but not when just using colcon build.

What should we do? It is nice to have the checker but I don't think it is mandatory.

/ws/src/beluga/beluga_vdb/test/beluga_vdb/sensor/test_likelihood_3d_field_model.cpp:79:64: required from here /ws/src/beluga/beluga_vdb/test/beluga_vdb/sensor/test_likelihood_3d_field_model.cpp:61:37: error: passing ‘const openvdb::v10_0::tools::CheckLevelSet<openvdb::v10_0::Grid<openvdb::v10_0::tree::Tree<openvdb::v10_0::tree::RootNode<openvdb::v10_0::tree::InternalNode<openvdb::v10_0::tree::InternalNode<openvdb::v10_0::tree::LeafNode<float, 3>, 4>, 5> > > > >’ as ‘this’ argument discards qualifiers [-fpermissive] 61 | assert(checker.checkInactiveValues() == "");

PD: I commented this before, but it seems it didn't generate a notification

@glpuga
Copy link
Collaborator

glpuga commented Jan 7, 2025

@hidmic

I forgot that setting the checker as const generate problems when running the build-and-test.sh script, but not when just using colcon build.

What should we do? It is nice to have the checker but I don't think it is mandatory.

/ws/src/beluga/beluga_vdb/test/beluga_vdb/sensor/test_likelihood_3d_field_model.cpp:79:64: required from here /ws/src/beluga/beluga_vdb/test/beluga_vdb/sensor/test_likelihood_3d_field_model.cpp:61:37: error: passing ‘const openvdb::v10_0::tools::CheckLevelSet<openvdb::v10_0::Grid<openvdb::v10_0::tree::Tree<openvdb::v10_0::tree::RootNode<openvdb::v10_0::tree::InternalNode<openvdb::v10_0::tree::InternalNode<openvdb::v10_0::tree::LeafNode<float, 3>, 4>, 5> > > > >’ as ‘this’ argument discards qualifiers [-fpermissive] 61 | assert(checker.checkInactiveValues() == "");

PD: I commented this before, but it seems it didn't generate a notification

@pvela2017 Michel will be out on PTO for a couple of weeks. If you give us more context maybe @nahueespinosa a me can help you.

@pvela2017
Copy link
Contributor Author

@hidmic
I forgot that setting the checker as const generate problems when running the build-and-test.sh script, but not when just using colcon build.
What should we do? It is nice to have the checker but I don't think it is mandatory.
/ws/src/beluga/beluga_vdb/test/beluga_vdb/sensor/test_likelihood_3d_field_model.cpp:79:64: required from here /ws/src/beluga/beluga_vdb/test/beluga_vdb/sensor/test_likelihood_3d_field_model.cpp:61:37: error: passing ‘const openvdb::v10_0::tools::CheckLevelSet<openvdb::v10_0::Grid<openvdb::v10_0::tree::Tree<openvdb::v10_0::tree::RootNode<openvdb::v10_0::tree::InternalNode<openvdb::v10_0::tree::InternalNode<openvdb::v10_0::tree::LeafNode<float, 3>, 4>, 5> > > > >’ as ‘this’ argument discards qualifiers [-fpermissive] 61 | assert(checker.checkInactiveValues() == "");
PD: I commented this before, but it seems it didn't generate a notification

@pvela2017 Michel will be out on PTO for a couple of weeks. If you give us more context maybe @nahueespinosa a me can help you.

Whops! I hope he doesnt get the notifications then.

Sure, in the testcase for beluga_vdb we use an OpenVDB object to check if the background of the level set is right.
const openvdb::tools::CheckLevelSet<GridT> checker(*grid);

Originally, it was without const, just openvdb::tools::CheckLevelSet<GridT> checker(*grid); but Michel suggest to changed to const, which does make sense, since we are not changing it. But this way seems to have problems and doesn't compile when using the build-and-test.sh script.

So, what would be better remove this checking or just leave it without const?

Thank you!

@glpuga
Copy link
Collaborator

glpuga commented Jan 8, 2025

Sure, in the testcase for beluga_vdb we use an OpenVDB object to check if the background of the level set is right. const openvdb::tools::CheckLevelSet<GridT> checker(*grid);

Originally, it was without const, just openvdb::tools::CheckLevelSet<GridT> checker(*grid); but Michel suggest to changed to const, which does make sense, since we are not changing it. But this way seems to have problems and doesn't compile when using the build-and-test.sh script.

So, what would be better remove this checking or just leave it without const?

The problem seems to be that that checker has noconst version of the checkInactiveValues() method, so you can't call it if you create the instance as const. The method internally seems to modify state in within the instance (a counter and maybe some other stuff).

Leave it as non-const.

Signed-off-by: Pablo Vela <[email protected]>
@pvela2017
Copy link
Contributor Author

Sure, in the testcase for beluga_vdb we use an OpenVDB object to check if the background of the level set is right. const openvdb::tools::CheckLevelSet<GridT> checker(*grid);
Originally, it was without const, just openvdb::tools::CheckLevelSet<GridT> checker(*grid); but Michel suggest to changed to const, which does make sense, since we are not changing it. But this way seems to have problems and doesn't compile when using the build-and-test.sh script.
So, what would be better remove this checking or just leave it without const?

The problem seems to be that that checker has noconst version of the checkInactiveValues() method, so you can't call it if you create the instance as const. The method internally seems to modify state in within the instance (a counter and maybe some other stuff).

Leave it as non-const.

Ok, I pushed the changes!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants