Add option to keep optimizing after a valid solution was found #46
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently, pick_ik will try to find an IK solution that optimizes for the given goal pose and the additional goals. As soon as the current best solution satisfies the pose threshold and the cost threshold, it will return the solution.
pick_ik/src/ik_memetic.cpp
Lines 247 to 249 in 807b04e
This makes sense in a lot of applications, as you often want to get a (for your context) valid IK solution as fast as possible. However, there are also scenarios where you are not in a hurry and might want to keep optimizing the IK solution until you reach a certain time or iteration limit.
This is currently not easily possible in pick_ik. It is possible to reduce the cost_threshold, so that the optimization runs longer. However, this comes with the risk that no solution is acepted as correct.
I first thought that the
memetic_stop_on_first_solution
would do this, but it only regards the stopping of other threads as soon as one has found a solution.Therefore, I added the
optimize_solution
option which will keep optimizing the solution till either time or iteration limit is reached. Indpependend on the usage of threads and IK mode.If you don't want to merge this upstream it is, of course, also fine.