optimize
Syntax
Description
The optimize
function optimizes a factor graph to find a
solution that minimizes the cost of the nonlinear least squares problem formulated by the
factor graph. The factor graph optimization utilizes the Ceres Solver for node state
covariance estimation, a process that incurs higher computation costs and longer estimation
times as the number of nodes increases. For more information about Ceres-Solver covariance
estimation, see http://ceres-solver.org/nnls_covariance.html.
To estimate node state covariance, optimize with custom solver options using the factorGraphSolverOptions
object that has the
StateCovarianceType
property set to one or more node types. When
optimizing factor graphs that require estimating state covariance for a high number of nodes,
consider using sliding window optimization to increase optimization speed by estimating the
state covariance for less nodes at once. For more information about sliding window
optimization, see Incrementally Optimize Factor Graph Using Sliding Window.
optimizes the specified pose nodes and any related nodes except for unspecified pose
nodes.solnInfo
= optimize(fg
,poseNodeIDs
)
Note
At least one of the specified pose nodes must meet one or both of these requirements:
Have a fixed pose state using the
fixNode
function.Relate to one or more factors that provide absolute state information:
optimizes the factor graph using the specified factor graph solver options, in addition to
any combination of input arguments from previous syntaxes. For example,
solnInfo
= optimize(___,solverOptions
)optimize(fg,factorGraphSolverOptions(StateCovarianceType="POSE_SE2"))
specifies that optimize
should estimate and store the node state
covariance for SE(2) pose nodes in the factor graph during optimization.
Examples
Input Arguments
Output Arguments
More About
Tips
Before you optimize the factor graph or a subset of nodes, use the
nodeState
function to save the node states to the workspace. If, after running the optimization, you want to make adjustments to it, you can set the node states back to the saved states.For debugging a partial optimization of a factor graph, check the
OptimizedNodeIDs
andFixedNodeIDs
fields of thesolnInfo
output argument to see which of the optimized node IDs and which of fixed nodes contributed to the optimization.To check if
poseNodeIDs
forms a connected factor graph, use theisConnected
function.