Visualization¶
Static plots from logs, comparisons between runs, and live plotting.
Usage¶
# Static plots from CSV logs
api.viz.plot_static("logs/test.csv", "3d")
api.viz.plot_static("logs/test.csv", "position") # Position vs time
api.viz.plot_static("logs/test.csv", "velocity")
api.viz.plot_static("logs/test.csv", "joints")
api.viz.plot_static("logs/test.csv", "force")
api.viz.plot_static("logs/test.csv", "2d_xy") # 2D projections
# Deviation from planned path
api.viz.plot_static("logs/actual.csv", "deviation", overlay_path="logs/planned.csv")
# Comprehensive multi-plot visualization
api.viz.visualize_csv_log("logs/test.csv")
api.viz.visualize_csv_log("logs/test.csv", export=True) # Save to disk
# Compare two runs
api.viz.compare_runs("run1.csv", "run2.csv")
# Live plotting (runs in background thread)
api.viz.start_live_plot("3d", interval=100) # 100ms update
api.viz.change_live_plot_mode("position")
api.viz.stop_live_plot()
Reference¶
VizAPI
¶
Data visualization interface for KUKA RSI robot control.
Provides static plot generation from CSV logs and live plotting capabilities for real-time monitoring of robot motion.
Initialize VizAPI namespace.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
client
|
RSIClient
|
RSIClient instance for live data access |
required |
plot_static
staticmethod
¶
Generate static plots from CSV log data.
Creates matplotlib visualizations of recorded robot trajectories, velocities, forces, and other metrics.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
csv_path
|
str
|
Path to CSV log file |
required |
plot_type
|
str
|
Type of plot to generate: - "3d": 3D trajectory visualization - "2d_xy", "2d_xz", "2d_yz": 2D projections - "position": Position vs time - "velocity": Velocity vs time - "acceleration": Acceleration vs time - "joints": Joint angles vs time - "force": Motor currents vs time - "deviation": Deviation from planned path (requires overlay_path) |
'3d'
|
overlay_path
|
Optional[str]
|
Optional CSV with planned trajectory for deviation plots |
None
|
Returns:
| Type | Description |
|---|---|
str
|
Status message |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If CSV file doesn't exist |
ValueError
|
If plot_type is invalid |
Example
api.viz.plot_static('logs/test.csv', '3d') 'Plot 3d generated successfully'
api.viz.plot_static('logs/actual.csv', 'deviation', 'logs/planned.csv') 'Plot deviation generated successfully'
Note
Plots are displayed interactively. Close the plot window to continue.
start_live_plot
¶
Start live plotting of robot data.
Opens an interactive matplotlib window that updates in real-time as robot data is received. Useful for monitoring during operation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mode
|
str
|
Plot mode: - "3d": Live 3D trajectory - "position": Position vs time - "velocity": Velocity vs time - "force": Motor currents vs time |
'3d'
|
interval
|
int
|
Update interval in milliseconds (default: 100ms = 10Hz) |
100
|
Returns:
| Type | Description |
|---|---|
str
|
Status message |
Example
api.viz.start_live_plot('3d', interval=100) 'Live plot started in 3d mode at 100ms interval'
Watch robot move in real-time¶
Close plot window or call stop_live_plot() to end¶
Note
Live plotting runs in a background thread. The plot window must remain open for updates to continue.
stop_live_plot
¶
Stop live plotting.
Closes the live plot window and stops the update thread.
Returns:
| Type | Description |
|---|---|
str
|
Status message |
Example
api.viz.stop_live_plot() 'Live plotting stopped'
change_live_plot_mode
¶
Change the mode of an active live plot.
Switches between different visualization modes without restarting the plot window.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mode
|
str
|
New plot mode (e.g., '3d', 'position', 'velocity', 'force') |
required |
Returns:
| Type | Description |
|---|---|
str
|
Status message |
Example
api.viz.start_live_plot('3d')
... watch for a while ...¶
api.viz.change_live_plot_mode('position') 'Live plot mode changed to position'
visualize_csv_log
staticmethod
¶
Comprehensive visualization of CSV log file.
Generates multiple plots (trajectory, joints, force) using the KukaRSIVisualiser. Optionally exports plots to files.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
csv_file
|
str
|
Path to CSV log file |
required |
export
|
bool
|
If True, save plots to disk instead of displaying |
False
|
Example
Display interactive plots¶
api.viz.visualize_csv_log('logs/test.csv')
Export plots to files¶
api.viz.visualize_csv_log('logs/test.csv', export=True)
Note
This generates three separate plots: - 3D trajectory with start/end markers - Joint angle evolution - Motor current trends
compare_runs
staticmethod
¶
Generate comparison plots for two test runs.
Visualizes deviations between two recorded trajectories for repeatability analysis.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file1
|
str
|
Path to first CSV log file |
required |
file2
|
str
|
Path to second CSV log file |
required |
Returns:
| Type | Description |
|---|---|
str
|
Status message |
Example
api.viz.compare_runs('run1.csv', 'run2.csv') 'Comparison plots generated successfully'
Note
Uses plot_static() with deviation mode internally.