File size: 1,293 Bytes
0ef7073
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
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)")