Logging¶
Per-cycle CSV logging of every exchanged variable, in its own process.
Usage¶
# Start logging (auto-generates filename in logs/)
path = api.logging.start()
print(path) # logs/17-04-2026_14-32-45.csv
# Or specify filename
api.logging.start("my_experiment.csv")
api.logging.is_active() # True
api.logging.stop()
Logs include British-format timestamps, all send/receive variables per cycle. Logging runs in a separate process to avoid interfering with the 4 ms control loop.
Reference¶
LoggingAPI
¶
CSV data logging interface for KUKA RSI robot control.
Manages high-frequency data logging to CSV files with British date format timestamps. Logging runs in a separate process to avoid timing interference with the real-time control loop.
Initialize LoggingAPI namespace.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
client
|
RSIClient
|
RSIClient instance for logging control |
required |
start
¶
Start CSV logging to file.
Creates a background logging process that writes send/receive variables to CSV with British date format timestamps (DD/MM/YYYY HH:MM:SS.mmm).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
Optional[str]
|
Optional output file path. Auto-generated if not provided with format: logs/DD-MM-YYYY_HH-MM-SS.csv |
None
|
Returns:
| Type | Description |
|---|---|
str
|
Path to the log file being written |
Example
Auto-generated filename¶
path = api.logging.start() print(path) logs/16-01-2026_14-32-45.csv
Custom filename¶
path = api.logging.start('my_experiment.csv') print(path) my_experiment.csv
Note
Logging runs in a separate process and uses a queue-based buffering system to prevent blocking the real-time control loop. If the queue fills, old entries are dropped rather than blocking.
stop
¶
Stop CSV logging.
Signals the logging process to flush remaining data and close the file. The logging process will terminate gracefully.
Returns:
| Type | Description |
|---|---|
str
|
Status message |
Example
api.logging.stop() 'CSV logging stopped'
Note
There may be a brief delay (up to 2 seconds) while the logging process completes writing buffered data and shuts down.
is_active
¶
Check if CSV logging is currently running.
Returns:
| Type | Description |
|---|---|
bool
|
True if logging process is active and writing data |
Example
api.logging.start('test.csv') api.logging.is_active() True api.logging.stop() api.logging.is_active() False
export
¶
Export the most recent recorded CSV log to a new file.
Copies the log recorded via start()/stop() (or an explicit source file) to the given destination — a snapshot you can hand off while later runs overwrite the working log.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
Output CSV file path |
'movement_log.csv'
|
source
|
Optional[str]
|
Source log to export (default: the last file passed to start() in this session) |
None
|
Returns:
| Type | Description |
|---|---|
str
|
Status message with export path |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If no log has been recorded this session and no source was given |
FileNotFoundError
|
If the source log file does not exist |
Example
api.logging.start('logs/run1.csv')
... motion ...¶
api.logging.stop() api.logging.export('run1_snapshot.csv') 'Movement data exported to run1_snapshot.csv'