add runner stereotype

This commit is contained in:
2025-09-05 12:00:59 +08:00
parent 4e51158215
commit 12a6b47969
7 changed files with 55 additions and 6 deletions

View File

View File

@@ -0,0 +1,23 @@
def generate_data():
robot = IsaacSimRpcRobot(robot_cfg=robot_cfg, scene_usd=task_info['scene']['scene_usd'],
client_host=args.client_host,
position=robot_position, rotation=robot_rotation, stand_type=stand["stand_type"],
stand_size_x=stand["stand_size_x"], stand_size_y=stand["stand_size_y"])
# planner = ManipulationPlanner()
agent = Agent(robot, None)
render_semantic = False
if "render_semantic" in task_info["recording_setting"]:
render_semantic = task_info["recording_setting"]["render_semantic"]
agent.run(task_folder=task_folder,
camera_list=task_info["recording_setting"]["camera_list"],
use_recording=args.use_recording,
workspaces=task_info['scene']['function_space_objects'],
fps=task_info["recording_setting"]["fps"],
render_semantic=render_semantic,
)
print("job done")
robot.client.Exit()

View File

@@ -1,5 +1,7 @@
from pyboot import stereotype
from pyboot.runner import Runner
@stereotype.runner("data_generator")
class DataGenerator(Runner):
def __init__(self, config_path: str):
super().__init__(config_path)

View File

@@ -1,5 +1,7 @@
from pyboot import stereotype
from pyboot.runner import Runner
@stereotype.runner("data_recorder")
class DataRecorder(Runner):
def __init__(self, config_path: str):
super().__init__(config_path)

View File

@@ -1,10 +1,13 @@
import json
import os
from pyboot import stereotype
from pyboot.runner import Runner
from pyboot.utils.log import Log
from task_gen_dependencies.task_generate import OldTaskGenerator
@stereotype.runner("task_generator")
class TaskGenerator(Runner):
def __init__(self, config_path: str):
super().__init__(config_path)

View File

@@ -2,9 +2,11 @@ import os
import shutil
import json
from pyboot import stereotype
from pyboot.runner import Runner
from pyboot.utils.log import Log
@stereotype.runner("task_templates_divider")
class TaskTemplatesDivider(Runner):
def __init__(self, config_path: str):
super().__init__(config_path)

View File

@@ -2,6 +2,8 @@
import os
import json
from copy import copy, deepcopy
import numpy as np
from task_gen_dependencies.object import OmniObject
from task_gen_dependencies.layout_object import LayoutObject
@@ -208,16 +210,31 @@ class OldTaskGenerator:
self.layouts[key] = LayoutGenerator(ws, obj_infos, objects, key_ids, extra_ids, constraint=constraint,
fix_obj_ids=self.fix_obj_ids)
self.stand = {
"stand_type": "cylinder",
"stand_size_x": 0.1,
"stand_size_y": 0.1
}
if "robot" not in task_template:
self.robot_cfg = "A2D_120s.json"
else:
self.robot_cfg = task_template["robot"]["robot_cfg"]
if "stand" in task_template["robot"]:
self.stand = task_template["robot"]["stand"]
def generate_tasks(self, save_path, task_num, task_name):
os.makedirs(save_path, exist_ok=True)
for i in range(task_num):
task_instance = deepcopy(self.task_template)
output_file = os.path.join(save_path, f'{task_name}_%d.json' % (i))
self.task_template['objects'] = []
self.task_template['objects'] += self.fix_obj_infos
self.task_template['robot'] = {
task_instance['objects'] = []
task_instance['objects'] += self.fix_obj_infos
task_instance['robot'] = {
"init_position" : self.robot_init_pose["position"],
"init_rotation" : self.robot_init_pose["quaternion"],
"robot_cfg": self.robot_cfg,
"stand": self.stand,
}
flag_failed = False
@@ -228,11 +245,11 @@ class OldTaskGenerator:
flag_failed = True
break
continue
self.task_template['objects'] += obj_infos
task_instance['objects'] += obj_infos
for object_info in self.obj_infos:
if object_info == 'fix_pose':
fix_pose_dict = self.obj_infos['fix_pose']
self.task_template['objects'].append(fix_pose_dict)
task_instance['objects'].append(fix_pose_dict)
break
if flag_failed:
Log.warning(f"Failed to place key object, skipping")
@@ -240,6 +257,6 @@ class OldTaskGenerator:
Log.info('Saved task json to %s' % output_file)
with open(output_file, 'w') as f:
json.dump(self.task_template, f, indent=4)
json.dump(task_instance, f, indent=4)
# -------------------------------------------------------------