11import logging
22import sys
3- from time import sleep
43
54import numpy as np
65import rcsss
7- from dotenv import dotenv_values
86from rcsss import sim
97from rcsss ._core .hw import FR3Config , IKController
108from rcsss ._core .sim import CameraType
@@ -57,54 +55,54 @@ def main():
5755 if "lab" not in rcsss .scenes :
5856 logger .error ("This pip package was not built with the UTN lab models, aborting." )
5957 sys .exit ()
58+ resource_manger : FCI | DummyResourceManager
6059 if ROBOT_INSTANCE == RobotInstance .HARDWARE :
6160 user , pw = load_creds_fr3_desk ()
6261 resource_manger = FCI (Desk (ROBOT_IP , user , pw ), unlock = False , lock_when_done = False )
6362 else :
6463 resource_manger = DummyResourceManager ()
6564
6665 with resource_manger :
66+ robot : rcsss .common .Robot
67+ gripper : rcsss .common .Gripper
6768 if ROBOT_INSTANCE == RobotInstance .SIMULATION :
6869 simulation = sim .Sim (rcsss .scenes ["fr3_empty_world" ]["mjb" ])
6970 urdf_path = get_urdf_path (URDF_PATH , allow_none_if_not_found = False )
71+ assert urdf_path is not None
7072 ik = rcsss .common .IK (urdf_path )
7173 robot = rcsss .sim .FR3 (simulation , "0" , ik )
7274 cfg = sim .FR3Config ()
7375 cfg .tcp_offset = rcsss .common .Pose (rcsss .common .FrankaHandTCPOffset ())
7476 cfg .realtime = False
7577 robot .set_parameters (cfg )
7678
77- gripper_cfg = sim .FHConfig ()
78- gripper = sim .FrankaHand (simulation , "0" , gripper_cfg )
79+ gripper_cfg_sim = sim .FHConfig ()
80+ gripper = sim .FrankaHand (simulation , "0" , gripper_cfg_sim )
7981
8082 # add camera to have a rendering gui
8183 cameras = {
82- "default_free" : SimCameraConfig (
83- identifier = "" , type = int (CameraType .default_free )
84- ),
85- "wrist" : SimCameraConfig (
86- identifier = "eye-in-hand_0" , type = int (CameraType .fixed )
87- ),
88- # TODO: odd behavior when not both cameras are used: only last image is shown
84+ "default_free" : SimCameraConfig (identifier = "" , type = int (CameraType .default_free )),
85+ "wrist" : SimCameraConfig (identifier = "eye-in-hand_0" , type = int (CameraType .fixed )),
8986 }
9087 cam_cfg = SimCameraSetConfig (cameras = cameras , resolution_width = 1280 , resolution_height = 720 , frame_rate = 20 )
91- camera_set = SimCameraSet (simulation , cam_cfg )
88+ camera_set = SimCameraSet (simulation , cam_cfg ) # noqa: F841
9289 simulation .open_gui ()
9390
9491 else :
9592 urdf_path = get_urdf_path (URDF_PATH , allow_none_if_not_found = False )
93+ assert urdf_path is not None
9694 ik = rcsss .common .IK (urdf_path )
97- robot = rcsss .hw .FR3 (ROBOT_IP , str ( rcsss . scenes [ "lab" ]. parent / "fr3.urdf" ), ik )
95+ robot = rcsss .hw .FR3 (ROBOT_IP , ik )
9896 robot_cfg = FR3Config ()
9997 robot_cfg .tcp_offset = rcsss .common .Pose (rcsss .common .FrankaHandTCPOffset ())
10098 robot_cfg .controller = IKController .robotics_library
10199 robot .set_parameters (robot_cfg )
102100
103- gripper_cfg = rcsss .hw .FHConfig ()
104- gripper_cfg .epsilon_inner = gripper_cfg .epsilon_outer = 0.1
105- gripper_cfg .speed = 0.1
106- gripper_cfg .force = 30
107- gripper = rcsss .hw .FrankaHand (ROBOT_IP , gripper_cfg )
101+ gripper_cfg_hw = rcsss .hw .FHConfig ()
102+ gripper_cfg_hw .epsilon_inner = gripper_cfg_hw .epsilon_outer = 0.1
103+ gripper_cfg_hw .speed = 0.1
104+ gripper_cfg_hw .force = 30
105+ gripper = rcsss .hw .FrankaHand (ROBOT_IP , gripper_cfg_hw )
108106 input ("the robot is going to move, press enter whenever you are ready" )
109107
110108 # move to home position and open gripper
@@ -120,7 +118,7 @@ def main():
120118 )
121119 if ROBOT_INSTANCE == RobotInstance .SIMULATION :
122120 simulation .step_until_convergence ()
123- logger .debug (f"IK success: { robot .get_state ().ik_success } " )
121+ logger .debug (f"IK success: { robot .get_state ().ik_success } " ) # type: ignore
124122 logger .debug (f"sim converged: { simulation .is_converged ()} " )
125123
126124 # 5cm in y direction
@@ -129,7 +127,7 @@ def main():
129127 )
130128 if ROBOT_INSTANCE == RobotInstance .SIMULATION :
131129 simulation .step_until_convergence ()
132- logger .debug (f"IK success: { robot .get_state ().ik_success } " )
130+ logger .debug (f"IK success: { robot .get_state ().ik_success } " ) # type: ignore
133131 logger .debug (f"sim converged: { simulation .is_converged ()} " )
134132
135133 # 5cm in z direction
@@ -138,7 +136,7 @@ def main():
138136 )
139137 if ROBOT_INSTANCE == RobotInstance .SIMULATION :
140138 simulation .step_until_convergence ()
141- logger .debug (f"IK success: { robot .get_state ().ik_success } " )
139+ logger .debug (f"IK success: { robot .get_state ().ik_success } " ) # type: ignore
142140 logger .debug (f"sim converged: { simulation .is_converged ()} " )
143141
144142 # rotate the arm 90 degrees around the inverted y and z axis
@@ -148,7 +146,7 @@ def main():
148146 robot .set_cartesian_position (new_pose )
149147 if ROBOT_INSTANCE == RobotInstance .SIMULATION :
150148 simulation .step_until_convergence ()
151- logger .debug (f"IK success: { robot .get_state ().ik_success } " )
149+ logger .debug (f"IK success: { robot .get_state ().ik_success } " ) # type: ignore
152150 logger .debug (f"sim converged: { simulation .is_converged ()} " )
153151
154152 if ROBOT_INSTANCE == RobotInstance .HARDWARE :
@@ -162,7 +160,7 @@ def main():
162160 )
163161 if ROBOT_INSTANCE == RobotInstance .SIMULATION :
164162 simulation .step_until_convergence ()
165- logger .debug (f"IK success: { robot .get_state ().ik_success } " )
163+ logger .debug (f"IK success: { robot .get_state ().ik_success } " ) # type: ignore
166164 logger .debug (f"sim converged: { simulation .is_converged ()} " )
167165
168166 # grasp the object
@@ -177,7 +175,7 @@ def main():
177175 )
178176 if ROBOT_INSTANCE == RobotInstance .SIMULATION :
179177 simulation .step_until_convergence ()
180- logger .debug (f"IK success: { robot .get_state ().ik_success } " )
178+ logger .debug (f"IK success: { robot .get_state ().ik_success } " ) # type: ignore
181179 logger .debug (f"sim converged: { simulation .is_converged ()} " )
182180
183181 if ROBOT_INSTANCE == RobotInstance .HARDWARE :
0 commit comments