MCPcopy Create free account
hub / github.com/botbotrobotics/BotBrain / parseYAML

Function parseYAML

frontend/src/utils/ros/mapFileUtils.ts:88–118  ·  view source on GitHub ↗
(content: string)

Source from the content-addressed store, hash-verified

86
87// Parse YAML file
88export function parseYAML(content: string): MapMetadata {
89 const metadata: any = {};
90 const lines = content.split('\n');
91
92 for (const line of lines) {
93 const trimmed = line.trim();
94 if (!trimmed || trimmed.startsWith('#')) continue;
95
96 const colonIndex = trimmed.indexOf(':');
97 if (colonIndex === -1) continue;
98
99 const key = trimmed.substring(0, colonIndex).trim();
100 const value = trimmed.substring(colonIndex + 1).trim();
101
102 // Parse origin array
103 if (key === 'origin') {
104 const matches = value.match(/\[([^\]]+)\]/);
105 if (matches) {
106 metadata.origin = matches[1].split(',').map(v => parseFloat(v.trim()));
107 }
108 } else if (key === 'resolution' || key === 'occupied_thresh' || key === 'free_thresh') {
109 metadata[key] = parseFloat(value);
110 } else if (key === 'negate') {
111 metadata[key] = parseInt(value);
112 } else {
113 metadata[key] = value;
114 }
115 }
116
117 return metadata as MapMetadata;
118}
119
120// Generate YAML content
121export function generateYAML(metadata: MapMetadata): string {

Callers 1

MapEditorFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected