Data Logging¶
Learning Objectives¶
After completing this tutorial, you will have learned:
- How to record simulation data using the
DataLoggerclass - How to save recorded data to a JSON file
- How to load and replay saved data (trajectory replay and scene replay)
Getting Started¶
Prerequisites¶
- Complete Tutorial 4: Adding a Manipulator Robot before starting this tutorial.
Estimated Time¶
Approximately 10-15 minutes.
Overview¶
In robotics simulation, recording robot joint states, control inputs, and positions of objects in the environment is useful for debugging and analysis. Isaac Sim provides the DataLogger class to record simulation data at each physics step and save it as a JSON file.
In this tutorial, we use the Follow Target sample, where a Franka robot follows a target, to record and replay data.
Recording Data¶
Loading the Sample¶
- Activate Windows > Examples > Robotics Examples to open the Robotics Examples tab.
- Click Robotics Examples > Manipulation > Follow Target Task.
- Press the LOAD button to load the world. A Franka robot and a target cube are placed in the scene.
Performing the Recording¶
- In the Follow Target menu's Data Logging section, specify the Output Directory for the JSON file.
- Click the Follow Target button under Task Controls to start the task.
- Click the START LOGGING button to begin recording.
- Move the target cube in the viewport and observe the Franka following it.
- After a few seconds, click the SAVE DATA button to save the data.
- Create a new stage via File > New From Stage Template > Empty.
Code Overview¶
Let's examine the Follow Target sample code to understand how to use the DataLogger.
Source Code Location
The Follow Target sample source code is located at:
<Isaac Sim Install Directory>/exts/isaacsim.examples.interactive/isaacsim/examples/interactive/follow_target/follow_target.py
Registering the Logging Function¶
With DataLogger, you register a logging function called at every physics step to define the data to record.
frame_logging_func takes tasks and scene as arguments and returns a dictionary. The dictionary keys are data item names, and the values are the data to record. This function is automatically called at every physics step while the DataLogger is started.
| Data Item | Description |
|---|---|
joint_positions |
Current joint positions of the robot |
applied_joint_positions |
Joint positions commanded by the controller |
target_position |
World coordinates of the target |
Saving Data¶
save() writes to a JSON file, and reset() clears the internal state.
Data Format¶
The saved JSON file has the following structure:
{
"Isaac Sim Data": [
{
"current_time": 1.483,
"current_time_step": 89,
"data": {
"joint_positions": [0.075, -1.231, 0.113, ...],
"applied_joint_positions": [0.072, -1.220, 0.119, ...],
"target_position": [0.0, 10.0, 70.0]
}
},
...
]
}
Metadata automatically added to each frame:
| Field | Description |
|---|---|
current_time |
Elapsed time since simulation start (seconds) |
current_time_step |
Frame index |
data |
Dictionary returned by frame_logging_func |
Replaying Data¶
Use the recorded data to reproduce robot motion.
Loading the Sample¶
- Click Robotics Examples > Manipulation > Replay Follow Target Task.
- Press the LOAD button to load the world.
- In the Data Replay section, specify the path to the previously saved JSON file in the Data File field.
Trajectory Replay¶
Trajectory replay applies recorded joint position commands to the robot to reproduce its motion. The target position is not updated.
- Click the Replay Trajectory button.
Source Code Location
The Replay Follow Target sample source code is located at:
<Isaac Sim Install Directory>/exts/isaacsim.examples.interactive/isaacsim/examples/interactive/replay_follow_target/replay_follow_target.py
Trajectory Replay Code¶
Replay workflow:
load()reads data from the JSON file- Register a physics callback
- At each physics step, use
get_data_frame()to retrieve the frame data corresponding to the current step - Apply the
applied_joint_positionsas anArticulationAction
Scene Replay¶
Scene replay updates the target position in addition to joint angles, fully reproducing the recorded scene.
- After replay completes, press the Reset button.
- Click the Replay Scene button.
Scene Replay Code¶
The difference from trajectory replay is that set_world_pose() also restores the target's position. This enables complete replay including the environmental state at the time of recording.
- Create a new stage via File > New From Stage Template > Empty.
DataLogger API Reference¶
| Method | Description |
|---|---|
world.get_data_logger() |
Retrieve the DataLogger instance from World |
add_data_frame_logging_func(func) |
Register a logging function called at each physics step |
start() |
Start data recording |
pause() |
Pause data recording |
is_started() |
Return whether recording is in progress |
save(log_path=path) |
Save recorded data to a JSON file |
reset() |
Clear internal state |
load(log_path=path) |
Load data from a JSON file |
get_num_of_data_frames() |
Get the number of recorded frames |
get_data_frame(data_frame_index=i) |
Retrieve frame data at the specified index |
Summary¶
This tutorial covered the following topics:
- Recording simulation data with
DataLogger - Defining custom data items using
frame_logging_func - Saving data in JSON format and understanding the data structure
- Trajectory replay (joint angles only) and Scene replay (complete replay including environment state)
Advanced Usage
DataLogger can also be used for recording reinforcement learning episode data or quantitative evaluation of simulation results. By recording custom data through frame_logging_func, you can support a wide variety of analyses.
Note
The following tutorials continue to use the Extension Workflow for development. Converting to the Standalone Workflow follows the same approach as learned in Hello World.