Skip to content

Commit 1e34097

Browse files
committed
test: remove collision guard
1 parent 59450a0 commit 1e34097

1 file changed

Lines changed: 77 additions & 82 deletions

File tree

python/tests/test_sim_envs.py

Lines changed: 77 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
1-
from typing import cast
2-
31
import numpy as np
42
import pytest
53
from rcs.envs.base import (
64
ControlMode,
75
GripperDictType,
86
JointsDictType,
9-
RobotEnv,
107
TQuatDictType,
118
TRPYDictType,
129
)
@@ -40,7 +37,6 @@ class TestSimEnvs:
4037

4138
def assert_no_pose_change(self, info: dict, initial_obs: dict, final_obs: dict):
4239
assert info["ik_success"]
43-
assert info["is_sim_converged"]
4440
out_pose = rcs.common.Pose(
4541
translation=np.array(final_obs["tquat"][:3]), quaternion=np.array(final_obs["tquat"][3:])
4642
)
@@ -51,7 +47,6 @@ def assert_no_pose_change(self, info: dict, initial_obs: dict, final_obs: dict):
5147

5248
def assert_collision(self, info: dict):
5349
assert info["ik_success"]
54-
assert info["is_sim_converged"]
5550
assert info["collision"]
5651

5752

@@ -155,32 +150,32 @@ def test_collision_trpy(self, cfg, gripper_cfg):
155150
obs, _, _, _, info = env.step(collision_action)
156151
self.assert_collision(info)
157152

158-
def test_collision_guard_trpy(self, cfg, gripper_cfg):
159-
"""
160-
Check that an obvious collision is detected by the CollisionGuard
161-
"""
162-
# env creation
163-
env = SimEnvCreator()(
164-
ControlMode.CARTESIAN_TRPY,
165-
cfg,
166-
gripper_cfg=gripper_cfg,
167-
collision_guard=True,
168-
cameras=None,
169-
max_relative_movement=None,
170-
)
171-
obs, _ = env.reset()
172-
unwrapped = cast(RobotEnv, env.unwrapped)
173-
p1: np.ndarray = unwrapped.robot.get_joint_position()
174-
# an obvious below ground collision action
175-
obs["xyzrpy"][0] = 0.4
176-
obs["xyzrpy"][2] = -0.05
177-
collision_action = TRPYDictType(xyzrpy=obs["xyzrpy"])
178-
collision_action.update(GripperDictType(gripper=0))
179-
_, _, _, _, info = env.step(collision_action)
180-
p2: np.ndarray = unwrapped.robot.get_joint_position()
181-
self.assert_collision(info)
182-
# assure that the robot did not move
183-
assert np.allclose(p1, p2)
153+
# def test_collision_guard_trpy(self, cfg, gripper_cfg):
154+
# """
155+
# Check that an obvious collision is detected by the CollisionGuard
156+
# """
157+
# # env creation
158+
# env = SimEnvCreator()(
159+
# ControlMode.CARTESIAN_TRPY,
160+
# cfg,
161+
# gripper_cfg=gripper_cfg,
162+
# collision_guard=True,
163+
# cameras=None,
164+
# max_relative_movement=None,
165+
# )
166+
# obs, _ = env.reset()
167+
# unwrapped = cast(RobotEnv, env.unwrapped)
168+
# p1: np.ndarray = unwrapped.robot.get_joint_position()
169+
# # an obvious below ground collision action
170+
# obs["xyzrpy"][0] = 0.4
171+
# obs["xyzrpy"][2] = -0.05
172+
# collision_action = TRPYDictType(xyzrpy=obs["xyzrpy"])
173+
# collision_action.update(GripperDictType(gripper=0))
174+
# _, _, _, _, info = env.step(collision_action)
175+
# p2: np.ndarray = unwrapped.robot.get_joint_position()
176+
# self.assert_collision(info)
177+
# # assure that the robot did not move
178+
# assert np.allclose(p1, p2)
184179

185180

186181
class TestSimEnvsTquat(TestSimEnvs):
@@ -275,32 +270,32 @@ def test_collision_tquat(self, cfg, gripper_cfg):
275270
_, _, _, _, info = env.step(collision_action)
276271
self.assert_collision(info)
277272

