33from time import sleep
44
55import numpy as np
6+ import rcs
7+ from rcs ._core import common
68from rcs ._core .common import RPY , Pose , RobotPlatform
7- from rcs ._core .sim import SimConfig
9+ from rcs ._core .sim import CameraType , SimCameraConfig , SimConfig
810from rcs .camera .hw import HardwareCameraSet
911from rcs .envs .base import (
1012 ControlMode ,
1921from rcs .utils import SimpleFrameRate
2022from rcs_fr3 .creators import RCSFR3MultiEnvCreator
2123from rcs_fr3 .utils import default_fr3_hw_gripper_cfg , default_fr3_hw_robot_cfg
22- from rcs_realsense .utils import default_realsense
24+ # from rcs_realsense.utils import default_realsense
2325from simpub .core .simpub_server import SimPublisher
2426from simpub .parser .simdata import SimObject , SimScene
2527from simpub .sim .mj_publisher import MujocoPublisher
3941 # "left": "192.168.102.1",
4042 "right" : "192.168.101.1" ,
4143}
44+ ROBOT2ID = {
45+ "left" : "0" ,
46+ "right" : "1" ,
47+ }
4248
4349
44- # ROBOT_INSTANCE = RobotPlatform.SIMULATION
45- ROBOT_INSTANCE = RobotPlatform .HARDWARE
50+ ROBOT_INSTANCE = RobotPlatform .SIMULATION
51+ # ROBOT_INSTANCE = RobotPlatform.HARDWARE
4652RECORD_FPS = 30
4753# set camera dict to none disable cameras
4854# CAMERA_DICT = {
@@ -87,7 +93,7 @@ def __init__(self, env: RelativeActionSpace):
8793 self ._reset_lock = threading .Lock ()
8894 self ._env = env
8995
90- self .controller_names = ROBOT2IP .keys () if ROBOT_INSTANCE == RobotPlatform .HARDWARE else [ "right" ]
96+ self .controller_names = ROBOT2IP .keys () if ROBOT_INSTANCE == RobotPlatform .HARDWARE else ROBOT2ID . keys ()
9197 self ._trg_btn = {"left" : "index_trigger" , "right" : "index_trigger" }
9298 self ._grp_btn = {"left" : "hand_trigger" , "right" : "hand_trigger" }
9399 self ._start_btn = "A"
@@ -100,7 +106,7 @@ def __init__(self, env: RelativeActionSpace):
100106 self ._last_controller_pose = {key : Pose () for key in self .controller_names }
101107 self ._offset_pose = {key : Pose () for key in self .controller_names }
102108
103- for robot in ROBOT2IP :
109+ for robot in ROBOT2IP if ROBOT_INSTANCE == RobotPlatform . HARDWARE else ROBOT2ID :
104110 self ._env .envs [robot ].set_origin_to_current ()
105111
106112 self ._step_env = False
@@ -326,22 +332,50 @@ def main():
326332
327333 else :
328334 # FR3
329- robot_cfg = default_sim_robot_cfg ("fr3_empty_world" )
335+ rcs .scenes ["rcs_icra_scene" ] = rcs .Scene (
336+ mjcf_scene = "/home/tobi/coding/rcs_clones/prs/models/scenes/rcs_icra_scene/scene.xml" ,
337+ mjcf_robot = rcs .scenes ["fr3_simple_pick_up" ].mjcf_robot ,
338+ robot_type = common .RobotType .FR3 ,
339+ )
340+ rcs .scenes ["pick" ] = rcs .Scene (
341+ mjcf_scene = "/home/tobi/coding/rcs_clones/prs/assets/scenes/fr3_simple_pick_up/scene.xml" ,
342+ mjcf_robot = rcs .scenes ["fr3_simple_pick_up" ].mjcf_robot ,
343+ robot_type = common .RobotType .FR3 ,
344+ )
345+
346+ # robot_cfg = default_sim_robot_cfg("fr3_empty_world")
347+ # robot_cfg = default_sim_robot_cfg("fr3_simple_pick_up")
348+ robot_cfg = default_sim_robot_cfg ("rcs_icra_scene" )
349+ # robot_cfg = default_sim_robot_cfg("pick")
350+
351+ resolution = (256 , 256 )
352+ cameras = {
353+ cam : SimCameraConfig (
354+ identifier = cam ,
355+ type = CameraType .fixed ,
356+ resolution_height = resolution [1 ],
357+ resolution_width = resolution [0 ],
358+ frame_rate = 0 ,
359+ )
360+ for cam in ["side" , "wrist" ]
361+ }
330362
331363 sim_cfg = SimConfig ()
332364 sim_cfg .async_control = True
333365 env_rel = SimMultiEnvCreator ()(
334- name2id = ROBOT2IP ,
366+ name2id = ROBOT2ID ,
335367 robot_cfg = robot_cfg ,
336368 control_mode = ControlMode .CARTESIAN_TQuat ,
337369 gripper_cfg = default_sim_gripper_cfg (),
338- # cameras=default_mujoco_cameraset_cfg() ,
370+ # cameras=cameras ,
339371 max_relative_movement = 0.5 ,
340372 relative_to = RelativeTo .CONFIGURED_ORIGIN ,
341373 sim_cfg = sim_cfg ,
342374 )
343- sim = env_rel .unwrapped .envs [ROBOT2IP .keys ().__iter__ ().__next__ ()].sim # type: ignore
375+ # sim = env_rel.unwrapped.envs[ROBOT2ID.keys().__iter__().__next__()].sim # type: ignore
376+ sim = env_rel .get_wrapper_attr ("sim" )
344377 sim .open_gui ()
378+ # MySimPublisher(MySimScene(), MQ3_ADDR)
345379 MujocoPublisher (sim .model , sim .data , MQ3_ADDR , visible_geoms_groups = list (range (1 , 3 )))
346380
347381 env_rel .reset ()
0 commit comments