Skip to content

Commit d617c9b

Browse files
committed
format
1 parent 373bae1 commit d617c9b

File tree

1 file changed

+36
-23
lines changed

1 file changed

+36
-23
lines changed

genesis/engine/couplers/ipc_coupler.py

Lines changed: 36 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -692,7 +692,7 @@ def set_link_ipc_coupling_type(self, entity, coupling_type: str, link_names=None
692692
target_links.add(solver_link_idx)
693693

694694
# Apply coupling type
695-
if coupling_type == 'both':
695+
if coupling_type == "both":
696696
# Two-way coupling: include in IPC, not in IPC-only
697697
self._ipc_link_filters[entity_idx] = target_links
698698

@@ -704,7 +704,7 @@ def set_link_ipc_coupling_type(self, entity, coupling_type: str, link_names=None
704704

705705
gs.logger.info(f"Entity {entity_idx}: {len(target_links)} link(s) set to 'both' coupling")
706706

707-
elif coupling_type == 'ipc_only':
707+
elif coupling_type == "ipc_only":
708708
# One-way coupling: IPC -> Genesis
709709
if entity_idx not in self._ipc_only_links:
710710
self._ipc_only_links[entity_idx] = set()
@@ -717,7 +717,7 @@ def set_link_ipc_coupling_type(self, entity, coupling_type: str, link_names=None
717717

718718
gs.logger.info(f"Entity {entity_idx}: {len(target_links)} link(s) set to 'ipc_only' coupling")
719719

720-
elif coupling_type == 'genesis_only':
720+
elif coupling_type == "genesis_only":
721721
# Genesis-only: remove from both filters
722722
if entity_idx in self._ipc_link_filters:
723723
self._ipc_link_filters[entity_idx] -= target_links
@@ -729,12 +729,13 @@ def set_link_ipc_coupling_type(self, entity, coupling_type: str, link_names=None
729729
if not self._ipc_only_links[entity_idx]:
730730
del self._ipc_only_links[entity_idx]
731731

732-
gs.logger.info(f"Entity {entity_idx}: {len(target_links)} link(s) set to 'genesis_only' (excluded from IPC)")
732+
gs.logger.info(
733+
f"Entity {entity_idx}: {len(target_links)} link(s) set to 'genesis_only' (excluded from IPC)"
734+
)
733735

734736
else:
735737
raise ValueError(
736-
f"Invalid coupling_type '{coupling_type}'. "
737-
f"Must be 'both', 'ipc_only', or 'genesis_only'."
738+
f"Invalid coupling_type '{coupling_type}'. " f"Must be 'both', 'ipc_only', or 'genesis_only'."
738739
)
739740

740741
def preprocess(self, f):
@@ -1024,42 +1025,54 @@ def _set_genesis_transforms_from_ipc(self, abd_data_by_link):
10241025
) # (1, 4) [w, x, y, z]
10251026

10261027
# Determine if this is a base link
1027-
is_base_link = (link_idx == entity.base_link_idx)
1028+
is_base_link = link_idx == entity.base_link_idx
10281029

10291030
if is_base_link:
10301031
# Use base link methods for base links
10311032
base_links_idx = torch.tensor([link_idx], dtype=gs.tc_int, device=gs.device)
10321033

10331034
if is_parallelized:
10341035
rigid_solver.set_base_links_pos(
1035-
pos_tensor, base_links_idx, envs_idx=env_idx, relative=False, unsafe=True, skip_forward=False
1036+
pos_tensor,
1037+
base_links_idx,
1038+
envs_idx=env_idx,
1039+
relative=False,
1040+
unsafe=True,
1041+
skip_forward=False,
10361042
)
10371043
rigid_solver.set_base_links_quat(
1038-
quat_tensor, base_links_idx, envs_idx=env_idx, relative=False, unsafe=True, skip_forward=False
1044+
quat_tensor,
1045+
base_links_idx,
1046+
envs_idx=env_idx,
1047+
relative=False,
1048+
unsafe=True,
1049+
skip_forward=False,
10391050
)
10401051
else:
10411052
rigid_solver.set_base_links_pos(
1042-
pos_tensor, base_links_idx, envs_idx=None, relative=False, unsafe=True, skip_forward=False
1053+
pos_tensor,
1054+
base_links_idx,
1055+
envs_idx=None,
1056+
relative=False,
1057+
unsafe=True,
1058+
skip_forward=False,
10431059
)
10441060
rigid_solver.set_base_links_quat(
1045-
quat_tensor, base_links_idx, envs_idx=None, relative=False, unsafe=True, skip_forward=False
1061+
quat_tensor,
1062+
base_links_idx,
1063+
envs_idx=None,
1064+
relative=False,
1065+
unsafe=True,
1066+
skip_forward=False,
10461067
)
10471068
else:
10481069
# Use regular link methods for non-base links
10491070
if is_parallelized:
1050-
rigid_solver.set_links_pos(
1051-
pos_tensor, links_idx=link_idx, envs_idx=env_idx, unsafe=True
1052-
)
1053-
rigid_solver.set_links_quat(
1054-
quat_tensor, links_idx=link_idx, envs_idx=env_idx, unsafe=True
1055-
)
1071+
rigid_solver.set_links_pos(pos_tensor, links_idx=link_idx, envs_idx=env_idx, unsafe=True)
1072+
rigid_solver.set_links_quat(quat_tensor, links_idx=link_idx, envs_idx=env_idx, unsafe=True)
10561073
else:
1057-
rigid_solver.set_links_pos(
1058-
pos_tensor, links_idx=link_idx, unsafe=True
1059-
)
1060-
rigid_solver.set_links_quat(
1061-
quat_tensor, links_idx=link_idx, unsafe=True
1062-
)
1074+
rigid_solver.set_links_pos(pos_tensor, links_idx=link_idx, unsafe=True)
1075+
rigid_solver.set_links_quat(quat_tensor, links_idx=link_idx, unsafe=True)
10631076

10641077
# Zero velocities after setting transform to avoid spurious forces
10651078
if is_parallelized:

0 commit comments

Comments
 (0)