33from time import sleep
44
55import numpy as np
6+ import rcs
67from rcs ._core .common import RPY , Pose , RobotPlatform
8+ from rcs ._core import common
79from rcs ._core .sim import SimConfig
810from rcs .camera .hw import HardwareCameraSet
911from rcs .envs .base import (
2123from rcs_fr3 .utils import default_fr3_hw_gripper_cfg , default_fr3_hw_robot_cfg
2224from rcs_realsense .utils import default_realsense
2325from rcs .operator .quest import QuestConfig , QuestOperator
26+ from rcs .operator .interface import TeleopLoop
2427
2528logger = logging .getLogger (__name__ )
2629
2730
28-
29-
3031ROBOT2IP = {
3132 # "left": "192.168.102.1",
3233 "right" : "192.168.101.1" ,
3334}
35+ ROBOT2ID = {
36+ "left" : "0" ,
37+ "right" : "1" ,
38+ }
3439
3540
36- # ROBOT_INSTANCE = RobotPlatform.SIMULATION
37- ROBOT_INSTANCE = RobotPlatform .HARDWARE
41+ ROBOT_INSTANCE = RobotPlatform .SIMULATION
42+ # ROBOT_INSTANCE = RobotPlatform.HARDWARE
3843
3944RECORD_FPS = 30
4045# set camera dict to none disable cameras
4550# "bird_eye": "243522070364",
4651# }
4752CAMERA_DICT = None
48- MQ3_ADDR = "10.42.0.1 "
53+ MQ3_ADDR = "192.168.1.219 "
4954
5055# DIGIT_DICT = {
5156# "digit_right_left": "D21182",
5661
5762DATASET_PATH = "test_data_iris_dual_arm14"
5863INSTRUCTION = "build a tower with the blocks in front of you"
59- TELEOP = "quest"
6064
61- configs = {"quest" : QuestConfig (robot_keys = ROBOT2IP .keys (), simulation = ROBOT_INSTANCE == RobotPlatform .SIMULATION , mq3_addr = MQ3_ADDR )}
62- operators = {
63- "quest" : QuestOperator ,
64- }
65+
66+ config = QuestConfig (mq3_addr = MQ3_ADDR , simulation = ROBOT_INSTANCE == RobotPlatform .SIMULATION )
6567
6668
6769def get_env ():
@@ -79,39 +81,70 @@ def get_env():
7981 name2ip = ROBOT2IP ,
8082 camera_set = camera_set ,
8183 robot_cfg = default_fr3_hw_robot_cfg (async_control = True ),
82- control_mode = operators [ TELEOP ] .control_mode [0 ],
84+ control_mode = QuestOperator .control_mode [0 ],
8385 gripper_cfg = default_fr3_hw_gripper_cfg (async_control = True ),
8486 max_relative_movement = (0.5 , np .deg2rad (90 )),
85- relative_to = operators [ TELEOP ] .control_mode [1 ],
87+ relative_to = QuestOperator .control_mode [1 ],
8688 )
8789 env_rel = StorageWrapper (
8890 env_rel , DATASET_PATH , INSTRUCTION , batch_size = 32 , max_rows_per_group = 100 , max_rows_per_file = 1000
8991 )
92+ operator = QuestOperator (config )
9093 else :
9194 # FR3
92- robot_cfg = default_sim_robot_cfg ("fr3_empty_world" )
95+ rcs .scenes ["rcs_icra_scene" ] = rcs .Scene (
96+ mjcf_scene = "/home/tobi/coding/rcs_clones/prs/models/scenes/rcs_icra_scene/scene.xml" ,
97+ mjcf_robot = rcs .scenes ["fr3_simple_pick_up" ].mjcf_robot ,
98+ robot_type = common .RobotType .FR3 ,
99+ )
100+ rcs .scenes ["pick" ] = rcs .Scene (
101+ mjcf_scene = "/home/tobi/coding/rcs_clones/prs/assets/scenes/fr3_simple_pick_up/scene.xml" ,
102+ mjcf_robot = rcs .scenes ["fr3_simple_pick_up" ].mjcf_robot ,
103+ robot_type = common .RobotType .FR3 ,
104+ )
105+
106+ # robot_cfg = default_sim_robot_cfg("fr3_empty_world")
107+ # robot_cfg = default_sim_robot_cfg("fr3_simple_pick_up")
108+ robot_cfg = default_sim_robot_cfg ("rcs_icra_scene" )
109+ # robot_cfg = default_sim_robot_cfg("pick")
110+
111+ # resolution = (256, 256)
112+ # cameras = {
113+ # cam: SimCameraConfig(
114+ # identifier=cam,
115+ # type=CameraType.fixed,
116+ # resolution_height=resolution[1],
117+ # resolution_width=resolution[0],
118+ # frame_rate=0,
119+ # )
120+ # for cam in ["side", "wrist"]
121+ # }
93122
94123 sim_cfg = SimConfig ()
95124 sim_cfg .async_control = True
96125 env_rel = SimMultiEnvCreator ()(
97- name2id = ROBOT2IP ,
126+ name2id = ROBOT2ID ,
98127 robot_cfg = robot_cfg ,
99- control_mode = operators [ TELEOP ] .control_mode [0 ],
128+ control_mode = QuestOperator .control_mode [0 ],
100129 gripper_cfg = default_sim_gripper_cfg (),
101130 # cameras=default_mujoco_cameraset_cfg(),
102131 max_relative_movement = 0.5 ,
103- relative_to = operators [ TELEOP ] .control_mode [1 ],
132+ relative_to = QuestOperator .control_mode [1 ],
104133 sim_cfg = sim_cfg ,
105134 )
106- sim = env_rel .unwrapped .envs [ROBOT2IP .keys ().__iter__ ().__next__ ()].sim # type: ignore
135+ # sim = env_rel.unwrapped.envs[ROBOT2IP.keys().__iter__().__next__()].sim # type: ignore
136+ sim = env_rel .get_wrapper_attr ("sim" )
137+ operator = QuestOperator (config , sim )
107138 sim .open_gui ()
108- return env_rel
139+ return env_rel , operator
140+
109141
110142def main ():
111- env_rel = get_env ()
143+ env_rel , operator = get_env ()
112144 env_rel .reset ()
113- with env_rel , operators [TELEOP ](env_rel , configs [TELEOP ]) as op : # type: ignore
114- op .environment_step_loop ()
145+ tele = TeleopLoop (env_rel , operator )
146+ with env_rel , tele : # type: ignore
147+ tele .environment_step_loop ()
115148
116149
117150if __name__ == "__main__" :
0 commit comments