|
| 1 | +import numpy as np |
| 2 | + |
| 3 | + |
| 4 | +class Config: |
| 5 | + SIMULATION_NAME = "" |
| 6 | + USE_FAST = True # if true use cumba's methods |
| 7 | + SPAWN_TYPE = "trajectory" |
| 8 | + |
| 9 | + # ----------------------------- Simulation params ---------------------------- # |
| 10 | + dt = 0.005 |
| 11 | + |
| 12 | + # -------------------------------- Cost params ------------------------------- # |
| 13 | + STATE_SIZE = 5 |
| 14 | + INPUT_SIZE = 2 |
| 15 | + ANGLE_IDX = 2 # state vector index which is angle, used to fit diff in |
| 16 | + |
| 17 | + R = np.diag([0.05, 0.05]) # control cost |
| 18 | + Q = np.diag([1, 1, 1, 1, 0]) # state cost | x, y, theta, v, omega |
| 19 | + Sf = np.diag([0, 0, 0, 0, 0]) # final state cost |
| 20 | + |
| 21 | + # STATE_SIZE = 4 |
| 22 | + # INPUT_SIZE = 2 |
| 23 | + |
| 24 | + # R = np.diag([0.05, 0.05]) # control cost |
| 25 | + # Q = np.diag([2.5, 2.5, 0, 0]) # state cost | r, omega, v, omega |
| 26 | + # Sf = np.diag([2.5, 2.5, 0, 0]) # final state cost |
| 27 | + |
| 28 | + # ------------------------------- Mouse params ------------------------------- # |
| 29 | + # ? works |
| 30 | + mouse = dict( |
| 31 | + mouse_type="working", |
| 32 | + L=1.5, # half body width | cm |
| 33 | + R=1, # radius of wheels | cm |
| 34 | + d=0.1, # distance between axel and CoM | cm |
| 35 | + length=3, # cm |
| 36 | + m=round(20 / 9.81, 2), # mass | g |
| 37 | + m_w=round(2 / 9.81, 2), # mass of wheels/legs |g |
| 38 | + ) |
| 39 | + |
| 40 | + # ? more realistic |
| 41 | + # mouse = dict( |
| 42 | + # mouse_type = 'realistic', |
| 43 | + # L=2, # half body width | cm |
| 44 | + # R=2, # radius of wheels | cm |
| 45 | + # d=3, # distance between axel and CoM | cm |
| 46 | + # length=8.6, # cm |
| 47 | + # m=round(25 / 9.81, 2), # mass | g |
| 48 | + # m_w=round(0.6 / 9.81, 2), # mass of wheels/legs |g |
| 49 | + # ) |
| 50 | + |
| 51 | + # ------------------------------ Goal trajectory ----------------------------- # |
| 52 | + |
| 53 | + trajectory = dict( # parameters of the goals trajectory |
| 54 | + name="tracking", |
| 55 | + nsteps=1000, |
| 56 | + distance=150, |
| 57 | + max_speed=100, |
| 58 | + min_speed=80, |
| 59 | + min_dist=5, # if agent is within this distance from trajectory end the goal is considered achieved |
| 60 | + dist_th=60, # keep frames only after moved away from start location |
| 61 | + resample=True, # if True when using tracking trajectory resamples it |
| 62 | + max_deg_interpol=8, # if using track fit a N degree polynomial to daa to smoothen |
| 63 | + randomize=True, # if true when using tracking it pulls a random trial |
| 64 | + ) |
| 65 | + |
| 66 | + # ------------------------------ Planning params ----------------------------- # |
| 67 | + planning = dict( # params used to compute goal states to be used for control |
| 68 | + prediction_length=80, |
| 69 | + n_ahead=5, # start prediction states from N steps ahead |
| 70 | + ) |
| 71 | + |
| 72 | + # --------------------------------- Plotting --------------------------------- # |
| 73 | + traj_plot_every = 15 |
| 74 | + |
| 75 | + # ------------------------------ Control params ------------------------------ # |
| 76 | + iLQR = dict( |
| 77 | + max_iter=500, |
| 78 | + init_mu=1.0, |
| 79 | + mu_min=1e-6, |
| 80 | + mu_max=1e10, |
| 81 | + init_delta=2.0, |
| 82 | + threshold=1e-6, |
| 83 | + ) |
| 84 | + |
| 85 | + def config_dict(self): |
| 86 | + return dict( |
| 87 | + dt=self.dt, |
| 88 | + STATE_SIZE=self.STATE_SIZE, |
| 89 | + INPUT_SIZE=self.INPUT_SIZE, |
| 90 | + R=list(np.diag(self.R).tolist()), |
| 91 | + Q=list(np.diag(self.Q).tolist()), |
| 92 | + Sf=list(np.diag(self.Sf).tolist()), |
| 93 | + mouse=self.mouse, |
| 94 | + trajectory=self.trajectory, |
| 95 | + planning=self.planning, |
| 96 | + iLQR=self.iLQR, |
| 97 | + ) |
0 commit comments