Skip to content

Commit 95e9acb

Browse files
committed
add ioai test env for develop purpose
1 parent 76f5ac5 commit 95e9acb

1 file changed

Lines changed: 116 additions & 0 deletions

File tree

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
#####################################################################################
2+
# Copyright (c) 2023-2025 Galbot. All Rights Reserved.
3+
#
4+
# This software contains confidential and proprietary information of Galbot, Inc.
5+
# ("Confidential Information"). You shall not disclose such Confidential Information
6+
# and shall use it only in accordance with the terms of the license agreement you
7+
# entered into with Galbot, Inc.
8+
#
9+
# UNAUTHORIZED COPYING, USE, OR DISTRIBUTION OF THIS SOFTWARE, OR ANY PORTION OR
10+
# DERIVATIVE THEREOF, IS STRICTLY PROHIBITED. IF YOU HAVE RECEIVED THIS SOFTWARE IN
11+
# ERROR, PLEASE NOTIFY GALBOT, INC. IMMEDIATELY AND DELETE IT FROM YOUR SYSTEM.
12+
#####################################################################################
13+
# _____ _ _ _ _
14+
# / ____| | | | | | \ | |
15+
# | (___ _ _ _ __ | |_| |__ | \| | _____ ____ _
16+
# \___ \| | | | '_ \| __| '_ \ | . ` |/ _ \ \ / / _` |
17+
# ____) | |_| | | | | |_| | | | | |\ | (_) \ V / (_| |
18+
# |_____/ \__, |_| |_|\__|_| |_| |_| \_|\___/ \_/ \__,_|
19+
# __/ |
20+
# |___/
21+
#
22+
#####################################################################################
23+
#
24+
# Description: A test env code for setting up ioai
25+
# Author: Chenyu Cao@Galbot
26+
# Date: 2025-07-24
27+
#
28+
#####################################################################################
29+
30+
from physics_simulator import PhysicsSimulator
31+
from synthnova_config import PhysicsSimulatorConfig, ScenarioConfig, MujocoConfig
32+
from physics_simulator.galbot_interface import GalbotInterface, GalbotInterfaceConfig
33+
from pathlib import Path
34+
35+
class IoaiTestEnv:
36+
def __init__(self, headless=False):
37+
self.simulator = None
38+
self.robot = None
39+
self.interface = None
40+
41+
self._setup_simulator(headless)
42+
self._setup_interface()
43+
self._init_pose()
44+
45+
def _setup_simulator(self, headless=False):
46+
sn_config = PhysicsSimulatorConfig(
47+
mujoco_config=MujocoConfig(headless=headless)
48+
)
49+
50+
scenario_config = ScenarioConfig.load_from_file(
51+
Path()
52+
.joinpath(PhysicsSimulator.get_root_directory())
53+
.joinpath("assets")
54+
.joinpath("synthnova_assets")
55+
.joinpath("scenarios")
56+
.joinpath("ioai_test_scenario_grasp.json")
57+
)
58+
sn_config.scenario_config = scenario_config
59+
60+
self.simulator = PhysicsSimulator(sn_config)
61+
self.simulator.initialize()
62+
63+
self.robot = self.simulator.get_robot("/World/Galbot")
64+
65+
def _setup_interface(self):
66+
self.interface = GalbotInterface(
67+
galbot_interface_config=self.galbot_interface_config,
68+
simulator=self.simulator
69+
)
70+
self.interface.initialize()
71+
72+
def _setup_interface(self):
73+
config = GalbotInterfaceConfig()
74+
config.robot.prim_path = "/World/Galbot"
75+
76+
robot_name = self.robot.name
77+
config.modules_manager.enabled_modules.extend([
78+
"right_arm", "left_arm", "leg", "head", "chassis"
79+
])
80+
81+
# Joint configurations
82+
config.right_arm.joint_names = [f"{robot_name}/right_arm_joint{i}" for i in range(1, 8)]
83+
config.left_arm.joint_names = [f"{robot_name}/left_arm_joint{i}" for i in range(1, 8)]
84+
config.leg.joint_names = [f"{robot_name}/leg_joint{i}" for i in range(1, 5)]
85+
config.head.joint_names = [f"{robot_name}/head_joint{i}" for i in range(1, 3)]
86+
config.chassis.joint_names = [
87+
f"{robot_name}/mobile_forward_joint",
88+
f"{robot_name}/mobile_side_joint",
89+
f"{robot_name}/mobile_yaw_joint",
90+
]
91+
92+
self.interface = GalbotInterface(galbot_interface_config=config, simulator=self.simulator)
93+
self.interface.initialize()
94+
95+
def _init_pose(self):
96+
# Initialize robot pose
97+
poses = {
98+
self.interface.head: [0.0, 0.0],
99+
self.interface.leg: [0.0835, 0.635, 0.523, 0.0],
100+
self.interface.left_arm: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
101+
self.interface.right_arm: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
102+
}
103+
104+
for module, pose in poses.items():
105+
module.set_joint_positions(pose, immediate=True)
106+
107+
def run(self):
108+
self.simulator.loop()
109+
110+
def close(self):
111+
self.simulator.close()
112+
113+
if __name__ == "__main__":
114+
env = IoaiTestEnv(headless=False)
115+
env.run()
116+
env.close()

0 commit comments

Comments
 (0)