How uditsinghparihar/g2o_tutorial works
Project type and purpose
• This is a tutorial codebase (“g2o_tutorial”) demonstrating graph-based SLAM formulations in Python. It covers two SLAM scenarios: Pose Graph SLAM (pgSlam) and Landmark SLAM (landmarkSlam).
File structure
• Top level:
• README.md, .gitignore
• pgSlam/ (Pose Graph SLAM module)
• landmarkSlam/ (Landmark SLAM module)
• Each module contains:
• A Python script (pgSlam.py or landmarkSlam.py) – end-to-end pipeline
• A Jupyter notebook (.ipynb) – stepwise, interactive version
• g2o files (noise.g2o, opt.g2o) – input to, and output from, the optimizer
• results/ folder – PNGs illustrating intermediate and final outputs
Key technical stack (from README)
• g2o (graph optimizer) – installed via binaries or built from source
• Python libraries: numpy, scipy, open3d, matplotlib, math
Main components
A. Data Generation
• Synthetic trajectory or cube+poses generator
• Outputs: raw odometry & landmark measurements
B. g2o File Writer
• Translates measurements into g2o format (.g2o files)
• noise.g2o (pre-optimization), opt.g2o (for results)
C. Graph Optimizer (g2o engine)
• Takes noise.g2o, runs optimization (EDGE_SE2 / EDGE_SE3, VERTEX_SE2 / VERTEX_SE3)
• Produces optimized graph (opt.g2o)
D. Result Parser & Visualizer
• Reads .g2o outputs
• Plots trajectories and landmark positions (matplotlib / open3d)
E. Notebooks (pgSlam.ipynb & landmarkSlam.ipynb)
• Interactive layer illustrating each sub-step, function by function
• Used for teaching and deeper inspection
Relationships & data flow
• Start → Data Generator → g2o File Writer → g2o Optimizer → Result Parser → Plotter
• Notebooks wrap this pipeline, calling the same underlying functions but in interactive order
• Two parallel pipelines (pgSlam vs. landmarkSlam), sharing almost identical flow but different measurement types
Architectural patterns & design principles
• Pipeline pattern: clear, linear data transformation stages
• Separation of concerns: generation, file generation, optimization engine, and visualization are decoupled
• Reusability: core functions in .py scripts are imported by notebooks
• Blue for data sources & generation
• Green for file I/O (g2o writer / parser)
• Orange for optimization engine
• Purple for visualization & notebooks