-
Notifications
You must be signed in to change notification settings - Fork 529
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
Cost function API for MoveIt 2 #2240
Comments
Well written @sjahr, this looks like a great start. Here's a formalization of some of the topics we discussed in person this week, plus some other things that I'm thinking of. C++ APIOptimization is often a game of simpifying your problem until your objective function is in the shape of something that can be solved quickly, e.g. a linear program, quadratic program, etc. My understanding of OMPL's optimizing planners, STOMP, and CHOMP is that they are solving a derivative-free non-linear optimization problem. In this case, the API you've proposed of a black-box C++ cost function callback is the proper shape. However, it does restrict you from exploiting the problem structure in the future if planners are introduced that make use of derivatives or formulate LPs or QPs. If forward-compatibility in that respect is important then I see a couple ways to work around this:
A motivating example of this expanded API may be to reuse your objective function between an optimizing local planner, such as OCS2, and a global planner, such as RRT* from OMPL. To do so, additional information about the cost function structure would be needed, including partial derivatives of the cost w.r.t. the state. Python APII think it would be very productive to consider how a cost-function API could be exposed to the Python library in an efficient way. Exposing the functional callback interface to directly call into a Python function is the obvious solution, but it would be very slow if the cost function is evaluated many times. It would be more efficient for the Python side to describe the shape of the cost function, which is then evaluated entirely in the C++ code. For example, instead of implementing a simple linear cost function like this: def cost(x):
A = [...]
b = [...]
return A * x + b You could implement it like this: problem = ...
A = [...]
b = [...]
problem.AddLinearCost(A, b) I wouldn't be surprised if this results in a 100x speedup of using the cost function API from Python. TerminationIn the interest of making this high-level API generic, you may want to consider adding some options for termination conditions. Check out SciPy's optimization toolbox for examples here. Ideally the user could supply an absolute tolerance (tolerance which disregards the magnitude of any particular solution component) and a relative tolerance (error is considered relative to the size of each solution component). These general tolerances would then be passed down and respected by the solvers, if possible. In addition to making the API easier to use, it would also make it much simpler to do cross-solver benchmarking with equivalent solution tolerances. Misc
|
This issue summarizes and tracks the ongoing effort to add a custom function API to MoveIt 2 for better support of optimizing planners.
Motivation
What is considered the best solution for a motion planning problem is highly application specific. Typical requirements are:
These requirements can be expressed to a planning algorithm as costs and/or constraints. Currently, we can pass hard constraints to planning algorithms but no cost terms. The supported optimizing planners use implementation-specific cost functions that cannot be re-used by other planners and it is hard to create custom cost terms.
Background
Cost and Constraints
Optimizing planners in MoveIt 2
OMPL provides a bunch of optimizing planners like RRT*, PRM*, or AnytimePathShortening. The optimization goal can be specified via an OptimizationObjective in the OMPL config .yaml file. At this point it is not possible to combine multiple objectives.
STOMP and CHOMP
Both are optimizing planners. While they would theoretically support it, it is not possible to pass custom optimizations goals to either of them with the currently available MoveIt API Optimizing
Optimizing IK solvers in MoveIt 2
MoveIt 2 supports passing custom cost functions to IK solvers which offers an API for it. Right now the available solvers for this feature are BioIK(ros2 version) and pick_ik
Implementation
The goal of this epic is to extend the existing MoveIt 2 API to enable specifying an application-specific, planner-agnostic cost function and pass it with the MotionPlanRequest to an optimizing planner plugin
A cost function implementation should allow:
The implementation is split into the following parts:
Happy to hear your feedback and/or additions and to get your reviews 😃
The text was updated successfully, but these errors were encountered: