-
Notifications
You must be signed in to change notification settings - Fork 11
/
run_simulations.py
76 lines (68 loc) · 3.59 KB
/
run_simulations.py
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import os
import numpy as np
from copy import deepcopy
import subprocess
# ros2 run steam_icp steam_icp --ros-args --params-file /home/krb/Documents/steam_icp/steam_icp/config/ncd_steamlo_config.yaml -p odometry_options.steam.use_imu:=false -p odometry_options.steam.use_accel:=false -p odometry_options.steam.use_line_search:=false -p dataset_options.lidar_timestamp_round:=true -p dataset_options.lidar_timestamp_round_hz:=10000.0 -p log_dir:=/home/krb/ASRL/temp/steam_icp/experiments/37 -p output_dir:=/home/krb/ASRL/temp/steam_icp/experiments/37
base_arg = "ros2 run steam_icp simulation --ros-args --params-file /home/krb/Documents/steam_icp/steam_icp/simulation/sim.yaml"
N = 20
np.random.seed(42)
# Slow
for i in range(N):
print(f"SLOW SIMULATION {i + 1} / {N}")
arg = deepcopy(base_arg)
arg += f" -p output_dir:=/workspace/raid/krb/boreas/robotica_sims/slow_{i:04}"
# v0 = np.random.uniform(0.5, 1.0)
# w0 = np.random.uniform(0.1, 0.5)
v0 = 0.0
w0 = 0.0
arg += f" -p x0:=[0.,0.,0.,0.,0.,0.,{v0},0.,0.,0.,0.,{w0},0.0,0.,0.,0.,0.,0.0]"
la = body_centric_linear_velocity_amplitudes = np.random.uniform(0.1, 0.5, size=3)
aa = body_centric_angular_velocity_amplitudes = np.random.uniform(0.1, 0.5, size=3)
arg += f" -p v_amps:=[{la[0]},{la[1]},{la[2]},{0.0},{0.0},{0.0}]"
lf = body_centric_linear_velocity_frequencies = np.random.uniform(0.5, 1.0, size=3)
af = body_centric_angular_velocity_frequencies = np.random.uniform(1.0, 2.0, size=3)
arg += f" -p v_freqs:=[{lf[0]},{lf[1]},{lf[2]},{0.0},{0.0},{0.0}]"
print(arg)
p = subprocess.Popen(arg.split(), stdout=subprocess.PIPE)
p.wait()
print(p.returncode)
# Medium
for i in range(N):
print(f"MEDIUM SIMULATION {i + 1} / {N}")
arg = deepcopy(base_arg)
arg += f" -p output_dir:=/workspace/raid/krb/boreas/robotica_sims/medium_{i:04}"
# v0 = np.random.uniform(1.0, 2.0)
# w0 = np.random.uniform(0.5, 1.0)
v0 = 0.0
w0 = 0.0
arg += f" -p x0:=[0.,0.,0.,0.,0.,0.,{v0},0.,0.,0.,0.,{w0},0.0,0.,0.,0.,0.,0.0]"
la = body_centric_linear_velocity_amplitudes = np.random.uniform(0.5, 1.0, size=3)
aa = body_centric_angular_velocity_amplitudes = np.random.uniform(0.5, 1.0, size=3)
arg += f" -p v_amps:=[{la[0]},{la[1]},{la[2]},{aa[0]},{aa[1]},{aa[2]}]"
lf = body_centric_linear_velocity_frequencies = np.random.uniform(1.0, 2.0, size=3)
af = body_centric_angular_velocity_frequencies = np.random.uniform(2.0, 4.0, size=3)
arg += f" -p v_freqs:=[{lf[0]},{lf[1]},{lf[2]},{af[0]},{af[1]},{af[2]}]"
print(arg)
p = subprocess.Popen(arg.split(), stdout=subprocess.PIPE)
p.wait()
print(p.returncode)
# Fast
for i in range(N):
print(f"FAST SIMULATION {i + 1} / {N}")
arg = deepcopy(base_arg)
arg += f" -p output_dir:=/workspace/raid/krb/boreas/robotica_sims/fast_{i:04}"
# v0 = np.random.uniform(2.0, 3.0)
# w0 = np.random.uniform(1.0, 2.0)
v0 = 0.0
w0 = 0.0
arg += f" -p x0:=[0.,0.,0.,0.,0.,0.,{v0},0.,0.,0.,0.,{w0},0.0,0.,0.,0.,0.,0.0]"
la = body_centric_linear_velocity_amplitudes = np.random.uniform(1.0, 2.0, size=3)
aa = body_centric_angular_velocity_amplitudes = np.random.uniform(1.0, 2.0, size=3)
arg += f" -p v_amps:=[{la[0]},{la[1]},{la[2]},{aa[0]},{aa[1]},{aa[2]}]"
lf = body_centric_linear_velocity_frequencies = np.random.uniform(2.0, 4.0, size=3)
af = body_centric_angular_velocity_frequencies = np.random.uniform(4.0, 8.0, size=3)
arg += f" -p v_freqs:=[{lf[0]},{lf[1]},{lf[2]},{af[0]},{af[1]},{af[2]}]"
print(arg)
p = subprocess.Popen(arg.split(), stdout=subprocess.PIPE)
p.wait()
print(p.returncode)