diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4bce1805a..261f77b80 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -13,7 +13,7 @@ repos: - id: check-yaml - id: check-toml - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.14.5 + rev: v0.15.12 hooks: - id: ruff args: [ --fix ] diff --git a/get_started/rl/fast_td3/fttd3_module.py b/get_started/rl/fast_td3/fttd3_module.py index 354d7878e..4bca9a3c7 100644 --- a/get_started/rl/fast_td3/fttd3_module.py +++ b/get_started/rl/fast_td3/fttd3_module.py @@ -425,7 +425,8 @@ def projection( next_dist = F.softmax(self.forward(obs, actions), dim=1) proj_dist = torch.zeros_like(next_dist) offset = ( - torch.linspace(0, (batch_size - 1) * self.num_atoms, batch_size, device=device) + torch + .linspace(0, (batch_size - 1) * self.num_atoms, batch_size, device=device) .unsqueeze(1) .expand(batch_size, self.num_atoms) .long() diff --git a/metasim/randomization/core/isaacsim_adapter.py b/metasim/randomization/core/isaacsim_adapter.py index bee53c720..ae3c3fcdf 100644 --- a/metasim/randomization/core/isaacsim_adapter.py +++ b/metasim/randomization/core/isaacsim_adapter.py @@ -263,7 +263,7 @@ def apply_mdl_material( # - material_name: Variant within MDL (optional, e.g., "Plywood::Oak") # - mtl_prim_name: Unique prim name to avoid conflicts mdl_basename = os.path.basename(mdl_path).removesuffix(".mdl") - prim_basename = prim_path.split("/")[-1] + prim_basename = prim_path.rsplit("/", maxsplit=1)[-1] mtl_prim_unique = f"{mdl_basename}_{prim_basename}_{id(prim_path)}" # Fully unique _, mtl_prim_path = get_material_prim_path(mtl_prim_unique) diff --git a/metasim/sim/newton/newton.py b/metasim/sim/newton/newton.py index 06ef035dc..9245fb8ea 100644 --- a/metasim/sim/newton/newton.py +++ b/metasim/sim/newton/newton.py @@ -1178,7 +1178,8 @@ def _render_tiled_cameras(self, env_ids: list[int]) -> dict: depth_tensor = depth_tensor[use_env_ids] intrinsics = ( - torch.tensor(cam_cfg.intrinsics, dtype=torch.float32, device=self.device) + torch + .tensor(cam_cfg.intrinsics, dtype=torch.float32, device=self.device) .unsqueeze(0) .expand(len(use_env_ids), -1, -1) ) diff --git a/metasim/utils/kinematics.py b/metasim/utils/kinematics.py index 9d9045213..fc8f38b52 100644 --- a/metasim/utils/kinematics.py +++ b/metasim/utils/kinematics.py @@ -103,7 +103,8 @@ def _solve_ik_jax_with_seed(robot, target_link_index, target_wxyz, target_positi ] sol = ( - jaxls.LeastSquaresProblem(factors, [joint_var]) + jaxls + .LeastSquaresProblem(factors, [joint_var]) .analyze() .solve( initial_vals=jaxls.VarValues.make([joint_var.with_value(prev_cfg)]), @@ -130,7 +131,8 @@ def _solve_ik_jax_without_seed(robot, target_link_index, target_wxyz, target_pos ] sol = ( - jaxls.LeastSquaresProblem(factors, [joint_var]) + jaxls + .LeastSquaresProblem(factors, [joint_var]) .analyze() .solve( verbose=False, diff --git a/roboverse_pack/callback_funcs/humanoid/step_funcs.py b/roboverse_pack/callback_funcs/humanoid/step_funcs.py index 09678bf80..217409361 100644 --- a/roboverse_pack/callback_funcs/humanoid/step_funcs.py +++ b/roboverse_pack/callback_funcs/humanoid/step_funcs.py @@ -77,7 +77,8 @@ def push_by_setting_velocity( / env.step_dt ).to(torch.int) push_env_ids = ( - torch.logical_and(env._episode_steps % env.push_interval == 0, env._episode_steps > 0) + torch + .logical_and(env._episode_steps % env.push_interval == 0, env._episode_steps > 0) .nonzero(as_tuple=False) .flatten() ) diff --git a/roboverse_pack/tasks/beyondmimic/metasim/envs/base_legged_robot.py b/roboverse_pack/tasks/beyondmimic/metasim/envs/base_legged_robot.py index 73ea29f9a..c9365156c 100644 --- a/roboverse_pack/tasks/beyondmimic/metasim/envs/base_legged_robot.py +++ b/roboverse_pack/tasks/beyondmimic/metasim/envs/base_legged_robot.py @@ -129,7 +129,8 @@ def _instantiate_cfg(self): # per-actuator action scale self.action_scale = ( - torch.tensor(list(self.robot.action_scale.values()), device=self.device) + torch + .tensor(list(self.robot.action_scale.values()), device=self.device) .unsqueeze(0) .repeat(self.num_envs, 1) ) diff --git a/roboverse_pack/tasks/beyondmimic/metasim/mdp/events.py b/roboverse_pack/tasks/beyondmimic/metasim/mdp/events.py index f0bd6bfa4..0728d4861 100644 --- a/roboverse_pack/tasks/beyondmimic/metasim/mdp/events.py +++ b/roboverse_pack/tasks/beyondmimic/metasim/mdp/events.py @@ -66,7 +66,8 @@ def push_by_setting_velocity( ).to(torch.int) # TODO different from how interval events are triggered in Isaac Lab, consider adapting this push_env_ids = ( - torch.logical_and(env._episode_steps % env.push_interval == 0, env._episode_steps > 0) + torch + .logical_and(env._episode_steps % env.push_interval == 0, env._episode_steps > 0) .nonzero(as_tuple=False) .flatten() ) diff --git a/roboverse_pack/tasks/beyondmimic/metasim/mdp/rewards.py b/roboverse_pack/tasks/beyondmimic/metasim/mdp/rewards.py index f50c07b14..80aad28a1 100644 --- a/roboverse_pack/tasks/beyondmimic/metasim/mdp/rewards.py +++ b/roboverse_pack/tasks/beyondmimic/metasim/mdp/rewards.py @@ -109,9 +109,8 @@ def undesired_contacts( contact_forces: ContactForces = env_states.extras["contact_forces"][env.name] is_contact = ( # TODO check correspondence with `contact_sensor.data.net_forces_w_history` - contact_forces.contact_forces_history[ - :, :, indexes, : - ] # [n_envs, history_length, n_indexes, 3] -> [n_envs, 3, 26, 3] + contact_forces + .contact_forces_history[:, :, indexes, :] # [n_envs, history_length, n_indexes, 3] -> [n_envs, 3, 26, 3] .norm(dim=-1) .max(dim=1)[0] > threshold