|
99 | 99 | from robosuite.wrappers import VisualizationWrapper |
100 | 100 |
|
101 | 101 | if __name__ == "__main__": |
102 | | - |
103 | 102 | parser = argparse.ArgumentParser() |
104 | 103 | parser.add_argument("--environment", type=str, default="Lift") |
105 | | - parser.add_argument("--robots", nargs="+", type=str, default="Panda", help="Which robot(s) to use in the env") |
106 | 104 | parser.add_argument( |
107 | | - "--config", type=str, default="default", help="Specified environment configuration if necessary" |
| 105 | + "--robots", |
| 106 | + nargs="+", |
| 107 | + type=str, |
| 108 | + default="Panda", |
| 109 | + help="Which robot(s) to use in the env", |
| 110 | + ) |
| 111 | + parser.add_argument( |
| 112 | + "--config", |
| 113 | + type=str, |
| 114 | + default="default", |
| 115 | + help="Specified environment configuration if necessary", |
| 116 | + ) |
| 117 | + parser.add_argument( |
| 118 | + "--arm", |
| 119 | + type=str, |
| 120 | + default="right", |
| 121 | + help="Which arm to control (eg bimanual) 'right' or 'left'", |
| 122 | + ) |
| 123 | + parser.add_argument( |
| 124 | + "--switch-on-grasp", |
| 125 | + action="store_true", |
| 126 | + help="Switch gripper control on gripper action", |
| 127 | + ) |
| 128 | + parser.add_argument( |
| 129 | + "--toggle-camera-on-grasp", |
| 130 | + action="store_true", |
| 131 | + help="Switch camera angle on gripper action", |
108 | 132 | ) |
109 | | - parser.add_argument("--arm", type=str, default="right", help="Which arm to control (eg bimanual) 'right' or 'left'") |
110 | | - parser.add_argument("--switch-on-grasp", action="store_true", help="Switch gripper control on gripper action") |
111 | | - parser.add_argument("--toggle-camera-on-grasp", action="store_true", help="Switch camera angle on gripper action") |
112 | 133 | parser.add_argument( |
113 | 134 | "--controller", |
114 | 135 | type=str, |
115 | 136 | default=None, |
116 | 137 | help="Choice of controller. Can be generic (eg. 'BASIC' or 'WHOLE_BODY_MINK_IK') or json file (see robosuite/controllers/config for examples) or None to get the robot's default controller if it exists", |
117 | 138 | ) |
118 | 139 | parser.add_argument("--device", type=str, default="keyboard") |
119 | | - parser.add_argument("--pos-sensitivity", type=float, default=1.0, help="How much to scale position user inputs") |
120 | | - parser.add_argument("--rot-sensitivity", type=float, default=1.0, help="How much to scale rotation user inputs") |
| 140 | + parser.add_argument( |
| 141 | + "--pos-sensitivity", |
| 142 | + type=float, |
| 143 | + default=1.0, |
| 144 | + help="How much to scale position user inputs", |
| 145 | + ) |
| 146 | + parser.add_argument( |
| 147 | + "--rot-sensitivity", |
| 148 | + type=float, |
| 149 | + default=1.0, |
| 150 | + help="How much to scale rotation user inputs", |
| 151 | + ) |
121 | 152 | parser.add_argument( |
122 | 153 | "--max_fr", |
123 | 154 | default=20, |
124 | 155 | type=int, |
125 | 156 | help="Sleep when simluation runs faster than specified frame rate; 20 fps is real time.", |
126 | 157 | ) |
| 158 | + parser.add_argument( |
| 159 | + "--reverse_xy", |
| 160 | + type=bool, |
| 161 | + default=False, |
| 162 | + help="(DualSense Only)Reverse the effect of the x and y axes of the joystick.It is used to handle the case that the left/right and front/back sides of the view are opposite to the LX and LY of the joystick(Push LX up but the robot move left in your view)", |
| 163 | + ) |
127 | 164 | args = parser.parse_args() |
128 | 165 |
|
129 | 166 | # Get controller config |
|
168 | 205 | if args.device == "keyboard": |
169 | 206 | from robosuite.devices import Keyboard |
170 | 207 |
|
171 | | - device = Keyboard(env=env, pos_sensitivity=args.pos_sensitivity, rot_sensitivity=args.rot_sensitivity) |
| 208 | + device = Keyboard( |
| 209 | + env=env, |
| 210 | + pos_sensitivity=args.pos_sensitivity, |
| 211 | + rot_sensitivity=args.rot_sensitivity, |
| 212 | + ) |
172 | 213 | env.viewer.add_keypress_callback(device.on_press) |
173 | 214 | elif args.device == "spacemouse": |
174 | 215 | from robosuite.devices import SpaceMouse |
175 | 216 |
|
176 | | - device = SpaceMouse(env=env, pos_sensitivity=args.pos_sensitivity, rot_sensitivity=args.rot_sensitivity) |
| 217 | + device = SpaceMouse( |
| 218 | + env=env, |
| 219 | + pos_sensitivity=args.pos_sensitivity, |
| 220 | + rot_sensitivity=args.rot_sensitivity, |
| 221 | + ) |
| 222 | + elif args.device == "dualsense": |
| 223 | + from robosuite.devices import DualSense |
| 224 | + |
| 225 | + device = DualSense( |
| 226 | + env=env, |
| 227 | + pos_sensitivity=args.pos_sensitivity, |
| 228 | + rot_sensitivity=args.rot_sensitivity, |
| 229 | + reverse_xy=args.reverse_xy, |
| 230 | + ) |
177 | 231 | elif args.device == "mjgui": |
178 | 232 | from robosuite.devices.mjgui import MJGUI |
179 | 233 |
|
180 | 234 | device = MJGUI(env=env) |
181 | 235 | else: |
182 | | - raise Exception("Invalid device choice: choose either 'keyboard' or 'spacemouse'.") |
| 236 | + raise Exception("Invalid device choice: choose either 'keyboard', 'dualsene' or 'spacemouse'.") |
183 | 237 |
|
184 | 238 | while True: |
185 | 239 | # Reset the environment |
|
0 commit comments