Skip to content

Commit 19b0fa1

Browse files
authored
Merge pull request #251 from RobotControlStack/juelg/teleop-fixes
fix: teleop example
2 parents 3bbf124 + 1dc9846 commit 19b0fa1

File tree

5 files changed

+190
-60
lines changed

5 files changed

+190
-60
lines changed

examples/teleop/quest_iris_dual_arm.py

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
)
1616
from rcs.envs.creators import SimMultiEnvCreator
1717
from rcs.envs.storage_wrapper import StorageWrapper
18-
from rcs.envs.utils import default_sim_gripper_cfg, default_sim_robot_cfg
18+
from rcs.envs.utils import default_digit, default_sim_gripper_cfg, default_sim_robot_cfg
1919
from rcs.utils import SimpleFrameRate
2020
from rcs_fr3.creators import RCSFR3MultiEnvCreator
2121
from rcs_fr3.utils import default_fr3_hw_gripper_cfg, default_fr3_hw_robot_cfg
@@ -25,8 +25,6 @@
2525
from simpub.sim.mj_publisher import MujocoPublisher
2626
from simpub.xr_device.meta_quest3 import MetaQuest3
2727

28-
# from rcs_xarm7.creators import RCSXArm7EnvCreator
29-
3028
logger = logging.getLogger(__name__)
3129

3230
# download the iris apk from the following repo release: https://github.com/intuitive-robots/IRIS-Meta-Quest3
@@ -38,7 +36,7 @@
3836

3937
INCLUDE_ROTATION = True
4038
ROBOT2IP = {
41-
"left": "192.168.102.1",
39+
# "left": "192.168.102.1",
4240
"right": "192.168.101.1",
4341
}
4442

@@ -48,14 +46,20 @@
4846
RECORD_FPS = 30
4947
# set camera dict to none disable cameras
5048
# CAMERA_DICT = {
51-
# "side_right": "244222071045",
49+
# "left_wrist": "230422272017",
50+
# "right_wrist": "230422271040",
51+
# "side": "243522070385",
5252
# "bird_eye": "243522070364",
53-
# "arro": "243522070385",
5453
# }
5554
CAMERA_DICT = None
5655
MQ3_ADDR = "10.42.0.1"
56+
# DIGIT_DICT = {
57+
# "digit_right_left": "D21182",
58+
# "digit_right_right": "D21193"
59+
# }
60+
DIGIT_DICT = None
5761

58-
DATASET_PATH = "test_data_iris_dual_arm"
62+
DATASET_PATH = "test_data_iris_dual_arm14"
5963
INSTRUCTION = "build a tower with the blocks in front of you"
6064

6165

@@ -80,6 +84,7 @@ def __init__(self, env: RelativeActionSpace):
8084

8185
self._resource_lock = threading.Lock()
8286
self._env_lock = threading.Lock()
87+
self._reset_lock = threading.Lock()
8388
self._env = env
8489

8590
self.controller_names = ROBOT2IP.keys() if ROBOT_INSTANCE == RobotPlatform.HARDWARE else ["right"]
@@ -155,11 +160,18 @@ def run(self):
155160

156161
if input_data[self._stop_btn] and (self._prev_data is None or not self._prev_data[self._stop_btn]):
157162
print("reset successful pressed: resetting env")
158-
with self._env_lock:
163+
with self._reset_lock:
159164
# set successful
160165
self._env.get_wrapper_attr("success")()
166+
# sleep to allow to let the robot reach the goal
167+
sleep(1)
161168
# this might also move the robot to the home position
162169
self._env.reset()
170+
for controller in self.controller_names:
171+
self._offset_pose[controller] = Pose()
172+
self._last_controller_pose[controller] = Pose()
173+
self._grp_pos[controller] = 1
174+
continue
163175

164176
# reset unsuccessful
165177
if input_data[self._unsuccessful_btn] and (
@@ -261,25 +273,25 @@ def environment_step_loop(self):
261273
if self._exit_requested:
262274
self._step_env = False
263275
break
264-
transforms, grippers = self.next_action()
265-
actions = {}
266-
for robot, transform in transforms.items():
267-
action = dict(
268-
LimitedTQuatRelDictType(tquat=np.concatenate([transform.translation(), transform.rotation_q()])) # type: ignore
269-
)
276+
with self._reset_lock:
277+
transforms, grippers = self.next_action()
278+
actions = {}
279+
for robot, transform in transforms.items():
280+
action = dict(
281+
LimitedTQuatRelDictType(tquat=np.concatenate([transform.translation(), transform.rotation_q()])) # type: ignore
282+
)
270283

271-
action.update(GripperDictType(gripper=grippers[robot]))
272-
actions[robot] = action
284+
action.update(GripperDictType(gripper=grippers[robot]))
285+
actions[robot] = action
273286

274-
with self._env_lock:
275287
self._env.step(actions)
276288
rate_limiter()
277289

278290

279291
def main():
280292
if ROBOT_INSTANCE == RobotPlatform.HARDWARE:
281293

282-
camera_set = HardwareCameraSet([default_realsense(CAMERA_DICT)]) if CAMERA_DICT is not None else None # type: ignore
294+
camera_set = HardwareCameraSet([default_realsense(CAMERA_DICT), default_digit(DIGIT_DICT)]) if CAMERA_DICT is not None else None # type: ignore
283295
env_rel = RCSFR3MultiEnvCreator()(
284296
name2ip=ROBOT2IP,
285297
camera_set=camera_set,

extensions/rcs_fr3/src/rcs_fr3/envs.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ def _rs2dict(self, state: hw.RobotState):
4040
self._robot_state_keys = [
4141
attr for attr in dir(state) if not attr.startswith("__") and not callable(getattr(state, attr))
4242
]
43+
self._robot_state_keys.remove("robot_mode")
4344
return {key: getattr(state, key) for key in self._robot_state_keys}
4445

4546
def reset(

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ dev = [
5151
"types-requests~=2.31",
5252
# temporarily use fixed version until PR #275 is merged
5353
# pybind11-stubgen==2.5.5
54-
"pybind11-stubgen @ git+https://github.com/juelg/pybind11-stubgen@fix/class-sorting",
54+
"pybind11-stubgen @ git+https://github.com/juelg/pybind11-stubgen@7f6afa59cfb8a485d3e53311be62214fefd96d75",
5555
"pytest==8.1.1",
5656
"commitizen~=3.28.0",
5757
"clang",

python/rcs/__main__.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
from pathlib import Path
2+
from typing import Annotated
3+
4+
import typer
5+
from rcs.envs.storage_wrapper import StorageWrapper
6+
7+
app = typer.Typer()
8+
9+
10+
@app.command()
11+
def consolidate(
12+
path: Annotated[
13+
Path,
14+
typer.Argument(
15+
exists=True,
16+
file_okay=False,
17+
dir_okay=True,
18+
help="The root directory of the parquet dataset to consolidate.",
19+
),
20+
]
21+
):
22+
"""
23+
Consolidates a fragmented Parquet dataset into larger files.
24+
25+
This is useful if the recording process crashed or was interrupted,
26+
leaving many small files behind.
27+
"""
28+
typer.echo(f"Starting consolidation for: {path}")
29+
30+
StorageWrapper.consolidate(str(path), schema=None)
31+
32+
typer.echo("Done.")
33+
34+
35+
if __name__ == "__main__":
36+
app()

0 commit comments

Comments
 (0)