Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
c176525
get_weld_contraints api and unit test
LeonLiu4 Jul 7, 2025
3cbc525
Merge branch 'main' into feature/get-weld
LeonLiu4 Jul 7, 2025
0cdd727
Merge branch 'main' into feature/get-weld
LeonLiu4 Jul 8, 2025
8d35d0e
dictionary return in get_weld
LeonLiu4 Jul 8, 2025
eb5eb84
mend
LeonLiu4 Jul 8, 2025
e463433
Merge branch 'main' into feature/get-weld
LeonLiu4 Jul 8, 2025
88fc6b9
Merge branch 'main' into feature/get-weld
LeonLiu4 Jul 9, 2025
17c3f82
taichi kernel and changed API
LeonLiu4 Jul 9, 2025
4837d9b
entity get_weld and unit test
LeonLiu4 Jul 9, 2025
e8d4a78
Update test_rigid_physics.py
LeonLiu4 Jul 9, 2025
4d6825e
velocity check in unit test
LeonLiu4 Jul 10, 2025
64ac3eb
mend
LeonLiu4 Jul 10, 2025
dc1124a
Merge branch 'main' into feature/get-weld
LeonLiu4 Jul 10, 2025
0a5efde
Merge branch 'main' into feature/get-weld
LeonLiu4 Jul 10, 2025
7ab12c5
mend
LeonLiu4 Jul 11, 2025
d53a5a4
Merge branch 'main' into feature/get-weld
YilingQiao Jul 11, 2025
ab2abfb
Merge branch 'main' into feature/get-weld
LeonLiu4 Jul 12, 2025
4ade718
Merge branch 'main' into feature/get-weld
LeonLiu4 Jul 14, 2025
97feebe
no flattening array
LeonLiu4 Jul 14, 2025
bf506ec
Merge branch 'main' into feature/get-weld
LeonLiu4 Jul 15, 2025
b093928
Merge branch 'main' into feature/get-weld
LeonLiu4 Jul 15, 2025
69922ce
Merge branch 'main' into feature/get-weld
LeonLiu4 Jul 16, 2025
543dceb
no 3D tensor and fixed formatting in unit tests
LeonLiu4 Jul 16, 2025
346a145
changed entity level get_weld
LeonLiu4 Jul 16, 2025
b232d5f
Merge branch 'main' into feature/get-weld
LeonLiu4 Jul 23, 2025
0ea2e96
mend
LeonLiu4 Jul 23, 2025
8bd9fce
Merge branch 'main' into feature/get-weld
LeonLiu4 Aug 4, 2025
f59852a
updated get_weld_constraint api after merging main
LeonLiu4 Aug 4, 2025
f742a9a
api tester, removed torch/tensor options and optional key, cleaned up…
LeonLiu4 Aug 8, 2025
4bb2c58
Merge branch 'main' into feature/get-weld
LeonLiu4 Aug 8, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions genesis/engine/solvers/rigid/rigid_solver_decomp.py
Original file line number Diff line number Diff line change
Expand Up @@ -5002,6 +5002,41 @@ def _kernel_delete_weld_constraint(
]
self.constraint_solver.ti_n_equalities[i_b] = self.constraint_solver.ti_n_equalities[i_b] - 1

def get_weld_constraints(self, envs_idx=None):
if envs_idx is None:
envs_idx = np.arange(self.n_envs, dtype=np.int32)
envs_idx = np.atleast_1d(envs_idx)

env_col, obj_a_col, obj_b_col = [], [], []
WELD = gs.EQUALITY_TYPE.WELD

for env in envs_idx:
n_eq = int(self.constraint_solver.ti_n_equalities[env])
for i in range(n_eq):
rec = self.equalities_info[i, env]
if rec.eq_type == WELD:
env_col.append(env)
obj_a_col.append(int(rec.eq_obj1id))
obj_b_col.append(int(rec.eq_obj2id))

obj_a = np.asarray(obj_a_col, dtype=np.int32)
obj_b = np.asarray(obj_b_col, dtype=np.int32)

if self.n_envs == 0:
return {"obj_a": obj_a, "obj_b": obj_b}

env_arr = np.asarray(env_col, dtype=np.int32)
valid_mask = np.zeros((self.n_envs, obj_a.shape[0]), dtype=bool)
for j, e in enumerate(env_arr):
valid_mask[e, j] = True

return {
"env": env_arr,
"obj_a": obj_a,
"obj_b": obj_b,
"valid_mask": valid_mask,
}

# ------------------------------------------------------------------------------------
# ----------------------------------- properties -------------------------------------
# ------------------------------------------------------------------------------------
Expand Down
23 changes: 23 additions & 0 deletions tests/test_rigid_physics.py
Original file line number Diff line number Diff line change
Expand Up @@ -2169,6 +2169,29 @@ def test_terrain_size(show_viewer, tol):
assert_allclose((height_ref * 2.0), height_test, tol=tol)


@pytest.mark.required
@pytest.mark.parametrize("backend", [gs.cpu])
def test_get_weld_constraints_basic(show_viewer, tol):
scene = gs.Scene(show_viewer=show_viewer)

cube1 = scene.add_entity(gs.morphs.Box(size=(0.05,) * 3, pos=(0.0, 0.0, 0.05)))
cube2 = scene.add_entity(gs.morphs.Box(size=(0.05,) * 3, pos=(0.2, 0.0, 0.05)))

scene.build(n_envs=1)

rigid = scene.sim.rigid_solver
link_a = np.array([cube1.base_link.idx], dtype=gs.np_int)
link_b = np.array([cube2.base_link.idx], dtype=gs.np_int)

rigid.add_weld_constraint(link_a, link_b)
scene.step()

welds = rigid.get_weld_constraints()
row = np.array([welds["env"][0], welds["obj_a"][0], welds["obj_b"][0]], dtype=np.int32)
ref = np.array([0, link_a[0], link_b[0]], dtype=np.int32)
assert_allclose(row, ref, tol=tol)


@pytest.mark.required
@pytest.mark.parametrize("backend", [gs.cpu])
def test_urdf_parsing(show_viewer, tol):
Expand Down