Ground Truth Map Module
gt_map.generator
Ground truth map generation from Gazebo SDF files.
This module parses SDF (Simulation Description Format) files and generates 2D occupancy grid maps by projecting 3D geometry onto a horizontal plane at a specified laser height.
generate_map(sdf_path='world/model.sdf', resolution=0.05, laser_z=0.17, padding=1.0, output_name='map_gt', gen_png=True, gen_debug=True)
Generate a 2D occupancy grid map from a Gazebo SDF file.
Parses the SDF file, extracts 3D geometry (boxes, cylinders), and projects them onto a 2D plane at the specified laser height. Outputs PGM and YAML files compatible with ROS 2 map_server.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sdf_path
|
Path to the SDF file |
'world/model.sdf'
|
|
resolution
|
Map resolution in meters per pixel (default: 0.05) |
0.05
|
|
laser_z
|
Height of the laser scanner in meters (default: 0.17) |
0.17
|
|
padding
|
Extra padding around the map bounds in meters (default: 1.0) |
1.0
|
|
output_name
|
Base name for output files (default: 'map_gt') |
'map_gt'
|
|
gen_png
|
Whether to generate a PNG preview (default: True) |
True
|
|
gen_debug
|
Whether to generate a debug plot (default: True) |
True
|
Returns:
| Type | Description |
|---|---|
|
Tuple of (success: bool, message: str) |
Example
success, msg = generate_map('worlds/turtlebot3_world.sdf', output_name='maps/gt/tb3_world') if success: ... print("Map generated successfully")
Source code in gt_map/generator.py
225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 | |
parse_pose(pose_str)
Parse SDF pose string into numpy array.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pose_str
|
Space-separated string "x y z roll pitch yaw" |
required |
Returns:
| Type | Description |
|---|---|
|
numpy array of 6 elements [x, y, z, roll, pitch, yaw] |
Source code in gt_map/generator.py
gt_map.viewer
Interactive map viewer for visualizing ground truth maps.
Displays occupancy grid maps with proper scaling and origin.
show_map(yaml_path)
Display a map from a YAML configuration file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
yaml_path
|
Path to the map YAML file (ROS map_server format) |
required |
The function loads the map image and metadata, then displays it with proper world coordinates using matplotlib.