跳转到内容

基础使用教程

快速开始(Quickstart) 部分中,我们介绍了如何使用 client.py 来测试仿真环境。 本节将讲解如何在 GenManipBench 上评估你自己的模型。

GenManip 的设计目标是让用户能够在无需深入理解 Isaac Sim 或 GenManip 内部机制的情况下,对模型进行评测。 一旦你的环境配置正确,你只需要通过定义好的通信协议与 GenManip 进行交互——也就是说,只需确保你的 输入输出 满足通信格式要求即可。

除此之外,GenManip 还支持多种 基准测试(Benchmarks),从多个维度评估模型性能。 你可以在 Benchmarks 章节中找到各个基准的详细说明。 对于任意基准测试,一般的使用流程如下:

Terminal window
# 下载所需资源并启动服务器
python ray_eval_server.py -cfg GenManipSuite/GenManip-Package-Basic
# 运行客户端
python standalone_tools/client.py --worker_ids 0 # 让 Server 创建一个 Isaac Sim 测试实例

不同基准的具体说明可以在对应的 Benchmarks 页面中查看。

你可以参考文件 standalone_tools/client.py,该脚本展示了通信逻辑的基本结构。 它从 Isaac Sim 基准环境中接收数据,并返回一个静态动作(例如不同机械臂的关节位置和末端执行器位姿示例)。 关于接口与通信协议的更多信息,请参考 通信协议(Communication Protocol) 一节。

需要注意的是,fake_port.py 是一个完全独立的脚本——它没有任何外部依赖。 这使得你可以非常方便地将其集成到自己的项目中,并添加你的模型推理逻辑。 例如,你可以如下修改主循环部分:

...
if __name__ == "__main__":
args = parse_args()
host = args.host
port = args.port
worker_ids = args.worker_ids
base_url = f"http://{host}:{port}"
# Create workers on server here, make sure they are created before stepping
client = EvalClient(base_url, worker_ids)
print(f"Created workers {worker_ids} on server {base_url}.")
# wrap the eval loop in a try-finally to ensure cleanup
try:
obs = client.reset()
while True:
action = {
i: fake_action(args.arm_type, args.gripper_type, args.control_type)
i: model.inference(process_data(obs[i])) # 或者使用 Batch 推理
for i in worker_ids
}
start = time.time()
obs, done = client.step(action)
print(f"workers {worker_ids} Step time: {time.time() - start:.4f} seconds")
if done:
# finished all evaluations
break
if obs is None:
break
if obs[worker_ids[0]]["obs"]["reset"]: # type: ignore
# model.reset()
model.reset()
pass
finally:
client.kill_workers()
print("Client cleaned.")

通过这种方式,你可以轻松地将自己的模型与 GenManip 平台对接,实现快速验证与评估。