importFactorGraph
Description
Examples
Import Factor Graph from G2o File
Import factor graph from the huskyGazebo2DPG.g2o
file.
fg = importFactorGraph("huskyGazebo2DPG.g2o")
fg = factorGraph with properties: NumNodes: 152 NumFactors: 357
Get the node type of the first pose node.
type = nodeType(fg,1)
type = "POSE_SE2"
Get all of the pose nodes of the same type.
poseIDs = nodeIDs(fg,NodeType=type)
poseIDs = 1×152
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
Fix the first node so it is an anchor during optimization and then optimize the factor graph with default solver options.
fixNode(fg,0); optimize(fg); poses = nodeState(fg,poseIDs);
Plot the poses of the factor graph as an SE(2) transformations.
poseTFs = se2(poses,"xytheta"); plotTransforms(poseTFs,FrameSize=0.5); xlabel("x(m)") ylabel("y(m)") title("Imported Factor Graph")
Input Arguments
filename
— Name of G2o log file
string scalar | character vector
Name of the G2o log file to import a factor graph from, specified as a string scalar
or character vector. The specified G2o log file must contain either only
'EDGE_SE2'
and 'VERTEX_SE2'
tokens, or only
'EDGE_SE3:QUAT'
and 'VERTEX_SE3:QUAT'
tokens.
Output Arguments
graph
— Factor graph imported from G2o file
factorGraph
object
Factor graph imported from the G2o file, returned as a factorGraph
object.
Version History
Introduced in R2022a
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)