Local preservation snapshot, not a new deployment or simulation acceptance.
44 lines
1.6 KiB
Python
44 lines
1.6 KiB
Python
"""Explicit full-map input mode for the pinned upstream terrain analysis."""
|
|
|
|
from pathlib import Path
|
|
|
|
|
|
def patch(source):
|
|
declaration = ' nh->declare_parameter<double>("scanVoxelSize", scanVoxelSize);'
|
|
getter = ' nh->get_parameter("scanVoxelSize", scanVoxelSize);'
|
|
stack = " // stack registered laser scans"
|
|
edits = {
|
|
"bool clearingCloud = false;": (
|
|
"bool clearingCloud = false;\nbool inputIsMapSnapshot = false;"
|
|
),
|
|
declaration: (
|
|
' nh->declare_parameter<bool>("inputIsMapSnapshot", inputIsMapSnapshot);\n'
|
|
+ declaration
|
|
),
|
|
getter: (' nh->get_parameter("inputIsMapSnapshot", inputIsMapSnapshot);\n' + getter),
|
|
stack: """ // ObservedSpace owns memory and ray clearing.
|
|
// A complete
|
|
// snapshot replaces our staging clouds, never averages timestamps with
|
|
// older copies or resurrects endpoints removed by the upstream memory.
|
|
if (inputIsMapSnapshot) {
|
|
for (int ind = 0; ind < terrainVoxelNum; ind++) {
|
|
terrainVoxelCloud[ind]->clear();
|
|
terrainVoxelUpdateNum[ind] = 0;
|
|
}
|
|
}
|
|
|
|
// stack registered laser scans""",
|
|
}
|
|
if "inputIsMapSnapshot" in source:
|
|
raise ValueError("CMU snapshot patch already present")
|
|
for anchor, replacement in edits.items():
|
|
if source.count(anchor) != 1:
|
|
raise ValueError("Unexpected pinned CMU snapshot anchor")
|
|
source = source.replace(anchor, replacement)
|
|
return source
|
|
|
|
|
|
if __name__ == "__main__":
|
|
path = Path("/opt/cmu/src/terrain_analysis/src/terrainAnalysis.cpp")
|
|
path.write_text(patch(path.read_text()))
|