Skip to content

Commit f9654a8

Browse files
committed
update ioai env
1 parent 18db966 commit f9654a8

1 file changed

Lines changed: 36 additions & 49 deletions

File tree

examples/ioai_examples/ioai_env.py

Lines changed: 36 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,6 @@ def _setup_simulator(self, headless=False):
165165
.joinpath("table.xml"),
166166
position=[0.65, 0, 0],
167167
orientation=[0, 0, 0.70711, 0.70711],
168-
# scale=[0.5, 0.7, 0.5]
169168
)
170169
self.simulator.add_object(table_config)
171170

@@ -186,27 +185,26 @@ def _setup_simulator(self, headless=False):
186185
# Add cube
187186
cube_config = CuboidConfig(
188187
prim_path="/World/Cube",
189-
position=[0.65, -0.3, 0.56],
188+
position=[0.6, -0.3, 0.56],
190189
orientation=[0, 0, 0, 1],
191190
scale=[0.05, 0.05, 0.05],
192191
color=[0.5, 0.5, 0.5], # Gray color
193192
)
194193
self.simulator.add_object(cube_config)
195194

196-
# # Add toy
197-
# toy_config = MeshConfig(
198-
# prim_path="/World/toy",
199-
# mjcf_path=Path()
200-
# .joinpath(self.simulator.synthnova_assets_directory)
201-
# .joinpath("synthnova_assets")
202-
# .joinpath("objects")
203-
# .joinpath("toy")
204-
# .joinpath("toy.xml"),
205-
# position=[0.6, 0, 0.5],
206-
# orientation=[0, 0.70711, 0, 0.70711],
207-
# scale=[0.2, 0.2, 0.2],
208-
# )
209-
# self.simulator.add_object(toy_config)
195+
# Add toy
196+
toy_config = MeshConfig(
197+
prim_path="/World/toy",
198+
mjcf_path=Path()
199+
.joinpath(self.simulator.synthnova_assets_directory)
200+
.joinpath("synthnova_assets")
201+
.joinpath("objects")
202+
.joinpath("toy")
203+
.joinpath("toy.xml"),
204+
position=[0.7, -0.2, 0.5],
205+
orientation=[0, 0, 0, 1],
206+
)
207+
self.simulator.add_object(toy_config)
210208

211209
# Add extrusion
212210
extrusion_config = MeshConfig(
@@ -218,8 +216,7 @@ def _setup_simulator(self, headless=False):
218216
.joinpath("extrusion")
219217
.joinpath("extrusion.xml"),
220218
position=[0.7, 0, 0.55],
221-
orientation=[0, 0.70711, 0, 0.70711],
222-
scale=[0.001, 0.001, 0.001],
219+
orientation=[0, 0, 0, 1],
223220
)
224221
self.simulator.add_object(extrusion_config)
225222

@@ -232,11 +229,25 @@ def _setup_simulator(self, headless=False):
232229
.joinpath("objects")
233230
.joinpath("power_drill")
234231
.joinpath("power_drill.xml"),
235-
position=[0.7, -0.1, 0.55],
236-
orientation=[0, 0, 0.70711, 0.70711],
232+
position=[0.6, -0.1, 0.55],
233+
orientation=[0, 0, 0, 1],
237234
)
238235
self.simulator.add_object(power_drill_config)
239236

237+
# Add mug
238+
mug_config = MeshConfig(
239+
prim_path="/World/Mug",
240+
mjcf_path=Path()
241+
.joinpath(self.simulator.synthnova_assets_directory)
242+
.joinpath("synthnova_assets")
243+
.joinpath("objects")
244+
.joinpath("mug")
245+
.joinpath("mug.xml"),
246+
position=[0.7, 0, 0.55],
247+
orientation=[0, 0, 0, 1],
248+
)
249+
self.simulator.add_object(mug_config)
250+
240251
center_x = 2
241252
center_y = 2
242253
wall_width = 5.5
@@ -697,39 +708,15 @@ def _move_right_arm_to_pose(self, target_position, target_orientation):
697708
return True
698709
return False
699710

700-
def get_left_gripper_pose(self):
701-
tmat = np.eye(4)
702-
tmat[:3,:3] = self.simulator.data.site(self.robot.namespace + "left_gripper_tcp").xmat.reshape((3,3))
703-
tmat[:3,3] = self.simulator.data.site(self.robot.namespace + "left_gripper_tcp").xpos
704-
705-
# Extract position
706-
position = tmat[:3, 3]
707-
708-
# Extract orientation as quaternion (x, y, z, w)
709-
from scipy.spatial.transform import Rotation
710-
rotation_matrix = tmat[:3, :3]
711-
quaternion = Rotation.from_matrix(rotation_matrix).as_quat()
712-
713-
return position, quaternion
714-
715-
def get_right_gripper_pose(self):
716-
tmat = np.eye(4)
717-
tmat[:3,:3] = self.simulator.data.site(self.robot.namespace + "right_gripper_tcp").xmat.reshape((3,3))
718-
tmat[:3,3] = self.simulator.data.site(self.robot.namespace + "right_gripper_tcp").xpos
719-
720-
# Extract position
721-
position = tmat[:3, 3]
722711

723-
# Extract orientation as quaternion (x, y, z, w)
724-
from scipy.spatial.transform import Rotation
725-
rotation_matrix = tmat[:3, :3]
726-
quaternion = Rotation.from_matrix(rotation_matrix).as_quat()
727-
728-
return position, quaternion
729-
730712
def run(self):
731713
self.simulator.loop()
732714

733715
if __name__ == "__main__":
734716
env = IOAIEnv(headless=False)
717+
#TODO: Define your callbacks here
718+
def demo_callback():
719+
print("demo callback")
720+
env.simulator.add_physics_callback("demo_callback", demo_callback)
721+
735722
env.run()

0 commit comments

Comments
 (0)