Browse Source

[update] optim data record.

main
silencht 7 months ago
parent
commit
bc1208353a
  1. 10
      teleop/teleop_hand_and_arm.py
  2. 17
      teleop/utils/episode_writer.py

10
teleop/teleop_hand_and_arm.py

@ -54,7 +54,7 @@ listen_keyboard_thread.start()
if __name__ == '__main__': if __name__ == '__main__':
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
parser.add_argument('--task_dir', type = str, default = './utils/data', help = 'path to save data')
parser.add_argument('--task_dir', type = str, default = './utils/data/', help = 'path to save data')
parser.add_argument('--frequency', type = float, default = 60.0, help = 'save data\'s frequency') parser.add_argument('--frequency', type = float, default = 60.0, help = 'save data\'s frequency')
# basic control parameters # basic control parameters
@ -62,10 +62,12 @@ if __name__ == '__main__':
parser.add_argument('--arm', type=str, choices=['G1_29', 'G1_23', 'H1_2', 'H1'], default='G1_29', help='Select arm controller') parser.add_argument('--arm', type=str, choices=['G1_29', 'G1_23', 'H1_2', 'H1'], default='G1_29', help='Select arm controller')
parser.add_argument('--ee', type=str, choices=['dex1', 'dex3', 'inspire1', 'brainco'], help='Select end effector controller') parser.add_argument('--ee', type=str, choices=['dex1', 'dex3', 'inspire1', 'brainco'], help='Select end effector controller')
# mode flags # mode flags
parser.add_argument('--record', action = 'store_true', help = 'Enable data recording')
parser.add_argument('--motion', action = 'store_true', help = 'Enable motion control mode') parser.add_argument('--motion', action = 'store_true', help = 'Enable motion control mode')
parser.add_argument('--headless', action='store_true', help='Enable headless mode (no display)') parser.add_argument('--headless', action='store_true', help='Enable headless mode (no display)')
parser.add_argument('--sim', action = 'store_true', help = 'Enable isaac simulation mode') parser.add_argument('--sim', action = 'store_true', help = 'Enable isaac simulation mode')
parser.add_argument('--record', action = 'store_true', help = 'Enable data recording')
parser.add_argument('--tast-name', type = str, default = 'pick cube', help = 'task name for recording')
parser.add_argument('--task-goal', type = str, default = 'e.g. pick the red cube on the table.', help = 'task goal for recording')
args = parser.parse_args() args = parser.parse_args()
logger_mp.info(f"args: {args}") logger_mp.info(f"args: {args}")
@ -196,9 +198,9 @@ if __name__ == '__main__':
# record + headless mode # record + headless mode
if args.record and args.headless: if args.record and args.headless:
recorder = EpisodeWriter(task_dir = args.task_dir, frequency = args.frequency, rerun_log = False)
recorder = EpisodeWriter(task_dir = args.task_dir + args.tast_name, task_goal = args.task_goal, frequency = args.frequency, rerun_log = False)
elif args.record and not args.headless: elif args.record and not args.headless:
recorder = EpisodeWriter(task_dir = args.task_dir, frequency = args.frequency, rerun_log = True)
recorder = EpisodeWriter(task_dir = args.task_dir + args.tast_name, task_goal = args.task_goal, frequency = args.frequency, rerun_log = True)
try: try:
logger_mp.info("Please enter the start signal (enter 'r' to start the subsequent program)") logger_mp.info("Please enter the start signal (enter 'r' to start the subsequent program)")

17
teleop/utils/episode_writer.py

@ -11,12 +11,20 @@ import logging_mp
logger_mp = logging_mp.get_logger(__name__) logger_mp = logging_mp.get_logger(__name__)
class EpisodeWriter(): class EpisodeWriter():
def __init__(self, task_dir, frequency=30, image_size=[640, 480], rerun_log = True):
def __init__(self, task_dir, task_goal=None, frequency=30, image_size=[640, 480], rerun_log = True):
""" """
image_size: [width, height] image_size: [width, height]
""" """
logger_mp.info("==> EpisodeWriter initializing...\n") logger_mp.info("==> EpisodeWriter initializing...\n")
self.task_dir = task_dir self.task_dir = task_dir
self.text = {
"goal": "Pick up the red cup on the table.",
"desc": "task description",
"steps":"step1: do this; step2: do that; ...",
}
if task_goal is not None:
self.text['goal'] = task_goal
self.frequency = frequency self.frequency = frequency
self.image_size = image_size self.image_size = image_size
@ -39,7 +47,6 @@ class EpisodeWriter():
os.makedirs(self.task_dir) os.makedirs(self.task_dir)
logger_mp.info(f"==> episode directory does not exist, now create one.\n") logger_mp.info(f"==> episode directory does not exist, now create one.\n")
self.data_info() self.data_info()
self.text_desc()
self.is_available = True # Indicates whether the class is available for new operations self.is_available = True # Indicates whether the class is available for new operations
# Initialize the queue and worker thread # Initialize the queue and worker thread
@ -73,12 +80,6 @@ class EpisodeWriter():
}, },
"sim_state": "" "sim_state": ""
} }
def text_desc(self):
self.text = {
"goal": "Pick up the red cup on the table.",
"desc": "Pick up the cup from the table and place it in another position. The operation should be smooth and the water in the cup should not spill out",
"steps":"step1: searching for cups. step2: go to the target location. step3: pick up the cup",
}
def create_episode(self): def create_episode(self):

Loading…
Cancel
Save