Skip to content

Commit

Permalink
Prevent loading of empty Choreo paths (#839)
Browse files Browse the repository at this point in the history
  • Loading branch information
mjansen4857 authored Oct 7, 2024
1 parent 1f4df3b commit 4a06224
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/path/choreo_path.dart
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,22 @@ class ChoreoPath {
for (FileSystemEntity e in files) {
if (e.path.endsWith('.traj')) {
final file = fs.file(e.path);
String pathName = basenameWithoutExtension(e.path);
String jsonStr = await file.readAsString();

try {
Map<String, dynamic> json = jsonDecode(jsonStr);
String pathName = basenameWithoutExtension(e.path);

// Add the full path
ChoreoPath path =
ChoreoPath.fromTrajJson(json, pathName, choreoDir, fs);

if (path.trajectory.states.isEmpty) {
Log.error(
'Failed to load choreo path: $pathName. Path has no trajectory states');
continue;
}

paths.add(path);

// Add each split
Expand Down Expand Up @@ -116,7 +123,7 @@ class ChoreoPath {
paths.add(splitPath);
}
} catch (ex, stack) {
Log.error('Failed to load choreo path', ex, stack);
Log.error('Failed to load choreo path: $pathName', ex, stack);
}
}
}
Expand Down

0 comments on commit 4a06224

Please sign in to comment.