add runner stereotype
This commit is contained in:
0
data_gen_dependencies/__init__.py
Normal file
0
data_gen_dependencies/__init__.py
Normal file
23
data_gen_dependencies/data_generate.py
Normal file
23
data_gen_dependencies/data_generate.py
Normal 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()
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
|
from pyboot import stereotype
|
||||||
from pyboot.runner import Runner
|
from pyboot.runner import Runner
|
||||||
|
|
||||||
|
@stereotype.runner("data_generator")
|
||||||
class DataGenerator(Runner):
|
class DataGenerator(Runner):
|
||||||
def __init__(self, config_path: str):
|
def __init__(self, config_path: str):
|
||||||
super().__init__(config_path)
|
super().__init__(config_path)
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
|
from pyboot import stereotype
|
||||||
from pyboot.runner import Runner
|
from pyboot.runner import Runner
|
||||||
|
|
||||||
|
@stereotype.runner("data_recorder")
|
||||||
class DataRecorder(Runner):
|
class DataRecorder(Runner):
|
||||||
def __init__(self, config_path: str):
|
def __init__(self, config_path: str):
|
||||||
super().__init__(config_path)
|
super().__init__(config_path)
|
||||||
|
|||||||
@@ -1,10 +1,13 @@
|
|||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
from pyboot import stereotype
|
||||||
from pyboot.runner import Runner
|
from pyboot.runner import Runner
|
||||||
from pyboot.utils.log import Log
|
from pyboot.utils.log import Log
|
||||||
from task_gen_dependencies.task_generate import OldTaskGenerator
|
from task_gen_dependencies.task_generate import OldTaskGenerator
|
||||||
|
|
||||||
|
|
||||||
|
@stereotype.runner("task_generator")
|
||||||
class TaskGenerator(Runner):
|
class TaskGenerator(Runner):
|
||||||
def __init__(self, config_path: str):
|
def __init__(self, config_path: str):
|
||||||
super().__init__(config_path)
|
super().__init__(config_path)
|
||||||
|
|||||||
@@ -2,9 +2,11 @@ import os
|
|||||||
import shutil
|
import shutil
|
||||||
import json
|
import json
|
||||||
|
|
||||||
|
from pyboot import stereotype
|
||||||
from pyboot.runner import Runner
|
from pyboot.runner import Runner
|
||||||
from pyboot.utils.log import Log
|
from pyboot.utils.log import Log
|
||||||
|
|
||||||
|
@stereotype.runner("task_templates_divider")
|
||||||
class TaskTemplatesDivider(Runner):
|
class TaskTemplatesDivider(Runner):
|
||||||
def __init__(self, config_path: str):
|
def __init__(self, config_path: str):
|
||||||
super().__init__(config_path)
|
super().__init__(config_path)
|
||||||
|
|||||||
@@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import json
|
import json
|
||||||
|
from copy import copy, deepcopy
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from task_gen_dependencies.object import OmniObject
|
from task_gen_dependencies.object import OmniObject
|
||||||
from task_gen_dependencies.layout_object import LayoutObject
|
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,
|
self.layouts[key] = LayoutGenerator(ws, obj_infos, objects, key_ids, extra_ids, constraint=constraint,
|
||||||
fix_obj_ids=self.fix_obj_ids)
|
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):
|
def generate_tasks(self, save_path, task_num, task_name):
|
||||||
os.makedirs(save_path, exist_ok=True)
|
os.makedirs(save_path, exist_ok=True)
|
||||||
|
|
||||||
for i in range(task_num):
|
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))
|
output_file = os.path.join(save_path, f'{task_name}_%d.json' % (i))
|
||||||
self.task_template['objects'] = []
|
task_instance['objects'] = []
|
||||||
self.task_template['objects'] += self.fix_obj_infos
|
task_instance['objects'] += self.fix_obj_infos
|
||||||
self.task_template['robot'] = {
|
task_instance['robot'] = {
|
||||||
"init_position" : self.robot_init_pose["position"],
|
"init_position" : self.robot_init_pose["position"],
|
||||||
"init_rotation" : self.robot_init_pose["quaternion"],
|
"init_rotation" : self.robot_init_pose["quaternion"],
|
||||||
|
"robot_cfg": self.robot_cfg,
|
||||||
|
"stand": self.stand,
|
||||||
}
|
}
|
||||||
|
|
||||||
flag_failed = False
|
flag_failed = False
|
||||||
@@ -228,11 +245,11 @@ class OldTaskGenerator:
|
|||||||
flag_failed = True
|
flag_failed = True
|
||||||
break
|
break
|
||||||
continue
|
continue
|
||||||
self.task_template['objects'] += obj_infos
|
task_instance['objects'] += obj_infos
|
||||||
for object_info in self.obj_infos:
|
for object_info in self.obj_infos:
|
||||||
if object_info == 'fix_pose':
|
if object_info == 'fix_pose':
|
||||||
fix_pose_dict = self.obj_infos['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
|
break
|
||||||
if flag_failed:
|
if flag_failed:
|
||||||
Log.warning(f"Failed to place key object, skipping")
|
Log.warning(f"Failed to place key object, skipping")
|
||||||
@@ -240,6 +257,6 @@ class OldTaskGenerator:
|
|||||||
|
|
||||||
Log.info('Saved task json to %s' % output_file)
|
Log.info('Saved task json to %s' % output_file)
|
||||||
with open(output_file, 'w') as f:
|
with open(output_file, 'w') as f:
|
||||||
json.dump(self.task_template, f, indent=4)
|
json.dump(task_instance, f, indent=4)
|
||||||
|
|
||||||
# -------------------------------------------------------------
|
# -------------------------------------------------------------
|
||||||
Reference in New Issue
Block a user