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

Bug fix to update freespace when bbx is set. #360

Merged
merged 8 commits into from
Jan 30, 2022
Merged

Conversation

kjulian3
Copy link
Contributor

@kjulian3 kjulian3 commented Jan 7, 2022

This pull request addresses #358. If the bounding box is set and the scan point is within the bounding box and within the max range (if set), then the cell containing the the scan point is added to occupied cells. Now, even if the scan point is outside the bounding box or beyond the max range, cells will be added to the free cells set. The end point is truncated to stop at the max range if the original scan point is beyond max range. Then, we iterate through the key ray and add cells to the free_cells list, breaking when we leave the bounding box.

@ahornung
Copy link
Member

ahornung commented Jan 7, 2022

Thanks for your contribution! Do you think it would be possible to add some basic unit tests as well?

@kjulian3
Copy link
Contributor Author

kjulian3 commented Jan 7, 2022

That's possible, I can add a new section in unit_tests.cpp and update CMakeLists.txt in src/testing. Is there anything else I should do to setup a basic unit test?

@ahornung
Copy link
Member

ahornung commented Jan 9, 2022

Yes, either add a new .cpp file for a dedicated test (preferred) or add a section in unit_tests.cpp + update CMakeListst.txt.

@kjulian3
Copy link
Contributor Author

I added a dedicated test. While working on the test, I discovered that we should probably use a keyray iterator, not reverse_iterator, to iterate through keys from the origin to the end of the vector rather than starting at the end and moving towards the origin. I added this change to the PR as well.

@ahornung
Copy link
Member

Thanks for the test and the change, indeed that makes sense. Sorry for the delay, I'm waiting for the CI builds to finish now.

@kjulian3
Copy link
Contributor Author

kjulian3 commented Jan 26, 2022

Looks like I deleted a line when refactoring the test to try to make the code cleaner. Hopefully the tests build/pass this time after my recent commit.

I've had trouble building/running the tests on my end, and I can't trigger the CI builds on my own. So I'm sorry for this inconvenience.

@kjulian3
Copy link
Contributor Author

The last commit seemed to fail due to floating-point precision. I modified the test to use a larger epsilon when checking for floating point equality.

@ahornung
Copy link
Member

To avoid going back and forth, could you compile and test locally on your machine before pushing?

@kjulian3
Copy link
Contributor Author

I found the source of the error, which was not in the new test but in testing.h. The testing macros did not put parentheses around the arguments, which results in incorrect computation when the arguments to the macros are an equation. I added parentheses around the arguments and ran the tests locally to ensure they pass.

@ahornung ahornung merged commit 56b605a into OctoMap:devel Jan 30, 2022
@ahornung
Copy link
Member

Thanks for the fixes!

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.

2 participants