-
Notifications
You must be signed in to change notification settings - Fork 82
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
Search energy classes #25
Search energy classes #25
Conversation
…ve state in a more natural way.
if (!mEnergyCalculator->isType(s)) | ||
{ | ||
mEnergyCalculator = SearchEnergy::getSearchEnergy(s); | ||
} |
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.
This leaks memory as a possible previous SearchEnergy instance is not deleted
This looks great overall, but has a few relatively small issues. The whole mType business has not been integrated with the new model. The variable still exists, but is not set properly in the constructors. Some of the classes still do things differently based on internal checks on the mType variable. Ideally, we would have a pure abstract getType() function in the interface that each energy type must overload to return the proper string. Also, inheriting classes should no longer fork anywhere based on their own type. It looks like perhaps we need to also specialize the function that decides if a state is legal. The base class could provide the default version (which just checks if there are no collisions) leaving inheriting classes to override that as needed. Finally, how has this been tested? Compiling is great, but we'd need to also see that the various energy types still work, in as much as possible. Some of them should be accessible thrgough the Eigengrasp planner dialog. Overall thanks a lot for looking into this - as the comment in the original file said, it was horrible before, and looks great now! |
…t type of mEnergyCalculator in SearchEnergy getSearchEnergy function
1)I fixed the memory leak, good catch. Overall, I feel this is ready, and provides the same functionality as before, in a cleaner manner, and allows the creation of stateful search energies. Completely agree that a pure abstract getType(), and an inherited function that decides if a state is legal should both be added but would rather address those in separate PRs. |
OK, sounds good. I had missed the setType inside the factory. Hope that a proper getType and inherited legal state check will indeed come in a future PR :) |
Actually, let's make one more change before we merge. Since the factory is the only way to build one of these that also correctly sets the type flag, can we make it impossible to build one another way? Perhaps with a protected constructor or something similar. |
I changed So it can be overridden. I also made SearchEnergy() protected so it can't be initialized outside the factory method. |
@mateiciocarlie
In this Commit:
Switched the SearchEnergy class to have different subclasses with different energy() functions rather than having different methods for thinks like contact energy or potential energy. The functional setup made it difficult to create search energies that had state. For instance some of my deep learning energy functions had to load in heatmaps, something that should not happen on every step of the planner and should also not be owned by the base searchenergy class.
I have tested this on linux. It builds just fine with both independently and with other plugins using catkin_make. In my opinion, this is ready to be pulled in.
For the Future:
This should also make it easy to pull our more of the different hardcoded constants such as the mixing parameter in the contact and potential quality into member variables which can then be set in the EG planner dlg.