@@ -66,17 +66,7 @@ def get_dv_w_J_e(self, bs_idx, v, Minv, Jac, Jac_v, v_star, mu, cor, DPhi):
6666 J_e = J_e_T .t () #
6767 Minv_J_e_T = (Minv @ J_e_T .reshape (n , d * C )).reshape (n * d , C )
6868 J_e_Minv_J_e_T = J_e @ Minv_J_e_T # (C, C)
69- # M_e = torch.inverse(J_e_Minv_J_e_T + torch.eye(J_e_Minv_J_e_T.shape[0]).type_as(v)*1e-3) # (C, C) inertia in equality contact space
7069 M_e = torch .inverse (J_e_Minv_J_e_T ) # (C, C) inertia in equality contact space
71- # L = torch.cholesky(Minv) # (n, n)
72- # L_T = L.t() # (n, n)
73- # L_T_J_e_T = (L_T @ J_e_T.reshape(n, d*C)).reshape(n*d, C)
74- # Q = (L_T_J_e_T @ M_e) @ L_T_J_e_T.t() # (n*d, n*d)
75- # e, V = symeig(Q)
76- # if not torch.allclose(e, (e>0.5).to(dtype=e.dtype), atol=1e-6):
77- # print(f"warning: eigenvalues is {e}")
78- # L_V_s = (L @ V[:, :n*d-C].reshape(n, d*(n*d-C))).reshape(n*d, n*d-C) # (n*d, n*d-C)
79- # V_s_T_L_T_Jac_T = L_V_s.t() @ Jac.reshape(n_cld*d, n*d).t() # (n*d-C, n_cld*d)
8070 factor = torch .eye (n * d ).type_as (v ) - J_e_T @ M_e @ Minv_J_e_T .t ()
8171 M_hat_inv = (Minv @ factor .reshape (n , d * n * d )).reshape (n * d , n * d )
8272 A = Jac .reshape (n_cld * d , n * d ) @ M_hat_inv @ Jac .reshape (n_cld * d , n * d ).t ()
@@ -86,14 +76,9 @@ def get_dv_w_J_e(self, bs_idx, v, Minv, Jac, Jac_v, v_star, mu, cor, DPhi):
8676 else :
8777 reg = self .reg
8878 A_decom = torch .cholesky (A + torch .eye (A .shape [0 ]).type_as (A )* reg , upper = True )
89- # A_decom = V_s_T_L_T_Jac_T
9079 # make sure v_star is "valid", avoid unbounded cvx problem
9180 v_star_c = self .get_v_star_c_w_J_e (n_cld , n , d , v_star , Jac .reshape (n_cld * d , n * d ), J_e )
9281
93- # Jac_T_v_star = Jac.reshape(n_cld*d, n*d).t() @ v_star.reshape(n_cld*d, 1) # (n*d, 1)
94- # J_e_Jac_T_v_star = J_e @ Jac_T_v_star # (C, 1)
95- # v_right = J_e_T @ torch.solve(J_e_Jac_T_v_star, J_e @ J_e_T)[0] # (n*d, 1)
96- # v_star_c = Jac.reshape(n_cld*d, n*d) @ (Jac_T_v_star - v_right) # (n_cld*d, 1)
9782 # compression phase impulse
9883 try :
9984 impulse = self .solve_compression_impulse (
@@ -105,10 +90,9 @@ def get_dv_w_J_e(self, bs_idx, v, Minv, Jac, Jac_v, v_star, mu, cor, DPhi):
10590 A_decom , Jac_v , mu , n_cld , d
10691 )
10792 except SolverError as e :
108- self .save (e , "comp" , bs_idx , v , Minv , Jac , Jac_v , v_star , mu , cor , DPhi )
93+ # self.save(e, "comp", bs_idx, v, Minv, Jac, Jac_v, v_star, mu, cor, DPhi)
10994 impulse = torch .zeros (n_cld * d , 1 ).type_as (v )
11095 # velocity after compression phase (before retitution phase)
111- # M_hat_inv = L_V_s @ L_V_s.t() #(n*d, n*d)
11296 M_hat_inv_Jac_T = M_hat_inv @ Jac .reshape (n_cld * d , n * d ).t () # (n*d, n_cld*d)
11397 dv_comp = (M_hat_inv_Jac_T @ impulse ).reshape (n , d )
11498 v_prev_r = v [bs_idx ] + dv_comp
@@ -125,7 +109,7 @@ def get_dv_w_J_e(self, bs_idx, v, Minv, Jac, Jac_v, v_star, mu, cor, DPhi):
125109 A_decom , Jac_v_prev_r , v_star_c , mu , n_cld , d , target_impulse = target_impulse
126110 )
127111 except SolverError as e :
128- self .save (e , "rest" , bs_idx , v , Minv , Jac , Jac_v , v_star , mu , cor , DPhi )
112+ # self.save(e, "rest", bs_idx, v, Minv, Jac, Jac_v, v_star, mu, cor, DPhi)
129113 impulse_star_r = torch .zeros (n_cld * d , 1 ).type_as (v )
130114 # velocity after restitution phase, compensate penetration
131115 dv_rest = (M_hat_inv_Jac_T @ impulse_star_r ).reshape (n , d )
@@ -137,9 +121,6 @@ def get_dv_wo_J_e(self, bs_idx, v, Minv, Jac, Jac_v, v_star, mu, cor):
137121 n_cld , d , n_o , n_p , _ = Jac .shape
138122 n = n_o * n_p
139123 # calculate A_decom
140- # Minv_sqrt = torch.cholesky(Minv) # (n, n)
141- # Minv_sqrt_Jac_T = (Minv_sqrt @ Jac.reshape(n_cld*d, n*d).t().reshape(n, d*n_cld*d)).reshape(n*d, n_cld*d)
142- # A_decom = Minv_sqrt_Jac_T
143124 Minv_Jac_T = (Minv @ Jac .reshape (n_cld * d , n * d ).t ().reshape (n , d * n_cld * d )).reshape (n * d , n_cld * d )
144125 A = Jac .reshape (n_cld * d , n * d ) @ Minv_Jac_T
145126
@@ -185,10 +166,9 @@ def get_dv_wo_J_e(self, bs_idx, v, Minv, Jac, Jac_v, v_star, mu, cor):
185166 A_decom , Jac_v , mu , n_cld , d
186167 )
187168 except SolverError as e :
188- self .save (e , "comp" , bs_idx , v , Minv , Jac , Jac_v , v_star , mu , cor )
169+ # self.save(e, "comp", bs_idx, v, Minv, Jac, Jac_v, v_star, mu, cor)
189170 impulse = torch .zeros (n_cld * d , 1 ).type_as (v )
190171 # velocity after compression phase (before retitution phase)
191- # Minv_Jac_T = (Minv @ Jac.reshape(n_cld*d, n*d).t().reshape(n, d*n_cld*d)).reshape(n*d, n_cld*d)
192172 dv_comp = (Minv_Jac_T @ impulse ).reshape (n , d )
193173 v_prev_r = v [bs_idx ] + dv_comp
194174 # restitution phase impulse
@@ -204,7 +184,7 @@ def get_dv_wo_J_e(self, bs_idx, v, Minv, Jac, Jac_v, v_star, mu, cor):
204184 A_decom , Jac_v_prev_r , v_star_c , mu , n_cld , d , target_impulse = target_impulse
205185 )
206186 except :
207- self .save (e , "rest" , bs_idx , v , Minv , Jac , Jac_v , v_star , mu , cor )
187+ # self.save(e, "rest", bs_idx, v, Minv, Jac, Jac_v, v_star, mu, cor)
208188 impulse_star_r = torch .zeros (n_cld * d , 1 ).type_as (v )
209189 # velocity after restitution phase
210190 dv_rest = (Minv_Jac_T @ impulse_star_r ).reshape (n , d )
0 commit comments