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

Search energy classes #25

Merged

Conversation

jvarley
Copy link
Member

@jvarley jvarley commented Mar 21, 2016

@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.

if (!mEnergyCalculator->isType(s))
{
mEnergyCalculator = SearchEnergy::getSearchEnergy(s);
}
Copy link
Member

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

@mateiciocarlie
Copy link
Member

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
@jvarley
Copy link
Member Author

jvarley commented Apr 6, 2016

1)I fixed the memory leak, good catch.
2) I added a setType function to searchEnergy, and called it before returning the energyType in getSearchEnergy which is the only way to construct and energy. This works.
3) I tested this by using EGPlannerDLG and ran it with contact energy, potential energy, and contact and potential energy, and they all behaved as expected.

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.

@mateiciocarlie
Copy link
Member

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 :)

@mateiciocarlie
Copy link
Member

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.

@jvarley
Copy link
Member Author

jvarley commented Apr 6, 2016

I changed
bool legal() const;
to:
virtual bool legal() const;

So it can be overridden. I also made SearchEnergy() protected so it can't be initialized outside the factory method.

@mateiciocarlie mateiciocarlie merged commit 15da288 into graspit-simulator:master Apr 6, 2016
@jvarley jvarley deleted the search_energy_classes branch May 18, 2016 18:42
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