Skip to content

Commit 8c8f466

Browse files
committed
Merge branch 'main' into fem_rigid_debug
2 parents 4c06b6b + 0119348 commit 8c8f466

28 files changed

+18283
-15270
lines changed

examples/collision/contype.py

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
"""
2+
NOTE: contype and conaffinity are 32-bit integer bitmasks used for contact filtering of contact pairs.
3+
When the contype of one geom and the conaffinity of the other geom share a common bit set to 1, two geoms can collide.
4+
Plane: contype=0xFFFF, conaffinity=0xFFFF (1111 1111 1111 1111)
5+
Red Cube: contype=1, conaffinity=1 (0001) -> collide with Plane and Blue Cube
6+
Green Cube: contype=2, conaffinity=2 (0010) -> collide with Plane and Blue Cube
7+
Blue Cube: contype=3, conaffinity=3 (0011) -> collide with Plane, Red Cube, and Green Cube
8+
Dragon: contype=4, conaffinity=4 (0100) -> collide with Plane only
9+
"""
10+
11+
import argparse
12+
13+
import genesis as gs
14+
15+
16+
def main():
17+
parser = argparse.ArgumentParser()
18+
parser.add_argument("-v", "--vis", action="store_true", default=False)
19+
args = parser.parse_args()
20+
21+
gs.init()
22+
23+
scene = gs.Scene(
24+
viewer_options=gs.options.ViewerOptions(
25+
camera_pos=(0.0, -2, 1.5),
26+
camera_lookat=(0.0, 0.0, 0.5),
27+
camera_fov=40,
28+
max_FPS=200,
29+
),
30+
show_viewer=args.vis,
31+
)
32+
33+
scene.add_entity(gs.morphs.Plane())
34+
35+
scene.add_entity(
36+
gs.morphs.Box(
37+
pos=(0.025, 0, 0.5),
38+
quat=(0, 0, 0, 1),
39+
size=(0.1, 0.1, 0.1),
40+
contype=1,
41+
conaffinity=1,
42+
),
43+
surface=gs.surfaces.Default(
44+
color=(1.0, 0.0, 0.0, 1.0),
45+
),
46+
)
47+
scene.add_entity(
48+
gs.morphs.Box(
49+
pos=(-0.025, 0, 1.0),
50+
quat=(0, 0, 0, 1),
51+
size=(0.1, 0.1, 0.1),
52+
contype=2,
53+
conaffinity=2,
54+
),
55+
surface=gs.surfaces.Default(
56+
color=(0.0, 1.0, 0.0, 1.0),
57+
),
58+
)
59+
scene.add_entity(
60+
gs.morphs.Box(
61+
pos=(0.0, 0, 1.5),
62+
quat=(0, 0, 0, 1),
63+
size=(0.1, 0.1, 0.1),
64+
contype=3,
65+
conaffinity=3,
66+
),
67+
surface=gs.surfaces.Default(
68+
color=(0.0, 0.0, 1.0, 1.0),
69+
),
70+
)
71+
scene.add_entity(
72+
morph=gs.morphs.Mesh(
73+
file="meshes/dragon/dragon.obj",
74+
scale=0.004,
75+
euler=(0, 0, 90),
76+
pos=(-0.1, 0.0, 1.0),
77+
contype=4,
78+
conaffinity=4,
79+
),
80+
)
81+
82+
scene.build()
83+
84+
for i in range(1000):
85+
scene.step()
86+
87+
88+
if __name__ == "__main__":
89+
main()

examples/drone/hover_env.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@
22
import math
33
import copy
44
import genesis as gs
5-
from genesis.utils.geom import quat_to_xyz, transform_by_quat, inv_quat, transform_quat_by_quat
5+
from genesis.utils.geom import (
6+
quat_to_xyz,
7+
transform_by_quat,
8+
inv_quat,
9+
transform_quat_by_quat,
10+
)
611

712

813
def gs_rand_float(lower, upper, shape, device):
@@ -147,7 +152,10 @@ def step(self, actions):
147152
self.last_rel_pos = self.commands - self.last_base_pos
148153
self.base_quat[:] = self.drone.get_quat()
149154
self.base_euler = quat_to_xyz(
150-
transform_quat_by_quat(torch.ones_like(self.base_quat) * self.inv_base_init_quat, self.base_quat),
155+
transform_quat_by_quat(
156+
torch.ones_like(self.base_quat) * self.inv_base_init_quat,
157+
self.base_quat,
158+
),
151159
rpy=True,
152160
degrees=True,
153161
)

0 commit comments

Comments
 (0)