|
1 | | -""" Exports a USD file corresponding to the collected trajectory. |
| 1 | +"""Exports a USD file corresponding to the collected trajectory. |
2 | 2 |
|
3 | 3 | The USD (Universal Scene Description) file format allows users to save |
4 | 4 | trajectories such that they can be rendered in external renderers such |
|
8 | 8 |
|
9 | 9 | ***IMPORTANT***: If you are using mujoco version 3.1.1, please make sure |
10 | 10 | that you also have numpy < 2 installed in your environment. Failure to do |
11 | | -so may result in incorrect renderings. |
| 11 | +so may result in incorrect renderings. |
12 | 12 | """ |
| 13 | + |
13 | 14 | import argparse |
14 | 15 |
|
15 | 16 | import mujoco |
|
26 | 27 | ROBOSUITE_DEFAULT_LOGGER.warning("If using mujoco==3.1.1, please use numpy < 2 for rendering with USD.") |
27 | 28 |
|
28 | 29 | if __name__ == "__main__": |
29 | | - |
30 | 30 | parser = argparse.ArgumentParser() |
31 | 31 | parser.add_argument("--environment", type=str, default="Lift") |
32 | | - parser.add_argument("--robots", nargs="+", type=str, default="Panda", help="Which robot(s) to use in the env") |
33 | 32 | parser.add_argument( |
34 | | - "--config", type=str, default="default", help="Specified environment configuration if necessary" |
| 33 | + "--robots", |
| 34 | + nargs="+", |
| 35 | + type=str, |
| 36 | + default="Panda", |
| 37 | + help="Which robot(s) to use in the env", |
| 38 | + ) |
| 39 | + parser.add_argument( |
| 40 | + "--config", |
| 41 | + type=str, |
| 42 | + default="default", |
| 43 | + help="Specified environment configuration if necessary", |
| 44 | + ) |
| 45 | + parser.add_argument( |
| 46 | + "--arm", |
| 47 | + type=str, |
| 48 | + default="right", |
| 49 | + help="Which arm to control (eg bimanual) 'right' or 'left'", |
| 50 | + ) |
| 51 | + parser.add_argument( |
| 52 | + "--camera", |
| 53 | + type=str, |
| 54 | + default="agentview", |
| 55 | + help="Which camera to use for collecting demos", |
| 56 | + ) |
| 57 | + parser.add_argument( |
| 58 | + "--switch-on-grasp", |
| 59 | + action="store_true", |
| 60 | + help="Switch gripper control on gripper action", |
| 61 | + ) |
| 62 | + parser.add_argument( |
| 63 | + "--toggle-camera-on-grasp", |
| 64 | + action="store_true", |
| 65 | + help="Switch camera angle on gripper action", |
| 66 | + ) |
| 67 | + parser.add_argument( |
| 68 | + "--controller", |
| 69 | + type=str, |
| 70 | + default="BASIC", |
| 71 | + help="Choice of controller. Can be 'ik' or 'osc'", |
35 | 72 | ) |
36 | | - parser.add_argument("--arm", type=str, default="right", help="Which arm to control (eg bimanual) 'right' or 'left'") |
37 | | - parser.add_argument("--camera", type=str, default="agentview", help="Which camera to use for collecting demos") |
38 | | - parser.add_argument("--switch-on-grasp", action="store_true", help="Switch gripper control on gripper action") |
39 | | - parser.add_argument("--toggle-camera-on-grasp", action="store_true", help="Switch camera angle on gripper action") |
40 | | - parser.add_argument("--controller", type=str, default="BASIC", help="Choice of controller. Can be 'ik' or 'osc'") |
41 | 73 | parser.add_argument("--device", type=str, default="keyboard") |
42 | | - parser.add_argument("--pos-sensitivity", type=float, default=1.0, help="How much to scale position user inputs") |
43 | | - parser.add_argument("--rot-sensitivity", type=float, default=1.0, help="How much to scale rotation user inputs") |
| 74 | + parser.add_argument( |
| 75 | + "--pos-sensitivity", |
| 76 | + type=float, |
| 77 | + default=1.0, |
| 78 | + help="How much to scale position user inputs", |
| 79 | + ) |
| 80 | + parser.add_argument( |
| 81 | + "--rot-sensitivity", |
| 82 | + type=float, |
| 83 | + default=1.0, |
| 84 | + help="How much to scale rotation user inputs", |
| 85 | + ) |
| 86 | + parser.add_argument( |
| 87 | + "--reverse_xy", |
| 88 | + type=bool, |
| 89 | + default=False, |
| 90 | + 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)", |
| 91 | + ) |
44 | 92 | args = parser.parse_args() |
45 | 93 |
|
46 | 94 | # Get controller config |
|
87 | 135 | if args.device == "keyboard": |
88 | 136 | from robosuite.devices import Keyboard |
89 | 137 |
|
90 | | - device = Keyboard(env=env, pos_sensitivity=args.pos_sensitivity, rot_sensitivity=args.rot_sensitivity) |
| 138 | + device = Keyboard( |
| 139 | + env=env, |
| 140 | + pos_sensitivity=args.pos_sensitivity, |
| 141 | + rot_sensitivity=args.rot_sensitivity, |
| 142 | + ) |
91 | 143 | env.viewer.add_keypress_callback(device.on_press) |
92 | 144 | elif args.device == "spacemouse": |
93 | 145 | from robosuite.devices import SpaceMouse |
94 | 146 |
|
95 | | - device = SpaceMouse(env=env, pos_sensitivity=args.pos_sensitivity, rot_sensitivity=args.rot_sensitivity) |
| 147 | + device = SpaceMouse( |
| 148 | + env=env, |
| 149 | + pos_sensitivity=args.pos_sensitivity, |
| 150 | + rot_sensitivity=args.rot_sensitivity, |
| 151 | + ) |
| 152 | + elif args.device == "dualsense": |
| 153 | + from robosuite.devices import DualSense |
| 154 | + |
| 155 | + device = DualSense( |
| 156 | + env=env, |
| 157 | + pos_sensitivity=args.pos_sensitivity, |
| 158 | + rot_sensitivity=args.rot_sensitivity, |
| 159 | + reverse_xy=args.reverse_xy, |
| 160 | + ) |
96 | 161 | else: |
97 | | - raise Exception("Invalid device choice: choose either 'keyboard' or 'spacemouse'.") |
| 162 | + raise Exception("Invalid device choice: choose either 'keyboard' or 'spacemouse' or 'dualsense'.") |
98 | 163 |
|
99 | 164 | env.reset() |
100 | 165 | cam_id = 0 |
|
0 commit comments