Download example/Visualize_Sim_Data.py from JiaoyangL/OpenRIF: direct link, hf CLI and curl.
- Browser
- Download file 1.29 kB
-
https://huggingface.co/datasets/JiaoyangL/OpenRIF/resolve/main/example/Visualize_Sim_Data.py
- Command line
-
hf download hf://datasets/JiaoyangL/OpenRIF/example/Visualize_Sim_Data.py
-
curl -L -o Visualize_Sim_Data.py https://huggingface.co/datasets/JiaoyangL/OpenRIF/resolve/main/example/Visualize_Sim_Data.py
1.29 kB
| import numpy as np | |
| import matplotlib.pyplot as plt | |
| from scipy.signal import savgol_filter | |
| # Ban scientific notation in results | |
| np.set_printoptions(precision=2, suppress=True) | |
| # TODO Data path | |
| cls = "Cup" | |
| idx = ["A"] | |
| #idx = ["A", "B", "C"] | |
| def plot_time_series(data, title = "Time Series Data"): | |
| n_ch = data.shape[1] | |
| plt.figure(figsize=(12, 7)) | |
| for i in range(n_ch): | |
| plt.subplot(n_ch, 1, 1+i) | |
| plt.plot(data[:, i], label=f'Channel {i+1}') | |
| plt.suptitle(title) | |
| plt.tight_layout() | |
| plt.show() | |
| for id in idx: | |
| # Load the raw data | |
| path = f'data/Simulation/Pick & Place - Ur5/Simulation_Ur5_{cls}_{id}.npy' | |
| data = np.load(path) | |
| print(f"Loaded data from {path} with shape: {data.shape}") | |
| # Slice the data | |
| joint_pos = data[:, 0:6] | |
| joint_vel = data[:, 6:12] | |
| joint_tor = data[:, 12:18] | |
| ft_readings = data[:, 18:21] | |
| timestamp = data[:, 21] | |
| # ----- 1. Joint Position ----- | |
| plot_time_series(joint_pos, title="Joint Position (6 channels)") | |
| # ----- 2. Joint Velocity ----- | |
| plot_time_series(joint_vel, title="Joint Velocity (6 channels)") | |
| # ----- 3. Joint Torque ----- | |
| plot_time_series(joint_tor, title="Joint Torque (6 channels)") | |