Skip to content

Commit 57e5d3b

Browse files
Merge pull request #645 from OceanPresentChao/dualsense
feat: Dualsense device support
2 parents 670f2a8 + 4b18edf commit 57e5d3b

15 files changed

Lines changed: 944 additions & 58 deletions

docs/algorithms/demonstrations.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
## Collecting Human Demonstrations
44

5-
We provide teleoperation utilities that allow users to control the robots with input devices, such as the keyboard, [SpaceMouse](https://www.3dconnexion.com/spacemouse_compact/en/) and mujoco-gui. Such functionality allows us to collect a dataset of human demonstrations for learning. We provide an example script to illustrate how to collect demonstrations. Our [collect_human_demonstrations](https://github.com/ARISE-Initiative/robosuite/blob/master/robosuite/scripts/collect_human_demonstrations.py) script takes the following arguments:
5+
We provide teleoperation utilities that allow users to control the robots with input devices, such as the keyboard, [SpaceMouse](https://www.3dconnexion.com/spacemouse_compact/en/), [DualSense](https://www.playstation.com/en-us/accessories/dualsense-wireless-controller/) and mujoco-gui. Such functionality allows us to collect a dataset of human demonstrations for learning. We provide an example script to illustrate how to collect demonstrations. Our [collect_human_demonstrations](https://github.com/ARISE-Initiative/robosuite/blob/master/robosuite/scripts/collect_human_demonstrations.py) script takes the following arguments:
66

77
- `directory:` path to a folder for where to store the pickle file of collected demonstrations
88
- `environment:` name of the environment you would like to collect the demonstrations for
9-
- `device:` either "keyboard" or "spacemouse" or "mjgui"
9+
- `device:` either "keyboard" or "spacemouse" or "dualsense" or "mjgui"
1010

1111
See the [devices page](https://robosuite.ai/docs/modules/devices.html) for details on how to use the devices.
1212

docs/conf.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,12 +185,21 @@
185185
# (source start file, target name, title, author,
186186
# dir menu entry, description, category)
187187
texinfo_documents = [
188-
(master_doc, "robosuite", "robosuite Documentation", author, "robosuite", "ARISE", "Miscellaneous"),
188+
(
189+
master_doc,
190+
"robosuite",
191+
"robosuite Documentation",
192+
author,
193+
"robosuite",
194+
"ARISE",
195+
"Miscellaneous",
196+
),
189197
]
190198

191199
autodoc_mock_imports = [
192200
"robosuite.devices.mjgui",
193201
"robosuite.devices.spacemouse",
202+
"robosuite.devices.dualsense",
194203
"robosuite.devices.keyboard",
195204
"robosuite.devices.device",
196205
]

docs/demos.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,12 @@ The `demo_device_control.py` scripts shows how to teleoperate robot with [contro
121121
This current implementation only supports macOS (Linux support can be added).
122122
Download and install the [driver](https://www.3dconnexion.com/service/drivers.html) before running the script.
123123
124+
* **DualSense**
125+
We use the DualSense joystick from [DualSense](https://www.playstation.com/en-us/accessories/dualsense-wireless-controller/) to control the end-effector of the robot. The joystick provides 6-DoF control commands.
126+
127+
**Note:**
128+
Make sure `hidapi` can detect your DualSense in your computer. In Linux, you may add udev rules in `/etc/udev/rules.d` to get access to the device without root privilege. For the rules content you can refer to [game-device-udev](https://codeberg.org/fabiscafe/game-devices-udev).
129+
124130
* **Mujoco GUI**
125131
The Mujoco GUI provides a graphical user interface for viewing and interacting with a mujoco simulation. We use the GUI and a mouse to drag and drop mocap bodies, whose
126132
poses are tracked by a controller. More specifically, once the mujoco GUI is loaded from running `python demo_device_control.py`, you first need to hit the <Tab> key to reach the interactive mujoco viewer state. Then, you should double click on

docs/installation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ The base installation requires the MuJoCo physics engine (with [mujoco](https://
3737
```
3838
This will also install our library as an editable package, such that local changes will be reflected elsewhere without having to reinstall the package.
3939

40-
3. (Optional) We also provide add-on functionalities, such as [OpenAI Gym](https://github.com/openai/gym) [interfaces](source/robosuite.wrappers), [inverse kinematics controllers](source/robosuite.controllers) powered by [PyBullet](http://bulletphysics.org), and [teleoperation](source/robosuite.devices) with [SpaceMouse](https://www.3dconnexion.com/products/spacemouse.html) devices. To enable these additional features, please install the extra dependencies by running
40+
3. (Optional) We also provide add-on functionalities, such as [OpenAI Gym](https://github.com/openai/gym) [interfaces](source/robosuite.wrappers), [inverse kinematics controllers](source/robosuite.controllers) powered by [PyBullet](http://bulletphysics.org), and [teleoperation](source/robosuite.devices) with [SpaceMouse](https://www.3dconnexion.com/products/spacemouse.html) and [DualSense](https://www.playstation.com/en-us/accessories/dualsense-wireless-controller/) devices. To enable these additional features, please install the extra dependencies by running
4141
```sh
4242
$ pip3 install -r requirements-extra.txt
4343
```

docs/modules/devices.md

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# I/O Devices
22

3-
Devices are used to read user input and teleoperate simulated robots in real-time. This is achieved by either using a keyboard or a [SpaceMouse](https://www.3dconnexion.com/spacemouse_compact/en/), and whose teleoperation capabilities can be demonstrated with the [demo_device_control.py](../demos.html#teleoperation) script. More generally, we support any interface that implements the [Device](../simulation/device) abstract base class. In order to support your own custom device, simply subclass this base class and implement the required methods.
3+
Devices are used to read user input and teleoperate simulated robots in real-time. This is achieved by either using a keyboard, a [SpaceMouse](https://www.3dconnexion.com/spacemouse_compact/en/) or a [DualSense](https://www.playstation.com/en-us/accessories/dualsense-wireless-controller/) joystick, and whose teleoperation capabilities can be demonstrated with the [demo_device_control.py](../demos.html#teleoperation) script. More generally, we support any interface that implements the [Device](../simulation/device) abstract base class. In order to support your own custom device, simply subclass this base class and implement the required methods.
44

55
## Keyboard
66

@@ -19,10 +19,10 @@ Note that the rendering window must be active for these commands to work.
1919
| o-p | rotate (yaw) |
2020
| y-h | rotate (pitch) |
2121
| e-r | rotate (roll) |
22-
| b | toggle arm/base mode (if appli cable) |
22+
| b | toggle arm/base mode (if applicable) |
2323
| s | switch active arm (if multi-armed robot) |
2424
| = | switch active robot (if multi-robot env) |
25-
| ESC | quit |
25+
| Ctrl+C | quit |
2626

2727

2828
## 3Dconnexion SpaceMouse
@@ -38,8 +38,29 @@ We support the use of a [SpaceMouse](https://www.3dconnexion.com/spacemouse_comp
3838
| Move mouse laterally | move arm horizontally in x-y plane |
3939
| Move mouse vertically | move arm vertically |
4040
| Twist mouse about an axis | rotate arm about a corresponding axis |
41-
| ESC (keyboard) | quit |
42-
41+
| b | toggle arm/base mode (if applicable) |
42+
| s | switch active arm (if multi-armed robot) |
43+
| = | switch active robot (if multi-robot environment) |
44+
| Ctrl+C (keyboard) | quit |
45+
46+
## Sony DualSense
47+
48+
we support the use of a [Sony DualSense](https://www.playstation.com/en-us/accessories/dualsense-wireless-controller/) as well.
49+
50+
**Sony DualSense controls**
51+
52+
| Control | Command |
53+
| :--------------------------- | :------------------------------------ |
54+
| Square button | reset simulation |
55+
| Circle button (hold) | close gripper |
56+
| Move LX/LY Stick | move arm horizontally in x-y plane |
57+
| Press L2 Trigger with or without L1 button | move arm vertically |
58+
| Move RX/RY Stick | rotate arm about x/y axis (roll/pitch) |
59+
| Press R2 Trigger with or without R1 button | rotate arm about z axis (yaw) |
60+
| Triangle button | toggle arm/base mode (if applicable) |
61+
| Left/Right Direction Pad | switch active arm (if multi-armed robot) |
62+
| Up/Down Direction Pad | switch active robot (if multi-robot environment) |
63+
| Ctrl+C (keyboard) | quit |
4364

4465
## Mujoco GUI Device
4566

docs/overview.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ This framework was originally developed in late 2017 by researchers in [Stanford
1818
* **standardized tasks**: a set of standardized manipulation tasks of large diversity and varying complexity and RL benchmarking results for reproducible research;
1919
* **procedural generation**: modular APIs for programmatically creating new environments and new tasks as combinations of robot models, arenas, and parameterized 3D objects. Check out our repo [robosuite_models](https://github.com/ARISE-Initiative/robosuite_models) for extra robot models tailored to robosuite.
2020
* **robot controllers**: a selection of controller types to command the robots, such as joint-space velocity control, inverse kinematics control, operational space control, and whole body control;
21-
* **teleoperation devices**: a selection of teleoperation devices including keyboard, spacemouse and MuJoCo viewer drag-drop;
21+
* **teleoperation devices**: a selection of teleoperation devices including keyboard, spacemouse, dualsense and MuJoCo viewer drag-drop;
2222
* **multi-modal sensors**: heterogeneous types of sensory signals, including low-level physical states, RGB cameras, depth maps, and proprioception;
2323
* **human demonstrations**: utilities for collecting human demonstrations, replaying demonstration datasets, and leveraging demonstration data for learning. Check out our sister project [robomimic](https://arise-initiative.github.io/robomimic-web/);
2424
* **photorealistic rendering**: integration with advanced graphics tools that provide real-time photorealistic renderings of simulated scenes, including support for NVIDIA Isaac Sim rendering.

docs/simulation/device.rst

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Device
22
======
33

4-
Devices allow for direct real-time interfacing with the MuJoCo simulation. The currently supported devices are ``Keyboard``. ``SpaceMouse`` and ``MjGUI``.
4+
Devices allow for direct real-time interfacing with the MuJoCo simulation. The currently supported devices are ``Keyboard``. ``SpaceMouse``. ``DualSense`` and ``MjGUI``.
55

66
Base Device
77
-----------
@@ -34,6 +34,18 @@ SpaceMouse Device
3434
.. automethod:: control_gripper
3535
.. automethod:: _display_controls
3636

37+
DualSense Device
38+
-----------------
39+
40+
.. autoclass:: robosuite.devices.dualsense.DualSense
41+
42+
.. automethod:: get_controller_state
43+
.. automethod:: run
44+
.. automethod:: control
45+
.. automethod:: control_gripper
46+
.. automethod:: _display_controls
47+
.. automethod:: _check_connection_type
48+
3749
MjGUI Device
3850
------------
3951
.. autoclass:: robosuite.devices.mjgui.MJGUI

docs/source/robosuite.devices.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@ robosuite.devices.device module
1212
:undoc-members:
1313
:show-inheritance:
1414

15+
robosuite.devices.dualsense module
16+
----------------------------------
17+
18+
.. automodule:: robosuite.devices.dualsense
19+
:members:
20+
:undoc-members:
21+
:show-inheritance:
22+
1523
robosuite.devices.keyboard module
1624
---------------------------------
1725

robosuite/demos/demo_device_control.py

Lines changed: 65 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -99,31 +99,68 @@
9999
from robosuite.wrappers import VisualizationWrapper
100100

101101
if __name__ == "__main__":
102-
103102
parser = argparse.ArgumentParser()
104103
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")
106104
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",
108132
)
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")
112133
parser.add_argument(
113134
"--controller",
114135
type=str,
115136
default=None,
116137
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",
117138
)
118139
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+
)
121152
parser.add_argument(
122153
"--max_fr",
123154
default=20,
124155
type=int,
125156
help="Sleep when simluation runs faster than specified frame rate; 20 fps is real time.",
126157
)
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+
)
127164
args = parser.parse_args()
128165

129166
# Get controller config
@@ -168,18 +205,35 @@
168205
if args.device == "keyboard":
169206
from robosuite.devices import Keyboard
170207

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+
)
172213
env.viewer.add_keypress_callback(device.on_press)
173214
elif args.device == "spacemouse":
174215
from robosuite.devices import SpaceMouse
175216

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+
)
177231
elif args.device == "mjgui":
178232
from robosuite.devices.mjgui import MJGUI
179233

180234
device = MJGUI(env=env)
181235
else:
182-
raise Exception("Invalid device choice: choose either 'keyboard' or 'spacemouse'.")
236+
raise Exception("Invalid device choice: choose either 'keyboard', 'dualsene' or 'spacemouse'.")
183237

184238
while True:
185239
# Reset the environment

0 commit comments

Comments
 (0)