diff --git "a/models/fields.py" "b/models/fields.py" --- "a/models/fields.py" +++ "b/models/fields.py" @@ -445,8 +445,8 @@ class BendingNetworkActiveForceFieldForwardLagV18(nn.Module): self.bending_dir_latent = nn.Embedding( num_embeddings=self.bending_n_timesteps, embedding_dim=self.bending_latent_size ) - # dist_k_a = self.distance_ks_val(torch.zeros((1,)).long().cuda()).view(1) - # dist_k_b = self.distance_ks_val(torch.ones((1,)).long().cuda()).view(1) * 5# *# 0.1 + # dist_k_a = self.distance_ks_val(torch.zeros((1,)).long()).view(1) + # dist_k_b = self.distance_ks_val(torch.ones((1,)).long()).view(1) * 5# *# 0.1 # distance self.distance_ks_val = nn.Embedding( @@ -888,14 +888,14 @@ class BendingNetworkActiveForceFieldForwardLagV18(nn.Module): self.obj_sdf_th = None self.obj_sdf_grad_th = None - self.normal_plane_max_y = torch.tensor([0, 1., 0], dtype=torch.float32).cuda() ## 0, 1, 0 - self.normal_plane_min_y = torch.tensor([0, -1., 0.], dtype=torch.float32).cuda() # + self.normal_plane_max_y = torch.tensor([0, 1., 0], dtype=torch.float32) ## 0, 1, 0 + self.normal_plane_min_y = torch.tensor([0, -1., 0.], dtype=torch.float32) # - self.normal_plane_max_x = torch.tensor([1, 0, 0], dtype=torch.float32).cuda() ## 0, 1, 0 - self.normal_plane_min_x = torch.tensor([-1, 0., 0.], dtype=torch.float32).cuda() # + self.normal_plane_max_x = torch.tensor([1, 0, 0], dtype=torch.float32) ## 0, 1, 0 + self.normal_plane_min_x = torch.tensor([-1, 0., 0.], dtype=torch.float32) # - self.normal_plane_max_z = torch.tensor([0, 0, 1.], dtype=torch.float32).cuda() ## 0, 1, 0 - self.normal_plane_min_z = torch.tensor([0, 0, -1.], dtype=torch.float32).cuda() # + self.normal_plane_max_z = torch.tensor([0, 0, 1.], dtype=torch.float32) ## 0, 1, 0 + self.normal_plane_min_z = torch.tensor([0, 0, -1.], dtype=torch.float32) # ## set the initial passive object verts and normals ### ## the default scene is the box scene ## @@ -1056,10 +1056,10 @@ class BendingNetworkActiveForceFieldForwardLagV18(nn.Module): if self.obj_sdf_th is None: - self.obj_sdf_th = torch.from_numpy(self.obj_sdf).float().cuda() - cur_transformed_pts_xs_th = torch.from_numpy(cur_transformed_pts_xs).long().cuda() - cur_transformed_pts_ys_th = torch.from_numpy(cur_transformed_pts_ys).long().cuda() - cur_transformed_pts_zs_th = torch.from_numpy(cur_transformed_pts_zs).long().cuda() + self.obj_sdf_th = torch.from_numpy(self.obj_sdf).float() + cur_transformed_pts_xs_th = torch.from_numpy(cur_transformed_pts_xs).long() + cur_transformed_pts_ys_th = torch.from_numpy(cur_transformed_pts_ys).long() + cur_transformed_pts_zs_th = torch.from_numpy(cur_transformed_pts_zs).long() cur_pts_sdf = batched_index_select(self.obj_sdf_th, cur_transformed_pts_xs_th, 0) # print(f"After selecting the x-axis: {cur_pts_sdf.size()}") @@ -1070,7 +1070,7 @@ class BendingNetworkActiveForceFieldForwardLagV18(nn.Module): if self.obj_sdf_grad is not None: if self.obj_sdf_grad_th is None: - self.obj_sdf_grad_th = torch.from_numpy(self.obj_sdf_grad).float().cuda() + self.obj_sdf_grad_th = torch.from_numpy(self.obj_sdf_grad).float() self.obj_sdf_grad_th = self.obj_sdf_grad_th / torch.clamp(torch.norm(self.obj_sdf_grad_th, p=2, keepdim=True, dim=-1), min=1e-5) cur_pts_sdf_grad = batched_index_select(self.obj_sdf_grad_th, cur_transformed_pts_xs_th, 0) # nn_pts x res x res x 3 cur_pts_sdf_grad = batched_index_select(cur_pts_sdf_grad, cur_transformed_pts_ys_th.unsqueeze(-1), 1).squeeze(1) @@ -1088,7 +1088,7 @@ class BendingNetworkActiveForceFieldForwardLagV18(nn.Module): # # the contact force dierection should be the negative direction of the sdf gradient? # # # it seems true # # # get the cur_pts_sdf value # - # cur_pts_sdf = torch.from_numpy(cur_pts_sdf).float().cuda() + # cur_pts_sdf = torch.from_numpy(cur_pts_sdf).float() if cur_pts_sdf_grad is None: return cur_pts_sdf else: @@ -1124,10 +1124,10 @@ class BendingNetworkActiveForceFieldForwardLagV18(nn.Module): if self.obj_sdf_th is None: - self.obj_sdf_th = torch.from_numpy(self.obj_sdf).float().cuda() - cur_transformed_pts_xs_th = torch.from_numpy(cur_transformed_pts_xs).long().cuda() - cur_transformed_pts_ys_th = torch.from_numpy(cur_transformed_pts_ys).long().cuda() - cur_transformed_pts_zs_th = torch.from_numpy(cur_transformed_pts_zs).long().cuda() + self.obj_sdf_th = torch.from_numpy(self.obj_sdf).float() + cur_transformed_pts_xs_th = torch.from_numpy(cur_transformed_pts_xs).long() + cur_transformed_pts_ys_th = torch.from_numpy(cur_transformed_pts_ys).long() + cur_transformed_pts_zs_th = torch.from_numpy(cur_transformed_pts_zs).long() cur_pts_sdf = batched_index_select(self.obj_sdf_th, cur_transformed_pts_xs_th, 0) # print(f"After selecting the x-axis: {cur_pts_sdf.size()}") @@ -1138,7 +1138,7 @@ class BendingNetworkActiveForceFieldForwardLagV18(nn.Module): if self.obj_sdf_grad is not None: if self.obj_sdf_grad_th is None: - self.obj_sdf_grad_th = torch.from_numpy(self.obj_sdf_grad).float().cuda() + self.obj_sdf_grad_th = torch.from_numpy(self.obj_sdf_grad).float() self.obj_sdf_grad_th = self.obj_sdf_grad_th / torch.clamp(torch.norm(self.obj_sdf_grad_th, p=2, keepdim=True, dim=-1), min=1e-5) cur_pts_sdf_grad = batched_index_select(self.obj_sdf_grad_th, cur_transformed_pts_xs_th, 0) # nn_pts x res x res x 3 cur_pts_sdf_grad = batched_index_select(cur_pts_sdf_grad, cur_transformed_pts_ys_th.unsqueeze(-1), 1).squeeze(1) @@ -1154,7 +1154,7 @@ class BendingNetworkActiveForceFieldForwardLagV18(nn.Module): # print(f"cur_pts_sdf: {cur_pts_sdf.shape}") # # the contact force dierection should be the negative direction of the sdf gradient? # # # get the cur_pts_sdf value # - # cur_pts_sdf = torch.from_numpy(cur_pts_sdf).float().cuda() + # cur_pts_sdf = torch.from_numpy(cur_pts_sdf).float() if cur_pts_sdf_grad is None: return cur_pts_sdf else: @@ -1318,7 +1318,7 @@ class BendingNetworkActiveForceFieldForwardLagV18(nn.Module): # direction of the normal direction has been changed # # contact region and multiple contact points ## - center_init_passive_obj_verts = torch.zeros((3, ), dtype=torch.float32).cuda() + center_init_passive_obj_verts = torch.zeros((3, ), dtype=torch.float32) self.center_init_passive_obj_verts = center_init_passive_obj_verts.clone() @@ -1345,11 +1345,11 @@ class BendingNetworkActiveForceFieldForwardLagV18(nn.Module): # nn instances # # # cur passive obj ns ## # if self.nn_instances == 1: - # ws_alpha = self.ks_weights(torch.zeros((1,)).long().cuda()).view(1) - # ws_beta = self.ks_weights(torch.ones((1,)).long().cuda()).view(1) + # ws_alpha = self.ks_weights(torch.zeros((1,)).long()).view(1) + # ws_beta = self.ks_weights(torch.ones((1,)).long()).view(1) # else: - # ws_alpha = self.ks_weights[i_instance](torch.zeros((1,)).long().cuda()).view(1) - # ws_beta = self.ks_weights[i_instance](torch.ones((1,)).long().cuda()).view(1) + # ws_alpha = self.ks_weights[i_instance](torch.zeros((1,)).long()).view(1) + # ws_beta = self.ks_weights[i_instance](torch.ones((1,)).long()).view(1) # print(f"sampled_input_pts: {sampled_input_pts.size()}") @@ -1391,7 +1391,7 @@ class BendingNetworkActiveForceFieldForwardLagV18(nn.Module): inter_obj_pts = cur_passive_obj_verts[minn_idx_sampled_pts_to_passive_obj] - cur_passive_obj_verts_pts_idxes = torch.arange(0, cur_passive_obj_verts.size(0), dtype=torch.long).cuda() # + cur_passive_obj_verts_pts_idxes = torch.arange(0, cur_passive_obj_verts.size(0), dtype=torch.long) # # inter_passive_obj_pts_idxes = cur_passive_obj_verts_pts_idxes[minn_idx_sampled_pts_to_passive_obj] @@ -1405,7 +1405,7 @@ class BendingNetworkActiveForceFieldForwardLagV18(nn.Module): # penetrating_depth_penalty = penetrating_depth[penetrating_indicator].mean() # self.penetrating_depth_penalty = penetrating_depth_penalty # if torch.isnan(penetrating_depth_penalty): # get the penetration penalties # - # self.penetrating_depth_penalty = torch.tensor(0., dtype=torch.float32).cuda() + # self.penetrating_depth_penalty = torch.tensor(0., dtype=torch.float32) ###### penetration penalty strategy v1 ###### # ws_beta; 10 # # sum over the forces but not the weighted sum... # @@ -1453,8 +1453,8 @@ class BendingNetworkActiveForceFieldForwardLagV18(nn.Module): # ).contiguous().transpose(1, 0).contiguous() penetrating_indicator = queried_sdf < 0 else: - cur_rot = torch.eye(n=3, dtype=torch.float32).cuda() - cur_trans = torch.zeros((3,), dtype=torch.float32).cuda() + cur_rot = torch.eye(n=3, dtype=torch.float32) + cur_trans = torch.zeros((3,), dtype=torch.float32) if self.penetration_determining == "sdf_of_canon": if self.obj_sdf_grad is None: queried_sdf = self.query_for_sdf_of_canon_obj(sampled_input_pts, (cur_rot, cur_trans)) @@ -1561,27 +1561,27 @@ class BendingNetworkActiveForceFieldForwardLagV18(nn.Module): if self.nn_instances == 1: # spring ks values # contact ks values # # if we set a fixed k value here # - contact_spring_ka = self.spring_ks_values(torch.zeros((1,), dtype=torch.long).cuda()).view(1,) - contact_spring_kb = self.spring_ks_values(torch.zeros((1,), dtype=torch.long).cuda() + 1).view(1,) - # contact_spring_kc = self.spring_ks_values(torch.zeros((1,), dtype=torch.long).cuda() + 3).view(1,) + contact_spring_ka = self.spring_ks_values(torch.zeros((1,), dtype=torch.long)).view(1,) + contact_spring_kb = self.spring_ks_values(torch.zeros((1,), dtype=torch.long) + 1).view(1,) + # contact_spring_kc = self.spring_ks_values(torch.zeros((1,), dtype=torch.long) + 3).view(1,) - # tangential_ks = self.spring_ks_values(torch.ones((1,), dtype=torch.long).cuda()).view(1,) + # tangential_ks = self.spring_ks_values(torch.ones((1,), dtype=torch.long)).view(1,) else: - contact_spring_ka = self.spring_ks_values[i_instance](torch.zeros((1,), dtype=torch.long).cuda()).view(1,) - # contact_spring_kb = self.spring_ks_values[i_instance](torch.zeros((1,), dtype=torch.long).cuda() + 2).view(1,) - # contact_spring_kc = self.spring_ks_values[i_instance](torch.zeros((1,), dtype=torch.long).cuda() + 3).view(1,) + contact_spring_ka = self.spring_ks_values[i_instance](torch.zeros((1,), dtype=torch.long)).view(1,) + # contact_spring_kb = self.spring_ks_values[i_instance](torch.zeros((1,), dtype=torch.long) + 2).view(1,) + # contact_spring_kc = self.spring_ks_values[i_instance](torch.zeros((1,), dtype=torch.long) + 3).view(1,) - # tangential_ks = self.spring_ks_values[i_instance](torch.ones((1,), dtype=torch.long).cuda()).view(1,) + # tangential_ks = self.spring_ks_values[i_instance](torch.ones((1,), dtype=torch.long)).view(1,) # optm_alltime_ks # # optimizable_spring_ks_normal, optimizable_spring_ks_friction # if self.optm_alltime_ks: - opt_penetration_proj_k_to_robot = self.optimizable_spring_ks_normal(torch.zeros((1,), dtype=torch.long).cuda() + input_pts_ts).view(1,) - opt_penetration_proj_k_to_robot_friction = self.optimizable_spring_ks_friction(torch.zeros((1,), dtype=torch.long).cuda() + input_pts_ts).view(1,) + opt_penetration_proj_k_to_robot = self.optimizable_spring_ks_normal(torch.zeros((1,), dtype=torch.long) + input_pts_ts).view(1,) + opt_penetration_proj_k_to_robot_friction = self.optimizable_spring_ks_friction(torch.zeros((1,), dtype=torch.long) + input_pts_ts).view(1,) else: # optimizable_spring_ks # - opt_penetration_proj_k_to_robot = self.optimizable_spring_ks(torch.zeros((1,), dtype=torch.long).cuda()).view(1,) - opt_penetration_proj_k_to_robot_friction = self.optimizable_spring_ks(torch.zeros((1,), dtype=torch.long).cuda() + 1).view(1,) + opt_penetration_proj_k_to_robot = self.optimizable_spring_ks(torch.zeros((1,), dtype=torch.long)).view(1,) + opt_penetration_proj_k_to_robot_friction = self.optimizable_spring_ks(torch.zeros((1,), dtype=torch.long) + 1).view(1,) # self.penetration_proj_k_to_robot = opt_penetration_proj_k_to_robot ** 2 # self.penetration_proj_k_to_robot_friction = opt_penetration_proj_k_to_robot_friction ** 2 @@ -1594,7 +1594,7 @@ class BendingNetworkActiveForceFieldForwardLagV18(nn.Module): # penetration_proj_k_to_robot = opt_penetration_proj_k_to_robot # if self.use_split_params: ## - # contact_spring_ka = self.spring_contact_ks_values(torch.zeros((1,), dtype=torch.long).cuda() + input_pts_ts).view(1,) + # contact_spring_ka = self.spring_contact_ks_values(torch.zeros((1,), dtype=torch.long) + input_pts_ts).view(1,) # if self.use_sqr_spring_stiffness: # contact_spring_ka = contact_spring_ka ** 2 @@ -1635,7 +1635,7 @@ class BendingNetworkActiveForceFieldForwardLagV18(nn.Module): ### contact spring ka ## if torch.isnan(self.penetrating_depth_penalty): # - self.penetrating_depth_penalty = torch.tensor(0., dtype=torch.float32).cuda() + self.penetrating_depth_penalty = torch.tensor(0., dtype=torch.float32) # penetrating_points = sampled_input_pts[penetrating_indicator] # robot to obj # # penetrating_points = sampled_input_pts[in_contact_indicator_robot_to_obj] # @@ -1679,7 +1679,7 @@ class BendingNetworkActiveForceFieldForwardLagV18(nn.Module): # penalty_friction_constraint = (norm_tangential_forces - self.static_friction_mu * norm_along_normals_forces) ** 2 # penalty_friction_constraint[norm_tangential_forces <= self.static_friction_mu * norm_along_normals_forces] = 0. # penalty_friction_constraint = torch.mean(penalty_friction_constraint) # friction - self.penalty_friction_constraint = torch.zeros((1,), dtype=torch.float32).cuda().mean() # penalty friction + self.penalty_friction_constraint = torch.zeros((1,), dtype=torch.float32).mean() # penalty friction # contact_force_d_scalar = norm_along_normals_forces.clone() # friction models # @@ -1804,14 +1804,14 @@ class BendingNetworkActiveForceFieldForwardLagV18(nn.Module): tot_canon_contact_passive_normals.append(canon_contact_passive_normals[remaining_contact_indicators]) else: - remaining_contact_act_idxes = torch.empty((0,), dtype=torch.long).cuda() ## remaining contact act idxes ## + remaining_contact_act_idxes = torch.empty((0,), dtype=torch.long) ## remaining contact act idxes ## # remaining idxes # new_in_contact_indicator_robot_to_obj = in_contact_indicator_robot_to_obj.clone() new_in_contact_indicator_robot_to_obj[remaining_contact_act_idxes] = False - tot_active_pts_idxes = torch.arange(0, sampled_input_pts.size(0), dtype=torch.long).cuda() + tot_active_pts_idxes = torch.arange(0, sampled_input_pts.size(0), dtype=torch.long) if torch.sum(new_in_contact_indicator_robot_to_obj.float()).item() > 0.5: @@ -1990,14 +1990,14 @@ class BendingNetworkActiveForceFieldForwardLagV18(nn.Module): torque = torch.mean(torque, dim=0) forces = torch.mean(forces, dim=0) ## get rigid acc ## # else: - # self.contact_force_d = torch.zeros((3,), dtype=torch.float32).cuda() - torque = torch.zeros((3,), dtype=torch.float32).cuda() - forces = torch.zeros((3,), dtype=torch.float32).cuda() - self.contact_force_d = torch.zeros((1, 3), dtype=torch.float32).cuda() - self.penalty_friction_tangential_forces = torch.zeros((1, 3), dtype=torch.float32).cuda() - self.penalty_based_friction_forces = torch.zeros((1, 3), dtype=torch.float32).cuda() + # self.contact_force_d = torch.zeros((3,), dtype=torch.float32) + torque = torch.zeros((3,), dtype=torch.float32) + forces = torch.zeros((3,), dtype=torch.float32) + self.contact_force_d = torch.zeros((1, 3), dtype=torch.float32) + self.penalty_friction_tangential_forces = torch.zeros((1, 3), dtype=torch.float32) + self.penalty_based_friction_forces = torch.zeros((1, 3), dtype=torch.float32) - self.tot_contact_passive_normals = torch.zeros((1, 3), dtype=torch.float32).cuda() + self.tot_contact_passive_normals = torch.zeros((1, 3), dtype=torch.float32) @@ -2035,25 +2035,25 @@ class BendingNetworkActiveForceFieldForwardLagV18(nn.Module): if self.nn_instances == 1: - time_cons = self.time_constant(torch.zeros((1,)).long().cuda()).view(1) - time_cons_2 = self.time_constant(torch.zeros((1,)).long().cuda() + 2).view(1) - time_cons_rot = self.time_constant(torch.ones((1,)).long().cuda()).view(1) - damping_cons = self.damping_constant(torch.zeros((1,)).long().cuda()).view(1) - damping_cons_rot = self.damping_constant(torch.ones((1,)).long().cuda()).view(1) + time_cons = self.time_constant(torch.zeros((1,)).long()).view(1) + time_cons_2 = self.time_constant(torch.zeros((1,)).long() + 2).view(1) + time_cons_rot = self.time_constant(torch.ones((1,)).long()).view(1) + damping_cons = self.damping_constant(torch.zeros((1,)).long()).view(1) + damping_cons_rot = self.damping_constant(torch.ones((1,)).long()).view(1) else: - time_cons = self.time_constant[i_instance](torch.zeros((1,)).long().cuda()).view(1) - time_cons_2 = self.time_constant[i_instance](torch.zeros((1,)).long().cuda() + 2).view(1) - time_cons_rot = self.time_constant[i_instance](torch.ones((1,)).long().cuda()).view(1) - damping_cons = self.damping_constant[i_instance](torch.zeros((1,)).long().cuda()).view(1) - damping_cons_rot = self.damping_constant[i_instance](torch.ones((1,)).long().cuda()).view(1) + time_cons = self.time_constant[i_instance](torch.zeros((1,)).long()).view(1) + time_cons_2 = self.time_constant[i_instance](torch.zeros((1,)).long() + 2).view(1) + time_cons_rot = self.time_constant[i_instance](torch.ones((1,)).long()).view(1) + damping_cons = self.damping_constant[i_instance](torch.zeros((1,)).long()).view(1) + damping_cons_rot = self.damping_constant[i_instance](torch.ones((1,)).long()).view(1) ## if self.use_split_params: ## ## friction network should be trained? ## # sep_time_constant, sep_torque_time_constant, sep_damping_constant, sep_angular_damping_constant - time_cons = self.sep_time_constant(torch.zeros((1,)).long().cuda() + input_pts_ts).view(1) - time_cons_2 = self.sep_torque_time_constant(torch.zeros((1,)).long().cuda() + input_pts_ts).view(1) - # damping_cons = self.sep_damping_constant(torch.zeros((1,)).long().cuda() + input_pts_ts).view(1) - # damping_cons_2 = self.sep_angular_damping_constant(torch.zeros((1,)).long().cuda() + input_pts_ts).view(1) + time_cons = self.sep_time_constant(torch.zeros((1,)).long() + input_pts_ts).view(1) + time_cons_2 = self.sep_torque_time_constant(torch.zeros((1,)).long() + input_pts_ts).view(1) + # damping_cons = self.sep_damping_constant(torch.zeros((1,)).long() + input_pts_ts).view(1) + # damping_cons_2 = self.sep_angular_damping_constant(torch.zeros((1,)).long() + input_pts_ts).view(1) # time_cons = 0.05 # time_cons_2 = 0.05 @@ -2087,7 +2087,7 @@ class BendingNetworkActiveForceFieldForwardLagV18(nn.Module): obj_mass = self.obj_mass - obj_mass_value = self.optimizable_obj_mass(torch.zeros((1,), dtype=torch.long).cuda()).view(1) + obj_mass_value = self.optimizable_obj_mass(torch.zeros((1,), dtype=torch.long)).view(1) obj_mass_value = obj_mass_value ** 2 @@ -2104,15 +2104,15 @@ class BendingNetworkActiveForceFieldForwardLagV18(nn.Module): if self.use_optimizable_params: ## - damping_coef = self.sep_damping_constant(torch.zeros((1,), dtype=torch.long).cuda()).view(1) - damping_coef_angular = self.sep_angular_damping_constant(torch.zeros((1,), dtype=torch.long).cuda()).view(1,) + damping_coef = self.sep_damping_constant(torch.zeros((1,), dtype=torch.long)).view(1) + damping_coef_angular = self.sep_angular_damping_constant(torch.zeros((1,), dtype=torch.long)).view(1,) damping_coef = damping_coef ** 2 damping_coef_angular = damping_coef_angular ** 2 ## sue the sampiing coef angular and dampoing coef here ## if self.use_damping_params_vel: - damping_coef_lin_vel = self.lin_damping_coefs(torch.zeros((1,), dtype=torch.long).cuda()).view(1) - damping_coef_ang_vel = self.ang_damping_coefs(torch.zeros((1,), dtype=torch.long).cuda()).view(1) + damping_coef_lin_vel = self.lin_damping_coefs(torch.zeros((1,), dtype=torch.long)).view(1) + damping_coef_ang_vel = self.ang_damping_coefs(torch.zeros((1,), dtype=torch.long)).view(1) damping_coef_lin_vel = damping_coef_lin_vel ** 2 damping_coef_ang_vel = damping_coef_ang_vel ** 2 else: @@ -2144,7 +2144,7 @@ class BendingNetworkActiveForceFieldForwardLagV18(nn.Module): cur_rigid_def = self.timestep_to_total_def[input_pts_ts].detach() # timestep - cur_inertia_div_factor = self.inertia_div_factor(torch.zeros((1,), dtype=torch.long).cuda()).view(1) + cur_inertia_div_factor = self.inertia_div_factor(torch.zeros((1,), dtype=torch.long)).view(1) # cur inv inertia is a large value? # # bug free? # ### divide the inv_inertia using the factor 20.0 # @@ -2152,9 +2152,9 @@ class BendingNetworkActiveForceFieldForwardLagV18(nn.Module): # cur_inv_inertia = torch.matmul(torch.matmul(cur_passive_obj_rot, self.I_inv_ref), cur_passive_obj_rot.transpose(1, 0)) / float(10.) ## # cur_inv_inertia = torch.matmul(torch.matmul(cur_passive_obj_rot, self.I_inv_ref), cur_passive_obj_rot.transpose(1, 0)) / float(cur_inertia_div_factor) ## - cur_inv_inertia = torch.eye(n=3, dtype=torch.float32).cuda() # three values for the inertia? # + cur_inv_inertia = torch.eye(n=3, dtype=torch.float32) # three values for the inertia? # - obj_inertia_value = self.obj_inertia(torch.zeros((1,), dtype=torch.long).cuda()).view(3,) + obj_inertia_value = self.obj_inertia(torch.zeros((1,), dtype=torch.long)).view(3,) obj_inertia_value = obj_inertia_value ** 2 # cur_inv_inertia = torch.diag(obj_inertia_value) cur_inv_inertia = cur_inv_inertia * obj_inertia_value.unsqueeze(0) ## 3 x 3 matrix ## ### the inertia values ## @@ -2220,8 +2220,8 @@ class BendingNetworkActiveForceFieldForwardLagV18(nn.Module): if input_pts_ts == 0 and input_pts_ts not in self.timestep_to_optimizable_total_def: self.timestep_to_total_def[input_pts_ts] = torch.zeros_like(cur_upd_rigid_def) self.timestep_to_optimizable_total_def[input_pts_ts] = torch.zeros_like(cur_optimizable_total_def) - self.timestep_to_optimizable_quaternion[input_pts_ts] = torch.tensor([1., 0., 0., 0.],dtype=torch.float32).cuda() - self.timestep_to_quaternion[input_pts_ts] = torch.tensor([1., 0., 0., 0.],dtype=torch.float32).cuda() + self.timestep_to_optimizable_quaternion[input_pts_ts] = torch.tensor([1., 0., 0., 0.],dtype=torch.float32) + self.timestep_to_quaternion[input_pts_ts] = torch.tensor([1., 0., 0., 0.],dtype=torch.float32) self.timestep_to_angular_vel[input_pts_ts] = torch.zeros_like(cur_angular_vel).detach() self.timestep_to_total_def[nex_pts_ts] = cur_upd_rigid_def self.timestep_to_optimizable_total_def[nex_pts_ts] = cur_optimizable_total_def @@ -2233,7 +2233,7 @@ class BendingNetworkActiveForceFieldForwardLagV18(nn.Module): # new_pts = raw_input_pts - cur_offset.unsqueeze(0) self.timestep_to_angular_vel[input_pts_ts] = cur_angular_vel.detach() - # self.timestep_to_optimizable_total_def[input_pts_ts + 1] = self.time_translations(torch.zeros((1,), dtype=torch.long).cuda() + input_pts_ts).view(3) + # self.timestep_to_optimizable_total_def[input_pts_ts + 1] = self.time_translations(torch.zeros((1,), dtype=torch.long) + input_pts_ts).view(3) self.timestep_to_input_pts[input_pts_ts] = sampled_input_pts.detach() @@ -2378,8 +2378,8 @@ class BendingNetworkActiveForceFieldForwardLagV16(nn.Module): self.bending_dir_latent = nn.Embedding( num_embeddings=self.bending_n_timesteps, embedding_dim=self.bending_latent_size ) - # dist_k_a = self.distance_ks_val(torch.zeros((1,)).long().cuda()).view(1) - # dist_k_b = self.distance_ks_val(torch.ones((1,)).long().cuda()).view(1) * 5# *# 0.1 + # dist_k_a = self.distance_ks_val(torch.zeros((1,)).long()).view(1) + # dist_k_b = self.distance_ks_val(torch.ones((1,)).long()).view(1) * 5# *# 0.1 # distance self.distance_ks_val = nn.Embedding( @@ -2871,10 +2871,10 @@ class BendingNetworkActiveForceFieldForwardLagV16(nn.Module): if self.obj_sdf_th is None: - self.obj_sdf_th = torch.from_numpy(self.obj_sdf).float().cuda() - cur_transformed_pts_xs_th = torch.from_numpy(cur_transformed_pts_xs).long().cuda() - cur_transformed_pts_ys_th = torch.from_numpy(cur_transformed_pts_ys).long().cuda() - cur_transformed_pts_zs_th = torch.from_numpy(cur_transformed_pts_zs).long().cuda() + self.obj_sdf_th = torch.from_numpy(self.obj_sdf).float() + cur_transformed_pts_xs_th = torch.from_numpy(cur_transformed_pts_xs).long() + cur_transformed_pts_ys_th = torch.from_numpy(cur_transformed_pts_ys).long() + cur_transformed_pts_zs_th = torch.from_numpy(cur_transformed_pts_zs).long() cur_pts_sdf = batched_index_select(self.obj_sdf_th, cur_transformed_pts_xs_th, 0) # print(f"After selecting the x-axis: {cur_pts_sdf.size()}") @@ -2893,7 +2893,7 @@ class BendingNetworkActiveForceFieldForwardLagV16(nn.Module): # # the contact force dierection should be the negative direction of the sdf gradient? # # # it seems true # # # get the cur_pts_sdf value # - # cur_pts_sdf = torch.from_numpy(cur_pts_sdf).float().cuda() + # cur_pts_sdf = torch.from_numpy(cur_pts_sdf).float() return cur_pts_sdf # # cur_pts_sdf # # def forward(self, input_pts_ts, timestep_to_active_mesh, timestep_to_passive_mesh, passive_sdf_net, active_bending_net, active_sdf_net, details=None, special_loss_return=False, update_tot_def=True): @@ -2903,8 +2903,8 @@ class BendingNetworkActiveForceFieldForwardLagV16(nn.Module): # prev_pts_ts = input_pts_ts - 1 # ''' Kinematics rigid transformations only ''' # timestep_to_optimizable_total_def, timestep_to_optimizable_quaternion # # - # self.timestep_to_optimizable_total_def[input_pts_ts + 1] = self.time_translations(torch.zeros((1,), dtype=torch.long).cuda() + input_pts_ts).view(3) # - # self.timestep_to_optimizable_quaternion[input_pts_ts + 1] = self.time_quaternions(torch.zeros((1,), dtype=torch.long).cuda() + input_pts_ts).view(4) # + # self.timestep_to_optimizable_total_def[input_pts_ts + 1] = self.time_translations(torch.zeros((1,), dtype=torch.long) + input_pts_ts).view(3) # + # self.timestep_to_optimizable_quaternion[input_pts_ts + 1] = self.time_quaternions(torch.zeros((1,), dtype=torch.long) + input_pts_ts).view(4) # # cur_optimizable_rot_mtx = quaternion_to_matrix(self.timestep_to_optimizable_quaternion[input_pts_ts + 1]) # # self.timestep_to_optimizable_rot_mtx[input_pts_ts + 1] = cur_optimizable_rot_mtx # ''' Kinematics rigid transformations only ''' @@ -2912,8 +2912,8 @@ class BendingNetworkActiveForceFieldForwardLagV16(nn.Module): nex_pts_ts = input_pts_ts + 1 ''' Kinematics transformations from acc and torques ''' - # rigid_acc = self.time_forces(torch.zeros((1,), dtype=torch.long).cuda() + input_pts_ts).view(3) # - # torque = self.time_torques(torch.zeros((1,), dtype=torch.long).cuda() + input_pts_ts).view(3) # TODO: note that inertial_matrix^{-1} real_torque # + # rigid_acc = self.time_forces(torch.zeros((1,), dtype=torch.long) + input_pts_ts).view(3) # + # torque = self.time_torques(torch.zeros((1,), dtype=torch.long) + input_pts_ts).view(3) # TODO: note that inertial_matrix^{-1} real_torque # ''' Kinematics transformations from acc and torques ''' # friction_qd = 0.1 # # @@ -2931,7 +2931,7 @@ class BendingNetworkActiveForceFieldForwardLagV16(nn.Module): nex_sampled_input_pts = nex_sampled_input_pts[sampled_verts_idxes] - # ws_normed = torch.ones((sampled_input_pts.size(0),), dtype=torch.float32).cuda() + # ws_normed = torch.ones((sampled_input_pts.size(0),), dtype=torch.float32) # ws_normed = ws_normed / float(sampled_input_pts.size(0)) # m = Categorical(ws_normed) # nn_sampled_input_pts = 20000 @@ -2960,7 +2960,7 @@ class BendingNetworkActiveForceFieldForwardLagV16(nn.Module): # ######## vel for frictions ######### # vel_active_mesh = nex_active_mesh - cur_active_mesh ### the active mesh velocity - # friction_k = self.ks_friction_val(torch.zeros((1,)).long().cuda()).view(1) + # friction_k = self.ks_friction_val(torch.zeros((1,)).long()).view(1) # friction_force = vel_active_mesh * friction_k # forces = friction_force # ######## vel for frictions ######### @@ -2971,10 +2971,10 @@ class BendingNetworkActiveForceFieldForwardLagV16(nn.Module): # if input_pts_ts > 0: # vel_passive_mesh = self.timestep_to_vel[input_pts_ts - 1] # else: - # vel_passive_mesh = torch.zeros((3,), dtype=torch.float32).cuda() ### zeros ### + # vel_passive_mesh = torch.zeros((3,), dtype=torch.float32) ### zeros ### # vel_active_mesh = vel_active_mesh - vel_passive_mesh.unsqueeze(0) ## nn_active_pts x 3 ## --> active pts ## - # friction_k = self.ks_friction_val(torch.zeros((1,)).long().cuda()).view(1) + # friction_k = self.ks_friction_val(torch.zeros((1,)).long()).view(1) # friction_force = vel_active_mesh * friction_k # # forces = friction_force # ######## vel for frictions ######### # # maintain the contact / continuous contact -> patch contact @@ -2983,7 +2983,7 @@ class BendingNetworkActiveForceFieldForwardLagV16(nn.Module): # cur actuation # cur_actuation_embedding_st_idx = self.nn_actuators * input_pts_ts cur_actuation_embedding_ed_idx = self.nn_actuators * (input_pts_ts + 1) - cur_actuation_embedding_idxes = torch.tensor([idxx for idxx in range(cur_actuation_embedding_st_idx, cur_actuation_embedding_ed_idx)], dtype=torch.long).cuda() + cur_actuation_embedding_idxes = torch.tensor([idxx for idxx in range(cur_actuation_embedding_st_idx, cur_actuation_embedding_ed_idx)], dtype=torch.long) # ######### optimize the actuator forces directly ######### # cur_actuation_forces = self.actuator_forces(cur_actuation_embedding_idxes) # actuation embedding idxes # # forces = cur_actuation_forces @@ -2999,7 +2999,7 @@ class BendingNetworkActiveForceFieldForwardLagV16(nn.Module): ref_mano_pts_nn = reference_mano_pts.size(0) cur_actuation_embedding_st_idx = ref_mano_pts_nn * input_pts_ts cur_actuation_embedding_ed_idx = ref_mano_pts_nn * (input_pts_ts + 1) - cur_actuation_embedding_idxes = torch.tensor([idxx for idxx in range(cur_actuation_embedding_st_idx, cur_actuation_embedding_ed_idx)], dtype=torch.long).cuda() + cur_actuation_embedding_idxes = torch.tensor([idxx for idxx in range(cur_actuation_embedding_st_idx, cur_actuation_embedding_ed_idx)], dtype=torch.long) cur_actuation_friction_forces = friction_forces(cur_actuation_embedding_idxes) # nn_ref_pts x 3 # @@ -3031,22 +3031,22 @@ class BendingNetworkActiveForceFieldForwardLagV16(nn.Module): if sampled_verts_idxes is not None: cur_actuation_embedding_st_idx = ori_nns * input_pts_ts cur_actuation_embedding_ed_idx = ori_nns * (input_pts_ts + 1) - cur_actuation_embedding_idxes = torch.tensor([idxx for idxx in range(cur_actuation_embedding_st_idx, cur_actuation_embedding_ed_idx)], dtype=torch.long).cuda() + cur_actuation_embedding_idxes = torch.tensor([idxx for idxx in range(cur_actuation_embedding_st_idx, cur_actuation_embedding_ed_idx)], dtype=torch.long) cur_actuation_friction_forces = friction_forces(cur_actuation_embedding_idxes) cur_actuation_friction_forces = cur_actuation_friction_forces[sampled_verts_idxes] else: cur_actuation_embedding_st_idx = nn_sampled_input_pts * input_pts_ts cur_actuation_embedding_ed_idx = nn_sampled_input_pts * (input_pts_ts + 1) - cur_actuation_embedding_idxes = torch.tensor([idxx for idxx in range(cur_actuation_embedding_st_idx, cur_actuation_embedding_ed_idx)], dtype=torch.long).cuda() + cur_actuation_embedding_idxes = torch.tensor([idxx for idxx in range(cur_actuation_embedding_st_idx, cur_actuation_embedding_ed_idx)], dtype=torch.long) cur_actuation_friction_forces = friction_forces(cur_actuation_embedding_idxes) # nn instances # # nninstances # # if self.nn_instances == 1: - ws_alpha = self.ks_weights(torch.zeros((1,)).long().cuda()).view(1) - ws_beta = self.ks_weights(torch.ones((1,)).long().cuda()).view(1) + ws_alpha = self.ks_weights(torch.zeros((1,)).long()).view(1) + ws_beta = self.ks_weights(torch.ones((1,)).long()).view(1) else: - ws_alpha = self.ks_weights[i_instance](torch.zeros((1,)).long().cuda()).view(1) - ws_beta = self.ks_weights[i_instance](torch.ones((1,)).long().cuda()).view(1) + ws_alpha = self.ks_weights[i_instance](torch.zeros((1,)).long()).view(1) + ws_beta = self.ks_weights[i_instance](torch.ones((1,)).long()).view(1) dist_sampled_pts_to_passive_obj = torch.sum( # nn_sampled_pts x nn_passive_pts @@ -3088,7 +3088,7 @@ class BendingNetworkActiveForceFieldForwardLagV16(nn.Module): inter_obj_normals = cur_passive_obj_ns[minn_idx_sampled_pts_to_passive_obj] inter_obj_pts = cur_passive_obj_verts[minn_idx_sampled_pts_to_passive_obj] - cur_passive_obj_verts_pts_idxes = torch.arange(0, cur_passive_obj_verts.size(0), dtype=torch.long).cuda() # + cur_passive_obj_verts_pts_idxes = torch.arange(0, cur_passive_obj_verts.size(0), dtype=torch.long) # inter_passive_obj_pts_idxes = cur_passive_obj_verts_pts_idxes[minn_idx_sampled_pts_to_passive_obj] # inter_obj_normals # @@ -3103,7 +3103,7 @@ class BendingNetworkActiveForceFieldForwardLagV16(nn.Module): # penetrating_depth_penalty = penetrating_depth[penetrating_indicator].mean() # self.penetrating_depth_penalty = penetrating_depth_penalty # if torch.isnan(penetrating_depth_penalty): # get the penetration penalties # - # self.penetrating_depth_penalty = torch.tensor(0., dtype=torch.float32).cuda() + # self.penetrating_depth_penalty = torch.tensor(0., dtype=torch.float32) ###### penetration penalty strategy v1 ###### @@ -3117,9 +3117,9 @@ class BendingNetworkActiveForceFieldForwardLagV16(nn.Module): # penetrating_depth_penalty = disp_prev_to_cur[penetrating_indicator].mean() # self.penetrating_depth_penalty = penetrating_depth_penalty # if torch.isnan(penetrating_depth_penalty): - # self.penetrating_depth_penalty = torch.tensor(0., dtype=torch.float32).cuda() + # self.penetrating_depth_penalty = torch.tensor(0., dtype=torch.float32) # else: - # self.penetrating_depth_penalty = torch.tensor(0., dtype=torch.float32).cuda() + # self.penetrating_depth_penalty = torch.tensor(0., dtype=torch.float32) ###### penetration penalty strategy v2 ###### @@ -3136,9 +3136,9 @@ class BendingNetworkActiveForceFieldForwardLagV16(nn.Module): # penetrating_depth_penalty = disp_prev_to_cur[penetrating_indicator].mean() # self.penetrating_depth_penalty = penetrating_depth_penalty # else: - # # cur_rot = torch.eye(3, dtype=torch.float32).cuda() - # # cur_trans = torch.zeros((3,), dtype=torch.float32).cuda() - # self.penetrating_depth_penalty = torch.tensor(0., dtype=torch.float32).cuda() + # # cur_rot = torch.eye(3, dtype=torch.float32) + # # cur_trans = torch.zeros((3,), dtype=torch.float32) + # self.penetrating_depth_penalty = torch.tensor(0., dtype=torch.float32) ###### penetration penalty strategy v3 ###### # ws_beta; 10 # # sum over the forces but not the weighted sum... # @@ -3212,7 +3212,7 @@ class BendingNetworkActiveForceFieldForwardLagV16(nn.Module): penetration_proj_penalty = penetration_proj_ks * (-1 * torch.sum(inter_obj_pts_to_sampled_pts * inter_obj_normals.detach(), dim=-1)) self.penetrating_depth_penalty = penetration_proj_penalty[penetrating_indicator].mean() if torch.isnan(self.penetrating_depth_penalty): # get the penetration penalties # - self.penetrating_depth_penalty = torch.tensor(0., dtype=torch.float32).cuda() + self.penetrating_depth_penalty = torch.tensor(0., dtype=torch.float32) penetrating_points = sampled_input_pts[penetrating_indicator] penetration_proj_k_to_robot = 1.0 # 0.7 # penetration_proj_k_to_robot = 0.01 @@ -3263,17 +3263,17 @@ class BendingNetworkActiveForceFieldForwardLagV16(nn.Module): if self.nn_instances == 1: # spring ks values # contact ks values # # if we set a fixed k value here # - contact_spring_ka = self.spring_ks_values(torch.zeros((1,), dtype=torch.long).cuda()).view(1,) - contact_spring_kb = self.spring_ks_values(torch.zeros((1,), dtype=torch.long).cuda() + 2).view(1,) - contact_spring_kc = self.spring_ks_values(torch.zeros((1,), dtype=torch.long).cuda() + 3).view(1,) + contact_spring_ka = self.spring_ks_values(torch.zeros((1,), dtype=torch.long)).view(1,) + contact_spring_kb = self.spring_ks_values(torch.zeros((1,), dtype=torch.long) + 2).view(1,) + contact_spring_kc = self.spring_ks_values(torch.zeros((1,), dtype=torch.long) + 3).view(1,) - tangential_ks = self.spring_ks_values(torch.ones((1,), dtype=torch.long).cuda()).view(1,) + tangential_ks = self.spring_ks_values(torch.ones((1,), dtype=torch.long)).view(1,) else: - contact_spring_ka = self.spring_ks_values[i_instance](torch.zeros((1,), dtype=torch.long).cuda()).view(1,) - contact_spring_kb = self.spring_ks_values[i_instance](torch.zeros((1,), dtype=torch.long).cuda() + 2).view(1,) - contact_spring_kc = self.spring_ks_values[i_instance](torch.zeros((1,), dtype=torch.long).cuda() + 3).view(1,) + contact_spring_ka = self.spring_ks_values[i_instance](torch.zeros((1,), dtype=torch.long)).view(1,) + contact_spring_kb = self.spring_ks_values[i_instance](torch.zeros((1,), dtype=torch.long) + 2).view(1,) + contact_spring_kc = self.spring_ks_values[i_instance](torch.zeros((1,), dtype=torch.long) + 3).view(1,) - tangential_ks = self.spring_ks_values[i_instance](torch.ones((1,), dtype=torch.long).cuda()).view(1,) + tangential_ks = self.spring_ks_values[i_instance](torch.ones((1,), dtype=torch.long)).view(1,) @@ -3408,7 +3408,7 @@ class BendingNetworkActiveForceFieldForwardLagV16(nn.Module): # tangential_forces[contact_active_idxes] = penalty_based_friction_forces * 0.005 # * 1000. - contact_friction_spring_cur = self.spring_friction_ks_values(torch.zeros((1,), dtype=torch.long).cuda() + input_pts_ts).view(1,) + contact_friction_spring_cur = self.spring_friction_ks_values(torch.zeros((1,), dtype=torch.long) + input_pts_ts).view(1,) # penalty_friction_tangential_forces[contact_active_idxes][valid_penalty_friction_forces_indicator] = penalty_based_friction_forces[valid_penalty_friction_forces_indicator] * contact_spring_kb @@ -3435,7 +3435,7 @@ class BendingNetworkActiveForceFieldForwardLagV16(nn.Module): # self.valid_penalty_friction_forces_indicator = valid_penalty_friction_forces_indicator # # # print(f"here {summ_valid_penalty_friction_forces_indicator}") # # tangential_forces[self.contact_active_idxes][self.valid_penalty_friction_forces_indicator] = tangential_forces_clone[self.contact_active_idxes][self.valid_penalty_friction_forces_indicator] - # contact_active_idxes_indicators = torch.ones((tangential_forces.size(0)), dtype=torch.float).cuda().bool() + # contact_active_idxes_indicators = torch.ones((tangential_forces.size(0)), dtype=torch.float).bool() # contact_active_idxes_indicators[:] = True # contact_active_idxes_indicators[self.contact_active_idxes] = False @@ -3475,7 +3475,7 @@ class BendingNetworkActiveForceFieldForwardLagV16(nn.Module): cur_contact_frame_passive_pts = torch.matmul( cur_contact_frame_rotations.contiguous().transpose(1, 2).contiguous(), (cur_in_contact_passive_pts - cur_contact_frame_translations).contiguous().unsqueeze(-1) ).squeeze(-1) ### cur_contact_frame_active_pts ### - cur_in_contact_active_pts_all = torch.arange(0, sampled_input_pts.size(0)).long().cuda() + cur_in_contact_active_pts_all = torch.arange(0, sampled_input_pts.size(0)).long() cur_in_contact_active_pts_all = cur_in_contact_active_pts_all[in_contact_indicator] cur_inter_passive_obj_pts_idxes = inter_passive_obj_pts_idxes[in_contact_indicator] # contact_point_position, (contact_active_idxes, contact_passive_idxes), contact_frame_pose @@ -3531,7 +3531,7 @@ class BendingNetworkActiveForceFieldForwardLagV16(nn.Module): if self.use_penalty_based_friction and self.use_disp_based_friction: disp_friction_tangential_forces = nex_sampled_input_pts - sampled_input_pts - contact_friction_spring_cur = self.spring_friction_ks_values(torch.zeros((1,), dtype=torch.long).cuda() + input_pts_ts).view(1,) + contact_friction_spring_cur = self.spring_friction_ks_values(torch.zeros((1,), dtype=torch.long) + input_pts_ts).view(1,) disp_friction_tangential_forces = disp_friction_tangential_forces * contact_friction_spring_cur disp_friction_tangential_forces_dot_normals = torch.sum( @@ -3601,17 +3601,17 @@ class BendingNetworkActiveForceFieldForwardLagV16(nn.Module): if self.nn_instances == 1: - time_cons = self.time_constant(torch.zeros((1,)).long().cuda()).view(1) - time_cons_2 = self.time_constant(torch.zeros((1,)).long().cuda() + 2).view(1) - time_cons_rot = self.time_constant(torch.ones((1,)).long().cuda()).view(1) - damping_cons = self.damping_constant(torch.zeros((1,)).long().cuda()).view(1) - damping_cons_rot = self.damping_constant(torch.ones((1,)).long().cuda()).view(1) + time_cons = self.time_constant(torch.zeros((1,)).long()).view(1) + time_cons_2 = self.time_constant(torch.zeros((1,)).long() + 2).view(1) + time_cons_rot = self.time_constant(torch.ones((1,)).long()).view(1) + damping_cons = self.damping_constant(torch.zeros((1,)).long()).view(1) + damping_cons_rot = self.damping_constant(torch.ones((1,)).long()).view(1) else: - time_cons = self.time_constant[i_instance](torch.zeros((1,)).long().cuda()).view(1) - time_cons_2 = self.time_constant[i_instance](torch.zeros((1,)).long().cuda() + 2).view(1) - time_cons_rot = self.time_constant[i_instance](torch.ones((1,)).long().cuda()).view(1) - damping_cons = self.damping_constant[i_instance](torch.zeros((1,)).long().cuda()).view(1) - damping_cons_rot = self.damping_constant[i_instance](torch.ones((1,)).long().cuda()).view(1) + time_cons = self.time_constant[i_instance](torch.zeros((1,)).long()).view(1) + time_cons_2 = self.time_constant[i_instance](torch.zeros((1,)).long() + 2).view(1) + time_cons_rot = self.time_constant[i_instance](torch.ones((1,)).long()).view(1) + damping_cons = self.damping_constant[i_instance](torch.zeros((1,)).long()).view(1) + damping_cons_rot = self.damping_constant[i_instance](torch.ones((1,)).long()).view(1) k_acc_to_vel = time_cons @@ -3680,7 +3680,7 @@ class BendingNetworkActiveForceFieldForwardLagV16(nn.Module): self.timestep_to_angular_vel[input_pts_ts] = cur_angular_vel.detach() self.timestep_to_quaternion[nex_pts_ts] = cur_quaternion.detach() - # self.timestep_to_optimizable_total_def[input_pts_ts + 1] = self.time_translations(torch.zeros((1,), dtype=torch.long).cuda() + input_pts_ts).view(3) + # self.timestep_to_optimizable_total_def[input_pts_ts + 1] = self.time_translations(torch.zeros((1,), dtype=torch.long) + input_pts_ts).view(3) self.timestep_to_input_pts[input_pts_ts] = sampled_input_pts.detach() @@ -3709,8 +3709,8 @@ class BendingNetworkActiveForceFieldForwardLagV16(nn.Module): ''' Kinematics rigid transformations only ''' # timestep_to_optimizable_total_def, timestep_to_optimizable_quaternion # # - # self.timestep_to_optimizable_total_def[input_pts_ts + 1] = self.time_translations(torch.zeros((1,), dtype=torch.long).cuda() + input_pts_ts).view(3) # - # self.timestep_to_optimizable_quaternion[input_pts_ts + 1] = self.time_quaternions(torch.zeros((1,), dtype=torch.long).cuda() + input_pts_ts).view(4) # + # self.timestep_to_optimizable_total_def[input_pts_ts + 1] = self.time_translations(torch.zeros((1,), dtype=torch.long) + input_pts_ts).view(3) # + # self.timestep_to_optimizable_quaternion[input_pts_ts + 1] = self.time_quaternions(torch.zeros((1,), dtype=torch.long) + input_pts_ts).view(4) # # cur_optimizable_rot_mtx = quaternion_to_matrix(self.timestep_to_optimizable_quaternion[input_pts_ts + 1]) # # self.timestep_to_optimizable_rot_mtx[input_pts_ts + 1] = cur_optimizable_rot_mtx # ''' Kinematics rigid transformations only ''' @@ -3718,8 +3718,8 @@ class BendingNetworkActiveForceFieldForwardLagV16(nn.Module): nex_pts_ts = input_pts_ts + 1 ''' Kinematics transformations from acc and torques ''' - # rigid_acc = self.time_forces(torch.zeros((1,), dtype=torch.long).cuda() + input_pts_ts).view(3) - # torque = self.time_torques(torch.zeros((1,), dtype=torch.long).cuda() + input_pts_ts).view(3) + # rigid_acc = self.time_forces(torch.zeros((1,), dtype=torch.long) + input_pts_ts).view(3) + # torque = self.time_torques(torch.zeros((1,), dtype=torch.long) + input_pts_ts).view(3) ''' Kinematics transformations from acc and torques ''' # friction_qd = 0.1 # @@ -3736,7 +3736,7 @@ class BendingNetworkActiveForceFieldForwardLagV16(nn.Module): nex_sampled_input_pts = timestep_to_active_mesh[input_pts_ts].detach() nex_sampled_input_pts = nex_sampled_input_pts[sampled_verts_idxes] - # ws_normed = torch.ones((sampled_input_pts.size(0),), dtype=torch.float32).cuda() + # ws_normed = torch.ones((sampled_input_pts.size(0),), dtype=torch.float32) # ws_normed = ws_normed / float(sampled_input_pts.size(0)) # m = Categorical(ws_normed) # nn_sampled_input_pts = 20000 @@ -3763,7 +3763,7 @@ class BendingNetworkActiveForceFieldForwardLagV16(nn.Module): # ######## vel for frictions ######### # vel_active_mesh = nex_active_mesh - cur_active_mesh ### the active mesh velocity - # friction_k = self.ks_friction_val(torch.zeros((1,)).long().cuda()).view(1) + # friction_k = self.ks_friction_val(torch.zeros((1,)).long()).view(1) # friction_force = vel_active_mesh * friction_k # forces = friction_force # ######## vel for frictions ######### @@ -3774,10 +3774,10 @@ class BendingNetworkActiveForceFieldForwardLagV16(nn.Module): # if input_pts_ts > 0: # vel_passive_mesh = self.timestep_to_vel[input_pts_ts - 1] # else: - # vel_passive_mesh = torch.zeros((3,), dtype=torch.float32).cuda() ### zeros ### + # vel_passive_mesh = torch.zeros((3,), dtype=torch.float32) ### zeros ### # vel_active_mesh = vel_active_mesh - vel_passive_mesh.unsqueeze(0) ## nn_active_pts x 3 ## --> active pts ## - # friction_k = self.ks_friction_val(torch.zeros((1,)).long().cuda()).view(1) + # friction_k = self.ks_friction_val(torch.zeros((1,)).long()).view(1) # friction_force = vel_active_mesh * friction_k # # forces = friction_force # ######## vel for frictions ######### # # maintain the contact / continuous contact -> patch contact @@ -3786,7 +3786,7 @@ class BendingNetworkActiveForceFieldForwardLagV16(nn.Module): # cur actuation # cur_actuation_embedding_st_idx = self.nn_actuators * input_pts_ts cur_actuation_embedding_ed_idx = self.nn_actuators * (input_pts_ts + 1) - cur_actuation_embedding_idxes = torch.tensor([idxx for idxx in range(cur_actuation_embedding_st_idx, cur_actuation_embedding_ed_idx)], dtype=torch.long).cuda() + cur_actuation_embedding_idxes = torch.tensor([idxx for idxx in range(cur_actuation_embedding_st_idx, cur_actuation_embedding_ed_idx)], dtype=torch.long) # ######### optimize the actuator forces directly ######### # cur_actuation_forces = self.actuator_forces(cur_actuation_embedding_idxes) # actuation embedding idxes # # forces = cur_actuation_forces @@ -3795,11 +3795,11 @@ class BendingNetworkActiveForceFieldForwardLagV16(nn.Module): # nn instances # # nninstances # # if self.nn_instances == 1: - ws_alpha = self.ks_weights(torch.zeros((1,)).long().cuda()).view(1) - ws_beta = self.ks_weights(torch.ones((1,)).long().cuda()).view(1) + ws_alpha = self.ks_weights(torch.zeros((1,)).long()).view(1) + ws_beta = self.ks_weights(torch.ones((1,)).long()).view(1) else: - ws_alpha = self.ks_weights[i_instance](torch.zeros((1,)).long().cuda()).view(1) - ws_beta = self.ks_weights[i_instance](torch.ones((1,)).long().cuda()).view(1) + ws_alpha = self.ks_weights[i_instance](torch.zeros((1,)).long()).view(1) + ws_beta = self.ks_weights[i_instance](torch.ones((1,)).long()).view(1) if self.use_sqrt_dist: @@ -3827,7 +3827,7 @@ class BendingNetworkActiveForceFieldForwardLagV16(nn.Module): inter_obj_normals = cur_passive_obj_ns[minn_idx_sampled_pts_to_passive_obj] inter_obj_pts = cur_passive_obj_verts[minn_idx_sampled_pts_to_passive_obj] - cur_passive_obj_verts_pts_idxes = torch.arange(0, cur_passive_obj_verts.size(0), dtype=torch.long).cuda() # + cur_passive_obj_verts_pts_idxes = torch.arange(0, cur_passive_obj_verts.size(0), dtype=torch.long) # inter_passive_obj_pts_idxes = cur_passive_obj_verts_pts_idxes[minn_idx_sampled_pts_to_passive_obj] # inter_obj_normals # @@ -3841,7 +3841,7 @@ class BendingNetworkActiveForceFieldForwardLagV16(nn.Module): # penetrating_depth_penalty = penetrating_depth[penetrating_indicator].mean() # self.penetrating_depth_penalty = penetrating_depth_penalty # if torch.isnan(penetrating_depth_penalty): # get the penetration penalties # - # self.penetrating_depth_penalty = torch.tensor(0., dtype=torch.float32).cuda() + # self.penetrating_depth_penalty = torch.tensor(0., dtype=torch.float32) ###### penetration penalty strategy v1 ###### # ws_beta; 10 # # sum over the forces but not the weighted sum... # @@ -3873,7 +3873,7 @@ class BendingNetworkActiveForceFieldForwardLagV16(nn.Module): penetrating_indicator = queried_sdf < 0 else: # penetrating_indicator = torch.zeros_like(dot_inter_obj_pts_to_sampled_pts_normals).bool() - penetrating_indicator = torch.zeros((sampled_input_pts.size(0),), dtype=torch.bool).cuda().bool() + penetrating_indicator = torch.zeros((sampled_input_pts.size(0),), dtype=torch.bool).bool() # if contact_pairs_set is not None and self.use_penalty_based_friction and (not self.use_disp_based_friction): # penetrating @@ -3920,7 +3920,7 @@ class BendingNetworkActiveForceFieldForwardLagV16(nn.Module): penetration_proj_penalty = penetration_proj_ks * (-1 * torch.sum(inter_obj_pts_to_sampled_pts * cur_inter_obj_normals, dim=-1)) self.penetrating_depth_penalty = penetration_proj_penalty[penetrating_indicator].mean() if torch.isnan(self.penetrating_depth_penalty): # get the penetration penalties # - self.penetrating_depth_penalty = torch.tensor(0., dtype=torch.float32).cuda() + self.penetrating_depth_penalty = torch.tensor(0., dtype=torch.float32) penetrating_points = sampled_input_pts[penetrating_indicator] # penetration_proj_k_to_robot = 1.0 # penetration_proj_k_to_robot = 0.01 @@ -3936,20 +3936,20 @@ class BendingNetworkActiveForceFieldForwardLagV16(nn.Module): if self.nn_instances == 1: # spring ks values # contact ks values # # if we set a fixed k value here # - contact_spring_ka = self.spring_ks_values(torch.zeros((1,), dtype=torch.long).cuda()).view(1,) - contact_spring_kb = self.spring_ks_values(torch.zeros((1,), dtype=torch.long).cuda() + 2).view(1,) - contact_spring_kc = self.spring_ks_values(torch.zeros((1,), dtype=torch.long).cuda() + 3).view(1,) + contact_spring_ka = self.spring_ks_values(torch.zeros((1,), dtype=torch.long)).view(1,) + contact_spring_kb = self.spring_ks_values(torch.zeros((1,), dtype=torch.long) + 2).view(1,) + contact_spring_kc = self.spring_ks_values(torch.zeros((1,), dtype=torch.long) + 3).view(1,) - tangential_ks = self.spring_ks_values(torch.ones((1,), dtype=torch.long).cuda()).view(1,) + tangential_ks = self.spring_ks_values(torch.ones((1,), dtype=torch.long)).view(1,) else: - contact_spring_ka = self.spring_ks_values[i_instance](torch.zeros((1,), dtype=torch.long).cuda()).view(1,) - contact_spring_kb = self.spring_ks_values[i_instance](torch.zeros((1,), dtype=torch.long).cuda() + 2).view(1,) - contact_spring_kc = self.spring_ks_values[i_instance](torch.zeros((1,), dtype=torch.long).cuda() + 3).view(1,) + contact_spring_ka = self.spring_ks_values[i_instance](torch.zeros((1,), dtype=torch.long)).view(1,) + contact_spring_kb = self.spring_ks_values[i_instance](torch.zeros((1,), dtype=torch.long) + 2).view(1,) + contact_spring_kc = self.spring_ks_values[i_instance](torch.zeros((1,), dtype=torch.long) + 3).view(1,) - tangential_ks = self.spring_ks_values[i_instance](torch.ones((1,), dtype=torch.long).cuda()).view(1,) + tangential_ks = self.spring_ks_values[i_instance](torch.ones((1,), dtype=torch.long)).view(1,) - contact_spring_ka = self.spring_contact_ks_values(torch.zeros((1,), dtype=torch.long).cuda() + input_pts_ts).view(1,) + contact_spring_ka = self.spring_contact_ks_values(torch.zeros((1,), dtype=torch.long) + input_pts_ts).view(1,) ##### the contact force decided by the theshold ###### # realted to the distance threshold and the HO distance # @@ -3965,7 +3965,7 @@ class BendingNetworkActiveForceFieldForwardLagV16(nn.Module): # penalty_friction_constraint = (norm_tangential_forces - self.static_friction_mu * norm_along_normals_forces) ** 2 # penalty_friction_constraint[norm_tangential_forces <= self.static_friction_mu * norm_along_normals_forces] = 0. # penalty_friction_constraint = torch.mean(penalty_friction_constraint) - self.penalty_friction_constraint = torch.zeros((1,), dtype=torch.float32).cuda().mean() # penalty friction + self.penalty_friction_constraint = torch.zeros((1,), dtype=torch.float32).mean() # penalty friction # contact_force_d_scalar = norm_along_normals_forces.clone() contact_force_d_scalar = norm_along_normals_forces.clone() @@ -4036,7 +4036,7 @@ class BendingNetworkActiveForceFieldForwardLagV16(nn.Module): ### TODO: how to check the correctness of the switching between the static friction and the dynamic friction ### # contact friction spring cur # - contact_friction_spring_cur = self.spring_friction_ks_values(torch.zeros((1,), dtype=torch.long).cuda() + input_pts_ts).view(1,) + contact_friction_spring_cur = self.spring_friction_ks_values(torch.zeros((1,), dtype=torch.long) + input_pts_ts).view(1,) # use the relative scale of the friction force and thejcoantact force to decide the remaining contact indicator # ##### contact active penalty based friction forces -> spring_k * relative displacement ##### contact_active_penalty_based_friction_forces = penalty_based_friction_forces * contact_friction_spring_cur @@ -4139,7 +4139,7 @@ class BendingNetworkActiveForceFieldForwardLagV16(nn.Module): # self.valid_penalty_friction_forces_indicator = valid_penalty_friction_forces_indicator # # # print(f"here {summ_valid_penalty_friction_forces_indicator}") # # tangential_forces[self.contact_active_idxes][self.valid_penalty_friction_forces_indicator] = tangential_forces_clone[self.contact_active_idxes][self.valid_penalty_friction_forces_indicator] - # contact_active_idxes_indicators = torch.ones((tangential_forces.size(0)), dtype=torch.float).cuda().bool() + # contact_active_idxes_indicators = torch.ones((tangential_forces.size(0)), dtype=torch.float).bool() # contact_active_idxes_indicators[:] = True # contact_active_idxes_indicators[self.contact_active_idxes] = False @@ -4195,7 +4195,7 @@ class BendingNetworkActiveForceFieldForwardLagV16(nn.Module): cur_contact_frame_passive_pts = torch.matmul( cur_contact_frame_rotations.contiguous().transpose(1, 2).contiguous(), (cur_in_contact_passive_pts - cur_contact_frame_translations).contiguous().unsqueeze(-1) ).squeeze(-1) ### cur_contact_frame_active_pts ### - cur_in_contact_active_pts_all = torch.arange(0, sampled_input_pts.size(0)).long().cuda() + cur_in_contact_active_pts_all = torch.arange(0, sampled_input_pts.size(0)).long() cur_in_contact_active_pts_all = cur_in_contact_active_pts_all[in_contact_indicator] cur_inter_passive_obj_pts_idxes = inter_passive_obj_pts_idxes[in_contact_indicator] # contact_point_position, (contact_active_idxes, contact_passive_idxes), contact_frame_pose @@ -4230,7 +4230,7 @@ class BendingNetworkActiveForceFieldForwardLagV16(nn.Module): if self.use_penalty_based_friction and self.use_disp_based_friction: disp_friction_tangential_forces = nex_sampled_input_pts - sampled_input_pts - contact_friction_spring_cur = self.spring_friction_ks_values(torch.zeros((1,), dtype=torch.long).cuda() + input_pts_ts).view(1,) + contact_friction_spring_cur = self.spring_friction_ks_values(torch.zeros((1,), dtype=torch.long) + input_pts_ts).view(1,) disp_friction_tangential_forces = disp_friction_tangential_forces * contact_friction_spring_cur disp_friction_tangential_forces_dot_normals = torch.sum( @@ -4310,24 +4310,24 @@ class BendingNetworkActiveForceFieldForwardLagV16(nn.Module): if self.nn_instances == 1: - time_cons = self.time_constant(torch.zeros((1,)).long().cuda()).view(1) - time_cons_2 = self.time_constant(torch.zeros((1,)).long().cuda() + 2).view(1) - time_cons_rot = self.time_constant(torch.ones((1,)).long().cuda()).view(1) - damping_cons = self.damping_constant(torch.zeros((1,)).long().cuda()).view(1) - damping_cons_rot = self.damping_constant(torch.ones((1,)).long().cuda()).view(1) + time_cons = self.time_constant(torch.zeros((1,)).long()).view(1) + time_cons_2 = self.time_constant(torch.zeros((1,)).long() + 2).view(1) + time_cons_rot = self.time_constant(torch.ones((1,)).long()).view(1) + damping_cons = self.damping_constant(torch.zeros((1,)).long()).view(1) + damping_cons_rot = self.damping_constant(torch.ones((1,)).long()).view(1) else: - time_cons = self.time_constant[i_instance](torch.zeros((1,)).long().cuda()).view(1) - time_cons_2 = self.time_constant[i_instance](torch.zeros((1,)).long().cuda() + 2).view(1) - time_cons_rot = self.time_constant[i_instance](torch.ones((1,)).long().cuda()).view(1) - damping_cons = self.damping_constant[i_instance](torch.zeros((1,)).long().cuda()).view(1) - damping_cons_rot = self.damping_constant[i_instance](torch.ones((1,)).long().cuda()).view(1) + time_cons = self.time_constant[i_instance](torch.zeros((1,)).long()).view(1) + time_cons_2 = self.time_constant[i_instance](torch.zeros((1,)).long() + 2).view(1) + time_cons_rot = self.time_constant[i_instance](torch.ones((1,)).long()).view(1) + damping_cons = self.damping_constant[i_instance](torch.zeros((1,)).long()).view(1) + damping_cons_rot = self.damping_constant[i_instance](torch.ones((1,)).long()).view(1) # sep_time_constant, sep_torque_time_constant, sep_damping_constant, sep_angular_damping_constant - time_cons = self.sep_time_constant(torch.zeros((1,)).long().cuda() + input_pts_ts).view(1) - time_cons_2 = self.sep_torque_time_constant(torch.zeros((1,)).long().cuda() + input_pts_ts).view(1) - damping_cons = self.sep_damping_constant(torch.zeros((1,)).long().cuda() + input_pts_ts).view(1) - damping_cons_2 = self.sep_angular_damping_constant(torch.zeros((1,)).long().cuda() + input_pts_ts).view(1) + time_cons = self.sep_time_constant(torch.zeros((1,)).long() + input_pts_ts).view(1) + time_cons_2 = self.sep_torque_time_constant(torch.zeros((1,)).long() + input_pts_ts).view(1) + damping_cons = self.sep_damping_constant(torch.zeros((1,)).long() + input_pts_ts).view(1) + damping_cons_2 = self.sep_angular_damping_constant(torch.zeros((1,)).long() + input_pts_ts).view(1) k_acc_to_vel = time_cons @@ -4388,7 +4388,7 @@ class BendingNetworkActiveForceFieldForwardLagV16(nn.Module): self.timestep_to_angular_vel[input_pts_ts] = cur_angular_vel.detach() self.timestep_to_quaternion[nex_pts_ts] = cur_quaternion.detach() - # self.timestep_to_optimizable_total_def[input_pts_ts + 1] = self.time_translations(torch.zeros((1,), dtype=torch.long).cuda() + input_pts_ts).view(3) + # self.timestep_to_optimizable_total_def[input_pts_ts + 1] = self.time_translations(torch.zeros((1,), dtype=torch.long) + input_pts_ts).view(3) self.timestep_to_input_pts[input_pts_ts] = sampled_input_pts.detach() @@ -4475,8 +4475,8 @@ class BendingNetworkActiveForceFieldForwardLagRoboV13(nn.Module): num_embeddings=self.bending_n_timesteps, embedding_dim=self.bending_latent_size ) - # dist_k_a = self.distance_ks_val(torch.zeros((1,)).long().cuda()).view(1) - # dist_k_b = self.distance_ks_val(torch.ones((1,)).long().cuda()).view(1) * 5# *# 0.1 + # dist_k_a = self.distance_ks_val(torch.zeros((1,)).long()).view(1) + # dist_k_b = self.distance_ks_val(torch.ones((1,)).long()).view(1) * 5# *# 0.1 # distance self.distance_ks_val = nn.Embedding( @@ -4873,8 +4873,8 @@ class BendingNetworkActiveForceFieldForwardLagRoboV13(nn.Module): ''' Kinematics rigid transformations only ''' # timestep_to_optimizable_total_def, timestep_to_optimizable_quaternio - # self.timestep_to_optimizable_total_def[input_pts_ts + 1] = self.time_translations(torch.zeros((1,), dtype=torch.long).cuda() + input_pts_ts).view(3) - # self.timestep_to_optimizable_quaternion[input_pts_ts + 1] = self.time_quaternions(torch.zeros((1,), dtype=torch.long).cuda() + input_pts_ts).view(4) + # self.timestep_to_optimizable_total_def[input_pts_ts + 1] = self.time_translations(torch.zeros((1,), dtype=torch.long) + input_pts_ts).view(3) + # self.timestep_to_optimizable_quaternion[input_pts_ts + 1] = self.time_quaternions(torch.zeros((1,), dtype=torch.long) + input_pts_ts).view(4) # cur_optimizable_rot_mtx = quaternion_to_matrix(self.timestep_to_optimizable_quaternion[input_pts_ts + 1]) # self.timestep_to_optimizable_rot_mtx[input_pts_ts + 1] = cur_optimizable_rot_mtx @@ -4883,8 +4883,8 @@ class BendingNetworkActiveForceFieldForwardLagRoboV13(nn.Module): nex_pts_ts = input_pts_ts + 1 # ''' Kinematics transformations from acc and torques ''' - # rigid_acc = self.time_forces(torch.zeros((1,), dtype=torch.long).cuda() + input_pts_ts).view(3) - # torque = self.time_torques(torch.zeros((1,), dtype=torch.long).cuda() + input_pts_ts).view(3) # TODO: note that inertial_matrix^{-1} real_torque # + # rigid_acc = self.time_forces(torch.zeros((1,), dtype=torch.long) + input_pts_ts).view(3) + # torque = self.time_torques(torch.zeros((1,), dtype=torch.long) + input_pts_ts).view(3) # TODO: note that inertial_matrix^{-1} real_torque # ''' Kinematics transformations from acc and torques ''' @@ -4894,7 +4894,7 @@ class BendingNetworkActiveForceFieldForwardLagRoboV13(nn.Module): sampled_input_pts = timestep_to_active_mesh[input_pts_ts] # sampled points --> - ws_normed = torch.ones((sampled_input_pts.size(0),), dtype=torch.float32).cuda() + ws_normed = torch.ones((sampled_input_pts.size(0),), dtype=torch.float32) ws_normed = ws_normed / float(sampled_input_pts.size(0)) m = Categorical(ws_normed) nn_sampled_input_pts = 5000 @@ -4924,7 +4924,7 @@ class BendingNetworkActiveForceFieldForwardLagRoboV13(nn.Module): # ######## vel for frictions ######### # vel_active_mesh = nex_active_mesh - cur_active_mesh # the active mesh velocity - # friction_k = self.ks_friction_val(torch.zeros((1,)).long().cuda()).view(1) + # friction_k = self.ks_friction_val(torch.zeros((1,)).long()).view(1) # friction_force = vel_active_mesh * friction_k # forces = friction_force # ######## vel for frictions ######### @@ -4935,10 +4935,10 @@ class BendingNetworkActiveForceFieldForwardLagRoboV13(nn.Module): # if input_pts_ts > 0: # vel_passive_mesh = self.timestep_to_vel[input_pts_ts - 1] # else: - # vel_passive_mesh = torch.zeros((3,), dtype=torch.float32).cuda() ### zeros ### + # vel_passive_mesh = torch.zeros((3,), dtype=torch.float32) ### zeros ### # vel_active_mesh = vel_active_mesh - vel_passive_mesh.unsqueeze(0) ## nn_active_pts x 3 ## --> active pts ## - # friction_k = self.ks_friction_val(torch.zeros((1,)).long().cuda()).view(1) + # friction_k = self.ks_friction_val(torch.zeros((1,)).long()).view(1) # friction_force = vel_active_mesh * friction_k # forces = friction_force # ######## vel for frictions ######### @@ -4947,7 +4947,7 @@ class BendingNetworkActiveForceFieldForwardLagRoboV13(nn.Module): # cur actuation # embedding st idx # cur_actuation_embedding_st_idx = self.nn_actuators * input_pts_ts cur_actuation_embedding_ed_idx = self.nn_actuators * (input_pts_ts + 1) - cur_actuation_embedding_idxes = torch.tensor([idxx for idxx in range(cur_actuation_embedding_st_idx, cur_actuation_embedding_ed_idx)], dtype=torch.long).cuda() + cur_actuation_embedding_idxes = torch.tensor([idxx for idxx in range(cur_actuation_embedding_st_idx, cur_actuation_embedding_ed_idx)], dtype=torch.long) # ######### optimize the actuator forces directly ######### # cur_actuation_forces = self.actuator_forces(cur_actuation_embedding_idxes) # forces = cur_actuation_forces @@ -4959,13 +4959,13 @@ class BendingNetworkActiveForceFieldForwardLagRoboV13(nn.Module): else: cur_actuation_embedding_st_idx = 365428 * input_pts_ts cur_actuation_embedding_ed_idx = 365428 * (input_pts_ts + 1) - cur_actuation_embedding_idxes = torch.tensor([idxx for idxx in range(cur_actuation_embedding_st_idx, cur_actuation_embedding_ed_idx)], dtype=torch.long).cuda() + cur_actuation_embedding_idxes = torch.tensor([idxx for idxx in range(cur_actuation_embedding_st_idx, cur_actuation_embedding_ed_idx)], dtype=torch.long) cur_actuation_friction_forces = friction_forces(cur_actuation_embedding_idxes) cur_actuation_friction_forces = cur_actuation_friction_forces[sampled_input_pts_idx] ## sample ## - ws_alpha = self.ks_weights(torch.zeros((1,)).long().cuda()).view(1) - ws_beta = self.ks_weights(torch.ones((1,)).long().cuda()).view(1) + ws_alpha = self.ks_weights(torch.zeros((1,)).long()).view(1) + ws_beta = self.ks_weights(torch.ones((1,)).long()).view(1) dist_sampled_pts_to_passive_obj = torch.sum( # nn_sampled_pts x nn_passive_pts (sampled_input_pts.unsqueeze(1) - cur_passive_obj_verts.unsqueeze(0)) ** 2, dim=-1 @@ -5005,14 +5005,14 @@ class BendingNetworkActiveForceFieldForwardLagRoboV13(nn.Module): dot_rel_inter_obj_pts_normals = torch.sum(rel_inter_obj_pts_to_sampled_pts * inter_obj_normals, dim=-1) ## nn_sampled_pts dist_sampled_pts_to_passive_obj[dot_rel_inter_obj_pts_normals < 0] = -1. * dist_sampled_pts_to_passive_obj[dot_rel_inter_obj_pts_normals < 0] # contact_spring_ka * | minn_spring_length - dist_sampled_pts_to_passive_obj | - contact_spring_ka = self.spring_ks_values(torch.zeros((1,), dtype=torch.long).cuda()).view(1,) - contact_spring_kb = self.spring_ks_values(torch.zeros((1,), dtype=torch.long).cuda() + 2).view(1,) - contact_spring_kc = self.spring_ks_values(torch.zeros((1,), dtype=torch.long).cuda() + 3).view(1,) + contact_spring_ka = self.spring_ks_values(torch.zeros((1,), dtype=torch.long)).view(1,) + contact_spring_kb = self.spring_ks_values(torch.zeros((1,), dtype=torch.long) + 2).view(1,) + contact_spring_kc = self.spring_ks_values(torch.zeros((1,), dtype=torch.long) + 3).view(1,) # contact_force_d = -contact_spring_ka * (dist_sampled_pts_to_passive_obj - self.contact_spring_rest_length) # contact_force_d = contact_spring_ka * (self.contact_spring_rest_length - dist_sampled_pts_to_passive_obj) # + contact_spring_kb * (self.contact_spring_rest_length - dist_sampled_pts_to_passive_obj) ** 2 + contact_spring_kc * (self.contact_spring_rest_length - dist_sampled_pts_to_passive_obj) ** 3 # vel_sampled_pts = nex_active_mesh - cur_active_mesh - tangential_ks = self.spring_ks_values(torch.ones((1,), dtype=torch.long).cuda()).view(1,) + tangential_ks = self.spring_ks_values(torch.ones((1,), dtype=torch.long)).view(1,) ###### Get the tangential forces via optimizable forces ###### cur_actuation_friction_forces_along_normals = torch.sum(cur_actuation_friction_forces * inter_obj_normals, dim=-1).unsqueeze(-1) * inter_obj_normals @@ -5093,11 +5093,11 @@ class BendingNetworkActiveForceFieldForwardLagRoboV13(nn.Module): - time_cons = self.time_constant(torch.zeros((1,)).long().cuda()).view(1) - time_cons_2 = self.time_constant(torch.zeros((1,)).long().cuda() + 2).view(1) - time_cons_rot = self.time_constant(torch.ones((1,)).long().cuda()).view(1) - damping_cons = self.damping_constant(torch.zeros((1,)).long().cuda()).view(1) - damping_cons_rot = self.damping_constant(torch.ones((1,)).long().cuda()).view(1) + time_cons = self.time_constant(torch.zeros((1,)).long()).view(1) + time_cons_2 = self.time_constant(torch.zeros((1,)).long() + 2).view(1) + time_cons_rot = self.time_constant(torch.ones((1,)).long()).view(1) + damping_cons = self.damping_constant(torch.zeros((1,)).long()).view(1) + damping_cons_rot = self.damping_constant(torch.ones((1,)).long()).view(1) k_acc_to_vel = time_cons k_vel_to_offset = time_cons_2 delta_vel = rigid_acc * k_acc_to_vel @@ -5161,7 +5161,7 @@ class BendingNetworkActiveForceFieldForwardLagRoboV13(nn.Module): self.timestep_to_angular_vel[input_pts_ts] = cur_angular_vel.detach() self.timestep_to_quaternion[nex_pts_ts] = cur_quaternion.detach() - # self.timestep_to_optimizable_total_def[input_pts_ts + 1] = self.time_translations(torch.zeros((1,), dtype=torch.long).cuda() + input_pts_ts).view(3) + # self.timestep_to_optimizable_total_def[input_pts_ts + 1] = self.time_translations(torch.zeros((1,), dtype=torch.long) + input_pts_ts).view(3) self.timestep_to_input_pts[input_pts_ts] = sampled_input_pts.detach() @@ -5234,7 +5234,7 @@ class BendingNetworkActiveForceFieldForwardLagV14(nn.Module): self.nn_uniformly_sampled_pts = 50000 self.gravity_acc = 9.8 - self.gravity_dir = torch.tensor([0., 0., -1]).float().cuda() + self.gravity_dir = torch.tensor([0., 0., -1]).float() self.passive_obj_mass = 1. self.passive_obj_inertia = ... self.passive_obj_inertia_inv = ... @@ -5260,8 +5260,8 @@ class BendingNetworkActiveForceFieldForwardLagV14(nn.Module): num_embeddings=self.bending_n_timesteps, embedding_dim=self.bending_latent_size ) - # dist_k_a = self.distance_ks_val(torch.zeros((1,)).long().cuda()).view(1) - # dist_k_b = self.distance_ks_val(torch.ones((1,)).long().cuda()).view(1) * 5# *# 0.1 + # dist_k_a = self.distance_ks_val(torch.zeros((1,)).long()).view(1) + # dist_k_b = self.distance_ks_val(torch.ones((1,)).long()).view(1) * 5# *# 0.1 # distance self.distance_ks_val = nn.Embedding( @@ -5660,8 +5660,8 @@ class BendingNetworkActiveForceFieldForwardLagV14(nn.Module): ''' Kinematics rigid transformations only ''' # timestep_to_optimizable_total_def, timestep_to_optimizable_quaternio - # self.timestep_to_optimizable_total_def[input_pts_ts + 1] = self.time_translations(torch.zeros((1,), dtype=torch.long).cuda() + input_pts_ts).view(3) - # self.timestep_to_optimizable_quaternion[input_pts_ts + 1] = self.time_quaternions(torch.zeros((1,), dtype=torch.long).cuda() + input_pts_ts).view(4) + # self.timestep_to_optimizable_total_def[input_pts_ts + 1] = self.time_translations(torch.zeros((1,), dtype=torch.long) + input_pts_ts).view(3) + # self.timestep_to_optimizable_quaternion[input_pts_ts + 1] = self.time_quaternions(torch.zeros((1,), dtype=torch.long) + input_pts_ts).view(4) # cur_optimizable_rot_mtx = quaternion_to_matrix(self.timestep_to_optimizable_quaternion[input_pts_ts + 1]) # self.timestep_to_optimizable_rot_mtx[input_pts_ts + 1] = cur_optimizable_rot_mtx @@ -5670,8 +5670,8 @@ class BendingNetworkActiveForceFieldForwardLagV14(nn.Module): nex_pts_ts = input_pts_ts + 1 # ''' Kinematics transformations from acc and torques ''' - # rigid_acc = self.time_forces(torch.zeros((1,), dtype=torch.long).cuda() + input_pts_ts).view(3) - # torque = self.time_torques(torch.zeros((1,), dtype=torch.long).cuda() + input_pts_ts).view(3) # TODO: note that inertial_matrix^{-1} real_torque # + # rigid_acc = self.time_forces(torch.zeros((1,), dtype=torch.long) + input_pts_ts).view(3) + # torque = self.time_torques(torch.zeros((1,), dtype=torch.long) + input_pts_ts).view(3) # TODO: note that inertial_matrix^{-1} real_torque # ''' Kinematics transformations from acc and torques ''' @@ -5696,7 +5696,7 @@ class BendingNetworkActiveForceFieldForwardLagV14(nn.Module): # ######## vel for frictions ######### # vel_active_mesh = nex_active_mesh - cur_active_mesh # the active mesh velocity - # friction_k = self.ks_friction_val(torch.zeros((1,)).long().cuda()).view(1) + # friction_k = self.ks_friction_val(torch.zeros((1,)).long()).view(1) # friction_force = vel_active_mesh * friction_k # forces = friction_force # ######## vel for frictions ######### @@ -5707,10 +5707,10 @@ class BendingNetworkActiveForceFieldForwardLagV14(nn.Module): # if input_pts_ts > 0: # vel_passive_mesh = self.timestep_to_vel[input_pts_ts - 1] # else: - # vel_passive_mesh = torch.zeros((3,), dtype=torch.float32).cuda() ### zeros ### + # vel_passive_mesh = torch.zeros((3,), dtype=torch.float32) ### zeros ### # vel_active_mesh = vel_active_mesh - vel_passive_mesh.unsqueeze(0) ## nn_active_pts x 3 ## --> active pts ## - # friction_k = self.ks_friction_val(torch.zeros((1,)).long().cuda()).view(1) + # friction_k = self.ks_friction_val(torch.zeros((1,)).long()).view(1) # friction_force = vel_active_mesh * friction_k # forces = friction_force # ######## vel for frictions ######### @@ -5719,7 +5719,7 @@ class BendingNetworkActiveForceFieldForwardLagV14(nn.Module): cur_actuation_embedding_st_idx = self.nn_actuators * input_pts_ts cur_actuation_embedding_ed_idx = self.nn_actuators * (input_pts_ts + 1) - cur_actuation_embedding_idxes = torch.tensor([idxx for idxx in range(cur_actuation_embedding_st_idx, cur_actuation_embedding_ed_idx)], dtype=torch.long).cuda() + cur_actuation_embedding_idxes = torch.tensor([idxx for idxx in range(cur_actuation_embedding_st_idx, cur_actuation_embedding_ed_idx)], dtype=torch.long) # ######### optimize the actuator forces directly ######### # cur_actuation_forces = self.actuator_forces(cur_actuation_embedding_idxes) # forces = cur_actuation_forces @@ -5730,8 +5730,8 @@ class BendingNetworkActiveForceFieldForwardLagV14(nn.Module): cur_actuation_friction_forces = self.actuator_friction_forces(cur_actuation_embedding_idxes) - ws_alpha = self.ks_weights(torch.zeros((1,)).long().cuda()).view(1) - ws_beta = self.ks_weights(torch.ones((1,)).long().cuda()).view(1) + ws_alpha = self.ks_weights(torch.zeros((1,)).long()).view(1) + ws_beta = self.ks_weights(torch.ones((1,)).long()).view(1) dist_sampled_pts_to_passive_obj = torch.sum( # nn_sampled_pts x nn_passive_pts (sampled_input_pts.unsqueeze(1) - cur_passive_obj_verts.unsqueeze(0)) ** 2, dim=-1 @@ -5770,10 +5770,10 @@ class BendingNetworkActiveForceFieldForwardLagV14(nn.Module): dot_rel_inter_obj_pts_normals = torch.sum(rel_inter_obj_pts_to_sampled_pts * inter_obj_normals, dim=-1) ## nn_sampled_pts dist_sampled_pts_to_passive_obj[dot_rel_inter_obj_pts_normals < 0] = -1. * dist_sampled_pts_to_passive_obj[dot_rel_inter_obj_pts_normals < 0] # contact_spring_ka * | minn_spring_length - dist_sampled_pts_to_passive_obj | - contact_spring_ka = self.spring_ks_values(torch.zeros((1,), dtype=torch.long).cuda()).view(1,) + contact_spring_ka = self.spring_ks_values(torch.zeros((1,), dtype=torch.long)).view(1,) contact_force_d = -contact_spring_ka * (dist_sampled_pts_to_passive_obj - self.contact_spring_rest_length) # vel_sampled_pts = nex_active_mesh - cur_active_mesh - tangential_ks = self.spring_ks_values(torch.ones((1,), dtype=torch.long).cuda()).view(1,) + tangential_ks = self.spring_ks_values(torch.ones((1,), dtype=torch.long)).view(1,) ###### Get the tangential forces via optimizable forces ###### cur_actuation_friction_forces_along_normals = torch.sum(cur_actuation_friction_forces * inter_obj_normals, dim=-1).unsqueeze(-1) * inter_obj_normals @@ -5848,11 +5848,11 @@ class BendingNetworkActiveForceFieldForwardLagV14(nn.Module): torque = torch.matmul(cur_inertia_inv, torque.unsqueeze(-1)).squeeze(-1) ### torque # ## # torque # - time_cons = self.time_constant(torch.zeros((1,)).long().cuda()).view(1) - time_cons_2 = self.time_constant(torch.zeros((1,)).long().cuda() + 2).view(1) - time_cons_rot = self.time_constant(torch.ones((1,)).long().cuda()).view(1) - damping_cons = self.damping_constant(torch.zeros((1,)).long().cuda()).view(1) - damping_cons_rot = self.damping_constant(torch.ones((1,)).long().cuda()).view(1) + time_cons = self.time_constant(torch.zeros((1,)).long()).view(1) + time_cons_2 = self.time_constant(torch.zeros((1,)).long() + 2).view(1) + time_cons_rot = self.time_constant(torch.ones((1,)).long()).view(1) + damping_cons = self.damping_constant(torch.zeros((1,)).long()).view(1) + damping_cons_rot = self.damping_constant(torch.ones((1,)).long()).view(1) k_acc_to_vel = time_cons k_vel_to_offset = time_cons_2 delta_vel = rigid_acc * k_acc_to_vel @@ -5916,7 +5916,7 @@ class BendingNetworkActiveForceFieldForwardLagV14(nn.Module): self.timestep_to_angular_vel[input_pts_ts] = cur_angular_vel.detach() self.timestep_to_quaternion[nex_pts_ts] = cur_quaternion.detach() - # self.timestep_to_optimizable_total_def[input_pts_ts + 1] = self.time_translations(torch.zeros((1,), dtype=torch.long).cuda() + input_pts_ts).view(3) + # self.timestep_to_optimizable_total_def[input_pts_ts + 1] = self.time_translations(torch.zeros((1,), dtype=torch.long) + input_pts_ts).view(3) self.timestep_to_input_pts[input_pts_ts] = sampled_input_pts.detach() @@ -5954,8 +5954,8 @@ class BendingNetworkActiveForceFieldForwardLagV14(nn.Module): ''' Calculate weights for deformed input points ''' # ws_normed, defed_input_pts_sdf, # # prev_passive_mesh = timestep_to_passive_mesh[prev_pts_ts] - # ws_alpha = self.ks_weights(torch.zeros((1,)).long().cuda()).view(1).detach() - # ws_beta = self.ks_weights(torch.ones((1,)).long().cuda()).view(1).detach() + # ws_alpha = self.ks_weights(torch.zeros((1,)).long()).view(1).detach() + # ws_beta = self.ks_weights(torch.ones((1,)).long()).view(1).detach() # ws_unnormed = ws_beta * torch.exp(-1. * defed_input_pts_sdf.detach() * ws_alpha) # # ws_normed = ws_unnormed / torch.clamp(torch.sum(ws_unnormed), min=1e-9) ## ws_normed ## ''' Calculate weights for deformed input points ''' @@ -5967,10 +5967,10 @@ class BendingNetworkActiveForceFieldForwardLagV14(nn.Module): #### uniformly_sampled_pts: nn_sampled_pts x 3 #### uniformly_sampled_pts = uniformly_dist.sample(sample_shape=(nn_uniformly_sampled_pts, 3)) # use weighting_network to get weights of those sampled pts # - # expanded_prev_pts_ts = torch.zeros((uniformly_sampled_pts.size(0)), dtype=torch.long).cuda() + # expanded_prev_pts_ts = torch.zeros((uniformly_sampled_pts.size(0)), dtype=torch.long) # expanded_prev_pts_ts = expanded_prev_pts_ts + prev_pts_ts # (nn_pts,) # if we do not have a kinematics observation? # - expanded_pts_ts = torch.zeros((uniformly_sampled_pts.size(0)), dtype=torch.long).cuda() ### get + expanded_pts_ts = torch.zeros((uniformly_sampled_pts.size(0)), dtype=torch.long) ### get expanded_pts_ts = expanded_pts_ts + input_pts_ts input_latents = self.bending_latent(expanded_pts_ts) x = torch.cat([uniformly_sampled_pts, input_latents], dim=-1) @@ -6018,8 +6018,8 @@ class BendingNetworkActiveForceFieldForwardLagV14(nn.Module): cur_passive_obj_verts = torch.matmul(init_passive_obj_verts, cur_rot_mtx) + cur_passive_trans.unsqueeze(0) ## nn_pts x 3 ## passive_center_point = cur_passive_obj_verts.mean(0) - # ws_alpha = self.ks_weights(torch.zeros((1,)).long().cuda()).view(1).detach() - # ws_beta = self.ks_weights(torch.ones((1,)).long().cuda()).view(1).detach() + # ws_alpha = self.ks_weights(torch.zeros((1,)).long()).view(1).detach() + # ws_beta = self.ks_weights(torch.ones((1,)).long()).view(1).detach() # ws_unnormed = ws_beta * torch.exp(-1. * defed_uniformly_sampled_pts_sdf.detach() * ws_alpha * 100) # nn_pts # # ws_normed = ws_unnormed / torch.clamp(torch.sum(ws_unnormed), min=1e-9) ## ws_normed ## m = Categorical(ws_normed) @@ -6117,8 +6117,8 @@ class BendingNetworkActiveForceFieldForwardLagV14(nn.Module): dist_input_pts_active_mesh = torch.sqrt(dist_input_pts_active_mesh) # nn_sampled_pts x nn_active_pts # topk_dist_input_pts_active_mesh, topk_dist_input_pts_active_mesh_idx = torch.topk(dist_input_pts_active_mesh, k=self.nn_patch_active_pts, largest=False, dim=-1) thres_dist, _ = torch.max(topk_dist_input_pts_active_mesh, dim=-1) - weighting_ka = self.weighting_model_ks(torch.zeros((1,)).long().cuda()).view(1) # - weighting_kb = self.weighting_model_ks(torch.ones((1,)).long().cuda()).view(1) # + weighting_ka = self.weighting_model_ks(torch.zeros((1,)).long()).view(1) # + weighting_kb = self.weighting_model_ks(torch.ones((1,)).long()).view(1) # unnormed_weight_active_pts_to_input_pts = weighting_ka * torch.exp(-1. * dist_input_pts_active_mesh * weighting_kb * 50) # unnormed_weight_active_pts_to_input_pts[unnormed_weight_active_pts_to_input_pts > thres_dist.unsqueeze(-1) + 1e-6] = 0. @@ -6154,8 +6154,8 @@ class BendingNetworkActiveForceFieldForwardLagV14(nn.Module): # dist_input_pts_active_mesh_ori = torch.sqrt(dist_input_pts_active_mesh_ori) # nn_sampled_pts x nn_active_pts # # topk_dist_input_pts_active_mesh_ori, topk_dist_input_pts_active_mesh_idx_ori = torch.topk(dist_input_pts_active_mesh_ori, k=500, largest=False, dim=-1) # thres_dist_ori, _ = torch.max(topk_dist_input_pts_active_mesh_ori, dim=-1) - # weighting_ka_ori = self.weighting_model_ks(torch.zeros((1,)).long().cuda()).view(1) - # weighting_kb_ori = self.weighting_model_ks(torch.ones((1,)).long().cuda()).view(1) # weighting_kb # + # weighting_ka_ori = self.weighting_model_ks(torch.zeros((1,)).long()).view(1) + # weighting_kb_ori = self.weighting_model_ks(torch.ones((1,)).long()).view(1) # weighting_kb # # unnormed_weight_active_pts_to_input_pts_ori = weighting_ka_ori * torch.exp(-1. * dist_input_pts_active_mesh_ori * weighting_kb_ori * 50) # # unnormed_weight_active_pts_to_input_pts_ori[unnormed_weight_active_pts_to_input_pts_ori >= thres_dist_ori.unsqueeze(-1)] = 0. @@ -6182,7 +6182,7 @@ class BendingNetworkActiveForceFieldForwardLagV14(nn.Module): ''' spring force v2: use the spring force as input ''' ### determine the spring coefficient ### - spring_qd = self.spring_qd(torch.zeros((1,)).long().cuda()).view(1) + spring_qd = self.spring_qd(torch.zeros((1,)).long()).view(1) # spring_qd = 1. # fix the qd to 1 # spring_qd # # spring_qd # spring_qd = 0.5 # dist input pts to active mesh # # @@ -6196,8 +6196,8 @@ class BendingNetworkActiveForceFieldForwardLagV14(nn.Module): # wish to use simple functions to achieve the adjustmenet of k-d relations # # k-d relations # # print(f"spring_qd: {spring_qd.size()}, dist_input_pts_active_mesh: {dist_input_pts_active_mesh.size()}, spring_kd: {spring_kd.size()}") # - time_cons = self.time_constant(torch.zeros((1,)).long().cuda()).view(1) # tiem_constant - spring_k_val = self.ks_val(torch.zeros((1,)).long().cuda()).view(1) + time_cons = self.time_constant(torch.zeros((1,)).long()).view(1) # tiem_constant + spring_k_val = self.ks_val(torch.zeros((1,)).long()).view(1) spring_kd = spring_kd * time_cons ### get the spring_kd (nn_sampled_pts x nn_act_pts ) #### spring_force = -1. * spring_kd * (dist_input_pts_active_mesh - self.spring_rest_length) # nn_sampled_pts x nn-active_pts @@ -6284,7 +6284,7 @@ class BendingNetworkActiveForceFieldForwardLagV14(nn.Module): friction_kd = friction_kd * time_cons prev_prev_active_mesh_vel_norm = torch.norm(cur_active_mesh_vel, dim=-1) friction_force = friction_kd * (self.spring_rest_length - dist_input_pts_active_mesh_sel) * prev_prev_active_mesh_vel_norm # | vel | * (dist - rest_length) * friction_kd # - friction_k = self.ks_friction_val(torch.zeros((1,)).long().cuda()).view(1) + friction_k = self.ks_friction_val(torch.zeros((1,)).long()).view(1) # friction_force = batched_index_select(values=friction_force, indices=sampled_input_pts_idx, dim=1) # dir_friction_force = cur_active_mesh_vel dir_friction_force = dir_friction_force / torch.clamp(torch.norm(dir_friction_force, dim=-1, keepdim=True, p=2), min=1e-9) # @@ -6306,8 +6306,8 @@ class BendingNetworkActiveForceFieldForwardLagV14(nn.Module): ###### [time_cons] is used when calculating buth the spring force and the frictional force ---> convert force to acc ###### - ws_alpha = self.ks_weights(torch.zeros((1,)).long().cuda()).view(1) - ws_beta = self.ks_weights(torch.ones((1,)).long().cuda()).view(1) + ws_alpha = self.ks_weights(torch.zeros((1,)).long()).view(1) + ws_beta = self.ks_weights(torch.ones((1,)).long()).view(1) dist_sampled_pts_to_passive_obj = torch.sum( # nn_sampled_pts x nn_passive_pts (sampled_input_pts.unsqueeze(1) - cur_passive_obj_verts.unsqueeze(0)) ** 2, dim=-1 @@ -6323,8 +6323,8 @@ class BendingNetworkActiveForceFieldForwardLagV14(nn.Module): ''' get velocity and offset related constants ''' - # k_acc_to_vel = self.ks_val(torch.zeros((1,)).long().cuda()).view(1) # - # k_vel_to_offset = self.ks_val(torch.ones((1,)).long().cuda()).view(1) # + # k_acc_to_vel = self.ks_val(torch.zeros((1,)).long()).view(1) # + # k_vel_to_offset = self.ks_val(torch.ones((1,)).long()).view(1) # ''' get velocity and offset related constants ''' k_acc_to_vel = time_cons k_vel_to_offset = time_cons @@ -6521,8 +6521,8 @@ class BendingNetworkActiveForceFieldForwardLagEuV13(nn.Module): ) torch.nn.init.ones_(self.ks_weight_d.weight) # ks_weight_d # as the weights # - # dist_k_a = self.distance_ks_val(torch.zeros((1,)).long().cuda()).view(1) - # dist_k_b = self.distance_ks_val(torch.ones((1,)).long().cuda()).view(1) * 5# *# 0.1 + # dist_k_a = self.distance_ks_val(torch.zeros((1,)).long()).view(1) + # dist_k_b = self.distance_ks_val(torch.ones((1,)).long()).view(1) * 5# *# 0.1 # the level 1 distnace threshold # # use bending_latent to get the timelabel latnets # self.distance_threshold = 1.0 @@ -6841,9 +6841,9 @@ class BendingNetworkActiveForceFieldForwardLagEuV13(nn.Module): def construct_grid_points(self, ): bound_min = [-1, -1, -1] bound_max = [1, 1, 1] - X = torch.linspace(bound_min[0], bound_max[0], self.res).cuda() - Y = torch.linspace(bound_min[1], bound_max[1], self.res).cuda() # .split(N) - Z = torch.linspace(bound_min[2], bound_max[2], self.res).cuda() # .split(N) + X = torch.linspace(bound_min[0], bound_max[0], self.res) + Y = torch.linspace(bound_min[1], bound_max[1], self.res) # .split(N) + Z = torch.linspace(bound_min[2], bound_max[2], self.res) # .split(N) xx, yy, zz = torch.meshgrid(X, Y, Z) pts = torch.cat([xx.reshape(-1, 1), yy.reshape(-1, 1), zz.reshape(-1, 1)], dim=-1) self.grid_pts = pts @@ -7004,8 +7004,8 @@ class BendingNetworkActiveForceFieldForwardLagEuV13(nn.Module): ''' Kinematics rigid transformations only ''' # with a good initialization and the kinematics tracking result? # # timestep_to_optimizable_total_def, timestep_to_optimizable_quaternio - # self.timestep_to_optimizable_total_def[input_pts_ts + 1] = self.time_translations(torch.zeros((1,), dtype=torch.long).cuda() + input_pts_ts).view(3) - # self.timestep_to_optimizable_quaternion[input_pts_ts + 1] = self.time_quaternions(torch.zeros((1,), dtype=torch.long).cuda() + input_pts_ts).view(4) + # self.timestep_to_optimizable_total_def[input_pts_ts + 1] = self.time_translations(torch.zeros((1,), dtype=torch.long) + input_pts_ts).view(3) + # self.timestep_to_optimizable_quaternion[input_pts_ts + 1] = self.time_quaternions(torch.zeros((1,), dtype=torch.long) + input_pts_ts).view(4) # cur_optimizable_rot_mtx = quaternion_to_matrix(self.timestep_to_optimizable_quaternion[input_pts_ts + 1]) # self.timestep_to_optimizable_rot_mtx[input_pts_ts + 1] = cur_optimizable_rot_mtx @@ -7014,8 +7014,8 @@ class BendingNetworkActiveForceFieldForwardLagEuV13(nn.Module): nex_pts_ts = input_pts_ts + 1 # define correspondences # ''' Kinematics transformations from acc and torques ''' - # rigid_acc = self.time_forces(torch.zeros((1,), dtype=torch.long).cuda() + input_pts_ts).view(3) - # torque = self.time_torques(torch.zeros((1,), dtype=torch.long).cuda() + input_pts_ts).view(3) # TODO: note that inertial_matrix^{-1} real_torque # + # rigid_acc = self.time_forces(torch.zeros((1,), dtype=torch.long) + input_pts_ts).view(3) + # torque = self.time_torques(torch.zeros((1,), dtype=torch.long) + input_pts_ts).view(3) # TODO: note that inertial_matrix^{-1} real_torque # ''' Kinematics transformations from acc and torques ''' # friction_qd = 0.1 @@ -7029,7 +7029,7 @@ class BendingNetworkActiveForceFieldForwardLagEuV13(nn.Module): # self.grid_pts # - # ws_normed = torch.ones((sampled_input_pts.size(0),), dtype=torch.float32).cuda() + # ws_normed = torch.ones((sampled_input_pts.size(0),), dtype=torch.float32) # ws_normed = ws_normed / float(sampled_input_pts.size(0)) # m = Categorical(ws_normed) # nn_sampled_input_pts = 20000 @@ -7083,15 +7083,15 @@ class BendingNetworkActiveForceFieldForwardLagEuV13(nn.Module): # idx_pts_near_to_obj -> selector # - contact_ka = self.ks_contact_d(torch.zeros((1,)).long().cuda()).view(1) - contact_kb = self.ks_contact_d(torch.ones((1,)).long().cuda()).view(1) + contact_ka = self.ks_contact_d(torch.zeros((1,)).long()).view(1) + contact_kb = self.ks_contact_d(torch.ones((1,)).long()).view(1) pts_contact_d = contact_ka * (self.spring_rest_length - dist_pts_to_obj) # * 0.02 pts_contact_d = torch.softmax(pts_contact_d, dim=0) # nn_sampled_pts pts_contact_d = contact_kb * pts_contact_d pts_contact_force = -1 * pts_normals * pts_contact_d.unsqueeze(-1) - time_latents_emb_idxes = torch.zeros((sampled_input_pts.size(0), ), dtype=torch.long).cuda() + input_pts_ts + time_latents_emb_idxes = torch.zeros((sampled_input_pts.size(0), ), dtype=torch.long) + input_pts_ts time_latents = self.bending_latent(time_latents_emb_idxes) friction_latents_in = torch.cat( [sampled_input_pts, time_latents], dim=-1 @@ -7118,8 +7118,8 @@ class BendingNetworkActiveForceFieldForwardLagEuV13(nn.Module): (sampled_input_pts.unsqueeze(1) - cur_active_mesh.unsqueeze(0)) ** 2, dim=-1 ) dist_pts_to_active, minn_idx_pts_to_active = torch.min(dist_pts_to_active, dim=-1) - weight_da = self.ks_weight_d(torch.zeros((1,)).long().cuda()).view(1) - weight_db = self.ks_weight_d(torch.ones((1,)).long().cuda()).view(1) + weight_da = self.ks_weight_d(torch.zeros((1,)).long()).view(1) + weight_db = self.ks_weight_d(torch.ones((1,)).long()).view(1) # weight = weight_da * (self.spring_rest_length - dist_pts_to_active) weight = weight_da * (self.spring_rest_length_active - dist_pts_to_active) @@ -7133,7 +7133,7 @@ class BendingNetworkActiveForceFieldForwardLagEuV13(nn.Module): # ######## vel for frictions ######### # vel_active_mesh = nex_active_mesh - cur_active_mesh # the active mesh velocity - # friction_k = self.ks_friction_val(torch.zeros((1,)).long().cuda()).view(1) + # friction_k = self.ks_friction_val(torch.zeros((1,)).long()).view(1) # friction_force = vel_active_mesh * friction_k # forces = friction_force # ######## vel for frictions ######### @@ -7144,10 +7144,10 @@ class BendingNetworkActiveForceFieldForwardLagEuV13(nn.Module): # if input_pts_ts > 0: # vel_passive_mesh = self.timestep_to_vel[input_pts_ts - 1] # else: - # vel_passive_mesh = torch.zeros((3,), dtype=torch.float32).cuda() ### zeros ### + # vel_passive_mesh = torch.zeros((3,), dtype=torch.float32) ### zeros ### # vel_active_mesh = vel_active_mesh - vel_passive_mesh.unsqueeze(0) ## nn_active_pts x 3 ## --> active pts ## - # friction_k = self.ks_friction_val(torch.zeros((1,)).long().cuda()).view(1) + # friction_k = self.ks_friction_val(torch.zeros((1,)).long()).view(1) # friction_force = vel_active_mesh * friction_k # forces = friction_force # ######## vel for frictions ######### @@ -7156,7 +7156,7 @@ class BendingNetworkActiveForceFieldForwardLagEuV13(nn.Module): # # cur actuation # cur_actuation_embedding_st_idx = self.nn_actuators * input_pts_ts # cur_actuation_embedding_ed_idx = self.nn_actuators * (input_pts_ts + 1) - # cur_actuation_embedding_idxes = torch.tensor([idxx for idxx in range(cur_actuation_embedding_st_idx, cur_actuation_embedding_ed_idx)], dtype=torch.long).cuda() + # cur_actuation_embedding_idxes = torch.tensor([idxx for idxx in range(cur_actuation_embedding_st_idx, cur_actuation_embedding_ed_idx)], dtype=torch.long) # # ######### optimize the actuator forces directly ######### # # cur_actuation_forces = self.actuator_forces(cur_actuation_embedding_idxes) # # forces = cur_actuation_forces @@ -7168,12 +7168,12 @@ class BendingNetworkActiveForceFieldForwardLagEuV13(nn.Module): # else: # cur_actuation_embedding_st_idx = 365428 * input_pts_ts # cur_actuation_embedding_ed_idx = 365428 * (input_pts_ts + 1) - # cur_actuation_embedding_idxes = torch.tensor([idxx for idxx in range(cur_actuation_embedding_st_idx, cur_actuation_embedding_ed_idx)], dtype=torch.long).cuda() + # cur_actuation_embedding_idxes = torch.tensor([idxx for idxx in range(cur_actuation_embedding_st_idx, cur_actuation_embedding_ed_idx)], dtype=torch.long) # cur_actuation_friction_forces = friction_forces(cur_actuation_embedding_idxes) - # ws_alpha = self.ks_weights(torch.zeros((1,)).long().cuda()).view(1) - # ws_beta = self.ks_weights(torch.ones((1,)).long().cuda()).view(1) + # ws_alpha = self.ks_weights(torch.zeros((1,)).long()).view(1) + # ws_beta = self.ks_weights(torch.ones((1,)).long()).view(1) # dist_sampled_pts_to_passive_obj = torch.sum( # nn_sampled_pts x nn_passive_pts # (sampled_input_pts.unsqueeze(1) - cur_passive_obj_verts.unsqueeze(0)) ** 2, dim=-1 @@ -7212,15 +7212,15 @@ class BendingNetworkActiveForceFieldForwardLagEuV13(nn.Module): # dot_rel_inter_obj_pts_normals = torch.sum(rel_inter_obj_pts_to_sampled_pts * inter_obj_normals, dim=-1) ## nn_sampled_pts # dist_sampled_pts_to_passive_obj[dot_rel_inter_obj_pts_normals < 0] = -1. * dist_sampled_pts_to_passive_obj[dot_rel_inter_obj_pts_normals < 0] # # contact_spring_ka * | minn_spring_length - dist_sampled_pts_to_passive_obj | - # contact_spring_ka = self.spring_ks_values(torch.zeros((1,), dtype=torch.long).cuda()).view(1,) - # contact_spring_kb = self.spring_ks_values(torch.zeros((1,), dtype=torch.long).cuda() + 2).view(1,) - # contact_spring_kc = self.spring_ks_values(torch.zeros((1,), dtype=torch.long).cuda() + 3).view(1,) + # contact_spring_ka = self.spring_ks_values(torch.zeros((1,), dtype=torch.long)).view(1,) + # contact_spring_kb = self.spring_ks_values(torch.zeros((1,), dtype=torch.long) + 2).view(1,) + # contact_spring_kc = self.spring_ks_values(torch.zeros((1,), dtype=torch.long) + 3).view(1,) # # ### # fields # # # contact_force_d = -contact_spring_ka * (dist_sampled_pts_to_passive_obj - self.contact_spring_rest_length) # # contact_force_d = contact_spring_ka * (self.contact_spring_rest_length - dist_sampled_pts_to_passive_obj) # + contact_spring_kb * (self.contact_spring_rest_length - dist_sampled_pts_to_passive_obj) ** 2 + contact_spring_kc * (self.contact_spring_rest_length - dist_sampled_pts_to_passive_obj) ** 3 # # vel_sampled_pts = nex_active_mesh - cur_active_mesh - # tangential_ks = self.spring_ks_values(torch.ones((1,), dtype=torch.long).cuda()).view(1,) + # tangential_ks = self.spring_ks_values(torch.ones((1,), dtype=torch.long)).view(1,) # ###### Get the tangential forces via optimizable forces ###### # cur_actuation_friction_forces_along_normals = torch.sum(cur_actuation_friction_forces * inter_obj_normals, dim=-1).unsqueeze(-1) * inter_obj_normals @@ -7303,11 +7303,11 @@ class BendingNetworkActiveForceFieldForwardLagEuV13(nn.Module): # - time_cons = self.time_constant(torch.zeros((1,)).long().cuda()).view(1) - time_cons_2 = self.time_constant(torch.zeros((1,)).long().cuda() + 2).view(1) - time_cons_rot = self.time_constant(torch.ones((1,)).long().cuda()).view(1) - damping_cons = self.damping_constant(torch.zeros((1,)).long().cuda()).view(1) - damping_cons_rot = self.damping_constant(torch.ones((1,)).long().cuda()).view(1) + time_cons = self.time_constant(torch.zeros((1,)).long()).view(1) + time_cons_2 = self.time_constant(torch.zeros((1,)).long() + 2).view(1) + time_cons_rot = self.time_constant(torch.ones((1,)).long()).view(1) + damping_cons = self.damping_constant(torch.zeros((1,)).long()).view(1) + damping_cons_rot = self.damping_constant(torch.ones((1,)).long()).view(1) k_acc_to_vel = time_cons k_vel_to_offset = time_cons_2 delta_vel = rigid_acc * k_acc_to_vel @@ -7371,7 +7371,7 @@ class BendingNetworkActiveForceFieldForwardLagEuV13(nn.Module): self.timestep_to_angular_vel[input_pts_ts] = cur_angular_vel.detach() self.timestep_to_quaternion[nex_pts_ts] = cur_quaternion.detach() - # self.timestep_to_optimizable_total_def[input_pts_ts + 1] = self.time_translations(torch.zeros((1,), dtype=torch.long).cuda() + input_pts_ts).view(3) + # self.timestep_to_optimizable_total_def[input_pts_ts + 1] = self.time_translations(torch.zeros((1,), dtype=torch.long) + input_pts_ts).view(3) self.timestep_to_input_pts[input_pts_ts] = sampled_input_pts.detach() @@ -7388,7 +7388,7 @@ class BendingNetworkActiveForceFieldForwardLagEuV13(nn.Module): selected_pts_tot_forces = torch.cat([pts_contact_force, pts_friction], dim=-1) cur_grid_pts_forces[idx_pts_near_to_obj] = selected_pts_tot_forces self.timestep_to_grid_pts_forces[input_pts_ts] = cur_grid_pts_forces # .detach() - cur_grid_pts_weight = torch.zeros((self.grid_pts.size(0),), dtype=torch.float32).cuda() + cur_grid_pts_weight = torch.zeros((self.grid_pts.size(0),), dtype=torch.float32) cur_grid_pts_weight[idx_pts_near_to_obj] = weight self.timestep_to_grid_pts_weight[input_pts_ts] = cur_grid_pts_weight @@ -7480,8 +7480,8 @@ class BendingNetworkActiveForceFieldForwardLagRoboManipV13(nn.Module): num_embeddings=self.bending_n_timesteps, embedding_dim=self.bending_latent_size ) - # dist_k_a = self.distance_ks_val(torch.zeros((1,)).long().cuda()).view(1) - # dist_k_b = self.distance_ks_val(torch.ones((1,)).long().cuda()).view(1) * 5# *# 0.1 + # dist_k_a = self.distance_ks_val(torch.zeros((1,)).long()).view(1) + # dist_k_b = self.distance_ks_val(torch.ones((1,)).long()).view(1) * 5# *# 0.1 # distance self.distance_ks_val = nn.Embedding( @@ -7878,8 +7878,8 @@ class BendingNetworkActiveForceFieldForwardLagRoboManipV13(nn.Module): ''' Kinematics rigid transformations only ''' # timestep_to_optimizable_total_def, timestep_to_optimizable_quaternio - # self.timestep_to_optimizable_total_def[input_pts_ts + 1] = self.time_translations(torch.zeros((1,), dtype=torch.long).cuda() + input_pts_ts).view(3) - # self.timestep_to_optimizable_quaternion[input_pts_ts + 1] = self.time_quaternions(torch.zeros((1,), dtype=torch.long).cuda() + input_pts_ts).view(4) + # self.timestep_to_optimizable_total_def[input_pts_ts + 1] = self.time_translations(torch.zeros((1,), dtype=torch.long) + input_pts_ts).view(3) + # self.timestep_to_optimizable_quaternion[input_pts_ts + 1] = self.time_quaternions(torch.zeros((1,), dtype=torch.long) + input_pts_ts).view(4) # cur_optimizable_rot_mtx = quaternion_to_matrix(self.timestep_to_optimizable_quaternion[input_pts_ts + 1]) # self.timestep_to_optimizable_rot_mtx[input_pts_ts + 1] = cur_optimizable_rot_mtx ''' Kinematics rigid transformations only ''' @@ -7887,15 +7887,15 @@ class BendingNetworkActiveForceFieldForwardLagRoboManipV13(nn.Module): nex_pts_ts = input_pts_ts + 1 # ''' Kinematics transformations from acc and torques ''' - # rigid_acc = self.time_forces(torch.zeros((1,), dtype=torch.long).cuda() + input_pts_ts).view(3) - # torque = self.time_torques(torch.zeros((1,), dtype=torch.long).cuda() + input_pts_ts).view(3) # TODO: note that inertial_matrix^{-1} real_torque # + # rigid_acc = self.time_forces(torch.zeros((1,), dtype=torch.long) + input_pts_ts).view(3) + # torque = self.time_torques(torch.zeros((1,), dtype=torch.long) + input_pts_ts).view(3) # TODO: note that inertial_matrix^{-1} real_torque # ''' Kinematics transformations from acc and torques ''' friction_qd = 0.1 sampled_input_pts = timestep_to_active_mesh[input_pts_ts] - ws_normed = torch.ones((sampled_input_pts.size(0),), dtype=torch.float32).cuda() + ws_normed = torch.ones((sampled_input_pts.size(0),), dtype=torch.float32) ws_normed = ws_normed / float(sampled_input_pts.size(0)) m = Categorical(ws_normed) nn_sampled_input_pts = 5000 @@ -7925,7 +7925,7 @@ class BendingNetworkActiveForceFieldForwardLagRoboManipV13(nn.Module): # ######## vel for frictions ######### # vel_active_mesh = nex_active_mesh - cur_active_mesh # the active mesh velocity - # friction_k = self.ks_friction_val(torch.zeros((1,)).long().cuda()).view(1) + # friction_k = self.ks_friction_val(torch.zeros((1,)).long()).view(1) # friction_force = vel_active_mesh * friction_k # forces = friction_force # ######## vel for frictions ######### @@ -7936,10 +7936,10 @@ class BendingNetworkActiveForceFieldForwardLagRoboManipV13(nn.Module): # if input_pts_ts > 0: # vel_passive_mesh = self.timestep_to_vel[input_pts_ts - 1] # else: - # vel_passive_mesh = torch.zeros((3,), dtype=torch.float32).cuda() ### zeros ### + # vel_passive_mesh = torch.zeros((3,), dtype=torch.float32) ### zeros ### # vel_active_mesh = vel_active_mesh - vel_passive_mesh.unsqueeze(0) ## nn_active_pts x 3 ## --> active pts ## - # friction_k = self.ks_friction_val(torch.zeros((1,)).long().cuda()).view(1) + # friction_k = self.ks_friction_val(torch.zeros((1,)).long()).view(1) # friction_force = vel_active_mesh * friction_k # forces = friction_force # ######## vel for frictions ######### @@ -7948,7 +7948,7 @@ class BendingNetworkActiveForceFieldForwardLagRoboManipV13(nn.Module): # cur actuation # embedding st idx # cur_actuation_embedding_st_idx = self.nn_actuators * input_pts_ts cur_actuation_embedding_ed_idx = self.nn_actuators * (input_pts_ts + 1) - cur_actuation_embedding_idxes = torch.tensor([idxx for idxx in range(cur_actuation_embedding_st_idx, cur_actuation_embedding_ed_idx)], dtype=torch.long).cuda() + cur_actuation_embedding_idxes = torch.tensor([idxx for idxx in range(cur_actuation_embedding_st_idx, cur_actuation_embedding_ed_idx)], dtype=torch.long) # ######### optimize the actuator forces directly ######### # cur_actuation_forces = self.actuator_forces(cur_actuation_embedding_idxes) # forces = cur_actuation_forces @@ -7960,13 +7960,13 @@ class BendingNetworkActiveForceFieldForwardLagRoboManipV13(nn.Module): else: cur_actuation_embedding_st_idx = 365428 * input_pts_ts cur_actuation_embedding_ed_idx = 365428 * (input_pts_ts + 1) - cur_actuation_embedding_idxes = torch.tensor([idxx for idxx in range(cur_actuation_embedding_st_idx, cur_actuation_embedding_ed_idx)], dtype=torch.long).cuda() + cur_actuation_embedding_idxes = torch.tensor([idxx for idxx in range(cur_actuation_embedding_st_idx, cur_actuation_embedding_ed_idx)], dtype=torch.long) cur_actuation_friction_forces = friction_forces(cur_actuation_embedding_idxes) cur_actuation_friction_forces = cur_actuation_friction_forces[sampled_input_pts_idx] ## sample ## - ws_alpha = self.ks_weights(torch.zeros((1,)).long().cuda()).view(1) - ws_beta = self.ks_weights(torch.ones((1,)).long().cuda()).view(1) + ws_alpha = self.ks_weights(torch.zeros((1,)).long()).view(1) + ws_beta = self.ks_weights(torch.ones((1,)).long()).view(1) dist_sampled_pts_to_passive_obj = torch.sum( # nn_sampled_pts x nn_passive_pts (sampled_input_pts.unsqueeze(1) - cur_passive_obj_verts.unsqueeze(0)) ** 2, dim=-1 @@ -8008,14 +8008,14 @@ class BendingNetworkActiveForceFieldForwardLagRoboManipV13(nn.Module): dot_rel_inter_obj_pts_normals = torch.sum(rel_inter_obj_pts_to_sampled_pts * inter_obj_normals, dim=-1) ## nn_sampled_pts dist_sampled_pts_to_passive_obj[dot_rel_inter_obj_pts_normals < 0] = -1. * dist_sampled_pts_to_passive_obj[dot_rel_inter_obj_pts_normals < 0] # contact_spring_ka * | minn_spring_length - dist_sampled_pts_to_passive_obj | - contact_spring_ka = self.spring_ks_values(torch.zeros((1,), dtype=torch.long).cuda()).view(1,) - contact_spring_kb = self.spring_ks_values(torch.zeros((1,), dtype=torch.long).cuda() + 2).view(1,) - contact_spring_kc = self.spring_ks_values(torch.zeros((1,), dtype=torch.long).cuda() + 3).view(1,) + contact_spring_ka = self.spring_ks_values(torch.zeros((1,), dtype=torch.long)).view(1,) + contact_spring_kb = self.spring_ks_values(torch.zeros((1,), dtype=torch.long) + 2).view(1,) + contact_spring_kc = self.spring_ks_values(torch.zeros((1,), dtype=torch.long) + 3).view(1,) # contact_force_d = -contact_spring_ka * (dist_sampled_pts_to_passive_obj - self.contact_spring_rest_length) # contact_force_d = contact_spring_ka * (self.contact_spring_rest_length - dist_sampled_pts_to_passive_obj) # + contact_spring_kb * (self.contact_spring_rest_length - dist_sampled_pts_to_passive_obj) ** 2 + contact_spring_kc * (self.contact_spring_rest_length - dist_sampled_pts_to_passive_obj) ** 3 # vel_sampled_pts = nex_active_mesh - cur_active_mesh - tangential_ks = self.spring_ks_values(torch.ones((1,), dtype=torch.long).cuda()).view(1,) + tangential_ks = self.spring_ks_values(torch.ones((1,), dtype=torch.long)).view(1,) ###### Get the tangential forces via optimizable forces ###### cur_actuation_friction_forces_along_normals = torch.sum(cur_actuation_friction_forces * inter_obj_normals, dim=-1).unsqueeze(-1) * inter_obj_normals @@ -8076,7 +8076,7 @@ class BendingNetworkActiveForceFieldForwardLagRoboManipV13(nn.Module): # hard_selected_forces, hard_selected_manipulating_points # hard_selected_forces = forces[hard_selected_manipulating_points] hard_selected_manipulating_points = sampled_input_pts[hard_selected_manipulating_points] ### - sampled_input_pts_idxes = torch.tensor([idxx for idxx in range(sampled_input_pts.size(0))], dtype=torch.long).cuda() + sampled_input_pts_idxes = torch.tensor([idxx for idxx in range(sampled_input_pts.size(0))], dtype=torch.long) hard_selected_sampled_input_pts_idxes = sampled_input_pts_idxes[hard_selected_manipulating_points] @@ -8103,11 +8103,11 @@ class BendingNetworkActiveForceFieldForwardLagRoboManipV13(nn.Module): - time_cons = self.time_constant(torch.zeros((1,)).long().cuda()).view(1) - time_cons_2 = self.time_constant(torch.zeros((1,)).long().cuda() + 2).view(1) - time_cons_rot = self.time_constant(torch.ones((1,)).long().cuda()).view(1) - damping_cons = self.damping_constant(torch.zeros((1,)).long().cuda()).view(1) - damping_cons_rot = self.damping_constant(torch.ones((1,)).long().cuda()).view(1) + time_cons = self.time_constant(torch.zeros((1,)).long()).view(1) + time_cons_2 = self.time_constant(torch.zeros((1,)).long() + 2).view(1) + time_cons_rot = self.time_constant(torch.ones((1,)).long()).view(1) + damping_cons = self.damping_constant(torch.zeros((1,)).long()).view(1) + damping_cons_rot = self.damping_constant(torch.ones((1,)).long()).view(1) k_acc_to_vel = time_cons k_vel_to_offset = time_cons_2 delta_vel = rigid_acc * k_acc_to_vel @@ -8171,7 +8171,7 @@ class BendingNetworkActiveForceFieldForwardLagRoboManipV13(nn.Module): self.timestep_to_angular_vel[input_pts_ts] = cur_angular_vel.detach() self.timestep_to_quaternion[nex_pts_ts] = cur_quaternion.detach() - # self.timestep_to_optimizable_total_def[input_pts_ts + 1] = self.time_translations(torch.zeros((1,), dtype=torch.long).cuda() + input_pts_ts).view(3) + # self.timestep_to_optimizable_total_def[input_pts_ts + 1] = self.time_translations(torch.zeros((1,), dtype=torch.long) + input_pts_ts).view(3) self.timestep_to_input_pts[input_pts_ts] = sampled_input_pts.detach() @@ -8351,7 +8351,7 @@ class BendingNetworkForward(nn.Module): [[ 0.0000, 0.0000, 0.0000], [-0.0008, 0.0040, 0.0159], [-0.0566, 0.0099, 0.0173]], dtype=torch.float32 - ).cuda() + ) self.use_opt_rigid_translations = False # load utils and the loading .... ## self.use_split_network = False @@ -8363,7 +8363,7 @@ class BendingNetworkForward(nn.Module): [[ 0.0000, 0.0000, 0.0000], [-0.0008, 0.0040, 0.0159], [-0.0566, 0.0099, 0.0173]], dtype=torch.float32, requires_grad=True - ).cuda() + ) elif n_ts == 5: self.rigid_translations = torch.tensor( [[ 0.0000, 0.0000, 0.0000], @@ -8371,7 +8371,7 @@ class BendingNetworkForward(nn.Module): [-0.1211, 0.1123, 0.0565], [-0.2700, 0.1271, 0.0412], [-0.3081, 0.1174, 0.0529]], dtype=torch.float32, requires_grad=False - ).cuda() + ) # self.rigid_translations.requires_grad = True # self.rigid_translations.requires_grad_ = True # self.rigid_translations = nn.Parameter( @@ -8477,7 +8477,7 @@ class BendingNetworkForward(nn.Module): active_mesh_deformation = torch.mean(active_mesh_deformation, dim=0) ### (3, ) deformation direction ## # sdf value ? # - ks_val = self.ks_val(torch.zeros((1,)).long().cuda()) + ks_val = self.ks_val(torch.zeros((1,)).long()) self.ks_val_vals = ks_val.detach().cpu().numpy().item() @@ -8501,7 +8501,7 @@ class BendingNetworkForward(nn.Module): if special_loss_return and details is None: # details is None # details = {} - expanded_input_pts_ts = torch.zeros((input_pts.size(0)), dtype=torch.long).cuda() + expanded_input_pts_ts = torch.zeros((input_pts.size(0)), dtype=torch.long) expanded_input_pts_ts = expanded_input_pts_ts + nex_pts_ts input_latents = self.bending_latent(expanded_input_pts_ts) @@ -8692,7 +8692,7 @@ class BendingNetwork(nn.Module): [[ 0.0000, 0.0000, 0.0000], [-0.0008, 0.0040, 0.0159], [-0.0566, 0.0099, 0.0173]], dtype=torch.float32 - ).cuda() + ) self.use_opt_rigid_translations = False # load utils and the loading .... ## self.use_split_network = False @@ -8702,7 +8702,7 @@ class BendingNetwork(nn.Module): [[ 0.0000, 0.0000, 0.0000], [-0.0008, 0.0040, 0.0159], [-0.0566, 0.0099, 0.0173]], dtype=torch.float32, requires_grad=True - ).cuda() + ) elif n_ts == 5: self.rigid_translations = torch.tensor( [[ 0.0000, 0.0000, 0.0000], @@ -8710,7 +8710,7 @@ class BendingNetwork(nn.Module): [-0.1211, 0.1123, 0.0565], [-0.2700, 0.1271, 0.0412], [-0.3081, 0.1174, 0.0529]], dtype=torch.float32, requires_grad=False - ).cuda() + ) # self.rigid_translations.requires_grad = True # self.rigid_translations.requires_grad_ = True # self.rigid_translations = nn.Parameter( @@ -8805,7 +8805,7 @@ class BendingNetwork(nn.Module): if special_loss_return and details is None: # details is None # details = {} - expanded_input_pts_ts = torch.zeros((input_pts.size(0)), dtype=torch.long).cuda() + expanded_input_pts_ts = torch.zeros((input_pts.size(0)), dtype=torch.long) expanded_input_pts_ts = expanded_input_pts_ts + input_pts_ts input_latents = self.bending_latent(expanded_input_pts_ts) @@ -9075,7 +9075,7 @@ class BendingNetworkRigidTrans(nn.Module): # [[ 0.0000, 0.0000, 0.0000], # [-0.0008, 0.0040, 0.0159], # [-0.0566, 0.0099, 0.0173]], dtype=torch.float32 - # ).cuda() + # ) # self.use_opt_rigid_translations = False # load utils and the loading .... ## self.use_split_network = False @@ -9085,7 +9085,7 @@ class BendingNetworkRigidTrans(nn.Module): [[ 0.0000, 0.0000, 0.0000], [-0.0008, 0.0040, 0.0159], [-0.0566, 0.0099, 0.0173]], dtype=torch.float32, requires_grad=True - ).cuda() + ) elif n_ts == 5: self.rigid_translations = torch.tensor( [[ 0.0000, 0.0000, 0.0000], @@ -9093,7 +9093,7 @@ class BendingNetworkRigidTrans(nn.Module): [-0.1211, 0.1123, 0.0565], [-0.2700, 0.1271, 0.0412], [-0.3081, 0.1174, 0.0529]], dtype=torch.float32, requires_grad=False - ).cuda() + ) # self.rigid_translations.requires_grad = True # self.rigid_translations.requires_grad_ = True # self.rigid_translations = nn.Parameter( @@ -9152,7 +9152,7 @@ class BendingNetworkRigidTrans(nn.Module): if special_loss_return and details is None: # details is None # details = {} - expanded_input_pts_ts = torch.zeros((input_pts.size(0)), dtype=torch.long).cuda() + expanded_input_pts_ts = torch.zeros((input_pts.size(0)), dtype=torch.long) expanded_input_pts_ts = expanded_input_pts_ts + input_pts_ts # input_latents = self.bending_latent(expanded_input_pts_ts) @@ -9261,7 +9261,7 @@ class BendingNetworkRigidTrans(nn.Module): if special_loss_return and details is None: # details is None # details = {} - expanded_input_pts_ts = torch.zeros((input_pts.size(0)), dtype=torch.long).cuda() + expanded_input_pts_ts = torch.zeros((input_pts.size(0)), dtype=torch.long) expanded_input_pts_ts = expanded_input_pts_ts + input_pts_ts # input_latents = self.bending_latent(expanded_input_pts_ts)