Skip to content

Commit 2291e25

Browse files
authored
Merge pull request #150 from utn-mi/juelg/collision-guard-visualization-gui
collision guard visualization gui
2 parents 254a758 + 8ee3449 commit 2291e25

3 files changed

Lines changed: 16 additions & 23 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ pip install -r requirements_dev.txt
1616
```
1717
3. Build and install RCS:
1818
```shell
19-
pip install .
19+
pip install -ve .
2020
```
2121

2222
### UTN Models
2323
If you have a token to download the UTN models, you can add them to the pip package using:
2424
```shell
25-
pip install --config-settings=cmake.define.INCLUDE_UTN_MODELS=ON --config-settings=cmake.define.GITLAB_MODELS_TOKEN=<token> .
25+
pip install --config-settings=cmake.define.INCLUDE_UTN_MODELS=ON --config-settings=cmake.define.GITLAB_MODELS_TOKEN=<token> -ve .
2626
```
2727

2828
## Usage

python/rcsss/envs/factories.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,9 @@ def fr3_hw_env(
129129
urdf_path,
130130
gripper=True,
131131
check_home_collision=False,
132-
camera=True,
133132
control_mode=control_mode,
134133
tcp_offset=rcsss.common.Pose(rcsss.common.FrankaHandTCPOffset()),
134+
sim_gui=True,
135135
)
136136
if max_relative_movement is not None:
137137
env = RelativeActionSpace(env, max_mov=max_relative_movement, relative_to=relative_to)
@@ -222,9 +222,9 @@ def fr3_sim_env(
222222
urdf_path,
223223
gripper=gripper_cfg is not None,
224224
check_home_collision=False,
225-
camera=False,
226225
control_mode=control_mode,
227226
tcp_offset=rcsss.common.Pose(rcsss.common.FrankaHandTCPOffset()),
227+
sim_gui=True,
228228
)
229229
if max_relative_movement is not None:
230230
env = RelativeActionSpace(env, max_mov=max_relative_movement, relative_to=relative_to)

python/rcsss/envs/sim.py

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44
import gymnasium as gym
55
import rcsss
66
from rcsss import sim
7-
from rcsss._core.sim import CameraType
8-
from rcsss.camera.sim import SimCameraConfig, SimCameraSet, SimCameraSetConfig
9-
from rcsss.envs.base import CameraSetWrapper, ControlMode, FR3Env, GripperWrapper
7+
from rcsss.envs.base import ControlMode, FR3Env, GripperWrapper
108

119

1210
class FR3Sim(gym.Wrapper):
@@ -50,6 +48,7 @@ def __init__(
5048
collision_env: gym.Env,
5149
check_home_collision: bool = True,
5250
to_joint_control: bool = False,
51+
sim_gui: bool = True,
5352
):
5453
super().__init__(env)
5554
self.unwrapped: FR3Env
@@ -65,6 +64,8 @@ def __init__(
6564
), "Previous control mode must be joints"
6665
# change action space
6766
self.action_space = self.collision_env.action_space
67+
if sim_gui:
68+
self.sim.open_gui()
6869

6970
def step(self, action: dict[str, Any]) -> tuple[dict[str, Any], SupportsFloat, bool, bool, dict[str, Any]]:
7071
# TODO: we should set the state of the sim to the state of the real robot
@@ -112,12 +113,12 @@ def env_from_xml_paths(
112113
env: gym.Env,
113114
mjmld: str,
114115
urdf: str,
115-
id="0",
116-
gripper=True,
117-
check_home_collision=True,
118-
tcp_offset=None,
116+
id: str = "0",
117+
gripper: bool = True,
118+
check_home_collision: bool = True,
119+
tcp_offset: rcsss.common.Pose | None = None,
119120
control_mode: ControlMode | None = None,
120-
camera=False,
121+
sim_gui: bool = True,
121122
) -> "CollisionGuard":
122123
assert isinstance(env.unwrapped, FR3Env)
123124
simulation = sim.Sim(mjmld)
@@ -142,14 +143,6 @@ def env_from_xml_paths(
142143
c_env = FR3Sim(c_env, simulation)
143144
if gripper:
144145
gripper_cfg = sim.FHConfig()
145-
gripper = sim.FrankaHand(simulation, "0", gripper_cfg)
146-
c_env = GripperWrapper(c_env, gripper)
147-
if camera:
148-
cameras = {
149-
"wrist": SimCameraConfig(identifier="eye-in-hand_0", type=int(CameraType.fixed)),
150-
"default_free": SimCameraConfig(identifier="", type=int(CameraType.default_free)),
151-
}
152-
cam_cfg = SimCameraSetConfig(cameras=cameras, resolution_width=640, resolution_height=480, frame_rate=5)
153-
camera_set = SimCameraSet(simulation, cam_cfg)
154-
c_env = CameraSetWrapper(c_env, camera_set)
155-
return cls(env, simulation, c_env, check_home_collision, to_joint_control)
146+
fh = sim.FrankaHand(simulation, id, gripper_cfg)
147+
c_env = GripperWrapper(c_env, fh)
148+
return cls(env, simulation, c_env, check_home_collision, to_joint_control, sim_gui)

0 commit comments

Comments
 (0)