Step 2 — Map Surface-Z Error
After a layer is printed and its rosbag is captured, the rosbag_parser
associates the err_surface_mm signal with the robot’s (X, Y, Z)
position at each moment in time, producing both a human-readable 3D
visualization and a machine-readable error map.
What Happens
Section titled “What Happens”- Read
/kuka/posemessages → extract(timestamp, X, Y, Z). - Read
/wire_stickout/err_surface_mmmessages → extract(timestamp, value). - Interpolate error values onto pose timestamps (nearest-neighbor by time).
- Optionally parse the G-code for the commanded toolpath overlay.
- Apply trimming/smoothing to suppress transient sensor noise at layer start/end.
- Write
error_map.csv— each row maps a robot position to its error. - Render an interactive 3D Plotly scatter plot and save to
plot.html.
rosbag_parser :: BagDirectory -> GCode -> (HTML, CSV)Command
Section titled “Command”uv run python map_surface_err_to_xyz_pos.py \ /path/to/L<N>_Z<ZZ>/ \ /path/to/<layer>.gcode \ --nominal_z <ZZ> \ --no-gcode \ -o ~/PhotogrammetryWAAM/STATE/ERR/L<N>.html \ --smooth 12 \ --trim_first_n_err_vals 32 \ --trim_last_n_err_vals 32Working directory: shared/rosbag_parser/
Key Parameters
Section titled “Key Parameters”| Flag | Default | Purpose |
|---|---|---|
--nominal_z MM | auto-detect | Override nominal layer Z height |
--smooth N | 1 | Moving-average window size for error signal |
--trim_first_n_err_vals N | 0 | Zero out first N error values (approach transient) |
--trim_last_n_err_vals N | 0 | Zero out last N error values (departure transient) |
--exclude_outside_z_bounds MM | 0.5 | Drop poses more than ±MM from nominal Z |
--no-gcode | false | Skip G-code overlay in the plot |
Processing Order
Section titled “Processing Order”- Detect (or accept) nominal Z.
- Trim leading samples where Z deviates > 1 mm from nominal.
- Exclude samples outside ±
exclude_outside_z_boundsof nominal Z. - Interpolate error to remaining pose timestamps.
- Zero first/last N error values.
- Apply smoothing window.
Outputs
Section titled “Outputs”| Artifact | Format | Consumed By |
|---|---|---|
L<N>.html | Interactive Plotly 3D plot | Human inspection |
L<N>_error_map.csv | X,Y,Z,err_mm | Step 3 — proportional control |
error_map.csv Schema
Section titled “error_map.csv Schema”X,Y,Z,err_mm12.2021,47.3637,43.2479,4.064410.7972,47.6810,43.2649,4.0644...All positions are in the robot frame (mm). Error is signed: positive means the surface is above nominal, negative means below.
3D Plot Traces
Section titled “3D Plot Traces”| Trace | Color | Data |
|---|---|---|
| Robot path | Black | (X, Y, Z) from /kuka/pose |
| G-code path | Blue | (X, Y, Z) from G-code (offset-transformed) |
| Error surface | Red | (X, Y, Z + err_mm) |