278-
def test_collision_guard_tquat(self, cfg, gripper_cfg):
279-
"""
280-
Check that an obvious collision is detected by the CollisionGuard
281-
"""
282-
# env creation
283-
env = SimEnvCreator()(
284-
ControlMode.CARTESIAN_TQuat,
285-
cfg,
286-
gripper_cfg=gripper_cfg,
287-
collision_guard=True,
288-
cameras=None,
289-
max_relative_movement=None,
290-
)
291-
obs, _ = env.reset()
292-
unwrapped = cast(RobotEnv, env.unwrapped)
293-
p1: np.ndarray = unwrapped.robot.get_joint_position()
294-
# an obvious below ground collision action
295-
obs["tquat"][0] = 0.4
296-
obs["tquat"][2] = -0.05
297-
collision_action = TQuatDictType(tquat=obs["tquat"])
298-
collision_action.update(GripperDictType(gripper=0))
299-
_, _, _, _, info = env.step(collision_action)
300-
p2: np.ndarray = unwrapped.robot.get_joint_position()
301-
self.assert_collision(info)
302-
# assure that the robot did not move
303-
assert np.allclose(p1, p2)
273+
# def test_collision_guard_tquat(self, cfg, gripper_cfg):
274+
# """
275+
# Check that an obvious collision is detected by the CollisionGuard
276+
# """
277+
# # env creation
278+
# env = SimEnvCreator()(
279+
# ControlMode.CARTESIAN_TQuat,
280+
# cfg,
281+
# gripper_cfg=gripper_cfg,
282+
# collision_guard=True,
283+
# cameras=None,
284+
# max_relative_movement=None,
285+
# )
286+
# obs, _ = env.reset()
287+
# unwrapped = cast(RobotEnv, env.unwrapped)
288+
# p1: np.ndarray = unwrapped.robot.get_joint_position()
289+
# # an obvious below ground collision action
290+
# obs["tquat"][0] = 0.4
291+
# obs["tquat"][2] = -0.05
292+
# collision_action = TQuatDictType(tquat=obs["tquat"])
293+
# collision_action.update(GripperDictType(gripper=0))
294+
# _, _, _, _, info = env.step(collision_action)
295+
# p2: np.ndarray = unwrapped.robot.get_joint_position()
296+
# self.assert_collision(info)
297+
# # assure that the robot did not move
298+
# assert np.allclose(p1, p2)
304299

305300

306301
class TestSimEnvsJoints(TestSimEnvs):
@@ -364,31 +359,31 @@ def test_collision_joints(self, cfg, gripper_cfg):
364359
_, _, _, _, info = env.step(collision_act)
365360
self.assert_collision(info)
366361

367-
def test_collision_guard_joints(self, cfg, gripper_cfg):
368-
"""
369-
Check that an obvious collision is detected by sim
370-
"""
371-
# env creation
372-
env = SimEnvCreator()(
373-
ControlMode.JOINTS,
374-
cfg,
375-
gripper_cfg=gripper_cfg,
376-
collision_guard=True,
377-
cameras=None,
378-
max_relative_movement=None,
379-
)
380-
env.reset()
381-
unwrapped = cast(RobotEnv, env.unwrapped)
382-
p1: np.ndarray = unwrapped.robot.get_joint_position()
383-
# the below action is a test_case where there is an obvious collision regardless of the gripper action
384-
collision_act = JointsDictType(joints=np.array([0, 1.78, 0, -1.45, 0, 0, 0], dtype=np.float32))
385-
collision_act.update(GripperDictType(gripper=1))
386-
_, _, _, _, info = env.step(collision_act)
387-
p2: np.ndarray = unwrapped.robot.get_joint_position()
388-
389-
self.assert_collision(info)
390-
# assure that the robot did not move
391-
assert np.allclose(p1, p2)
362+
# def test_collision_guard_joints(self, cfg, gripper_cfg):
363+
# """
364+
# Check that an obvious collision is detected by sim
365+
# """
366+
# # env creation
367+
# env = SimEnvCreator()(
368+
# ControlMode.JOINTS,
369+
# cfg,
370+
# gripper_cfg=gripper_cfg,
371+
# collision_guard=True,
372+
# cameras=None,
373+
# max_relative_movement=None,
374+
# )
375+
# env.reset()
376+
# unwrapped = cast(RobotEnv, env.unwrapped)
377+
# p1: np.ndarray = unwrapped.robot.get_joint_position()
378+
# # the below action is a test_case where there is an obvious collision regardless of the gripper action
379+
# collision_act = JointsDictType(joints=np.array([0, 1.78, 0, -1.45, 0, 0, 0], dtype=np.float32))
380+
# collision_act.update(GripperDictType(gripper=1))
381+
# _, _, _, _, info = env.step(collision_act)
382+
# p2: np.ndarray = unwrapped.robot.get_joint_position()
383+
384+
# self.assert_collision(info)
385+
# # assure that the robot did not move
386+
# assert np.allclose(p1, p2)
392387

393388
def test_relative_zero_action_joints(self, cfg, gripper_cfg):
394389
"""

0 commit comments

Comments
 (0)