Skip to content

Commit 6103f8e

Browse files
committed
linting: added example and test code, fixed ruff errors
1 parent 78dc791 commit 6103f8e

8 files changed

Lines changed: 11 additions & 23 deletions

File tree

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
PYSRC = python/rcsss
1+
PYSRC = python
22
CPPSRC = src
33
COMPILE_MODE = Release
44

python/examples/env_cartesian_control.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import logging
22

3-
from dotenv import dotenv_values
43
from rcsss.control.fr3_desk import FCI, Desk, DummyResourceManager
54
from rcsss.control.utils import load_creds_fr3_desk
65
from rcsss.envs.base import ControlMode, RelativeTo, RobotInstance

python/examples/env_joint_control.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
import logging
22

3-
import mujoco
43
import numpy as np
5-
import rcsss
6-
from dotenv import dotenv_values
74
from rcsss.control.fr3_desk import FCI, Desk, DummyResourceManager
85
from rcsss.control.utils import load_creds_fr3_desk
96
from rcsss.envs.base import ControlMode, RelativeTo, RobotInstance

python/examples/fr3.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
import logging
22
import sys
3-
from time import sleep
43

54
import numpy as np
65
import rcsss
7-
from dotenv import dotenv_values
86
from rcsss import sim
97
from rcsss._core.hw import FR3Config, IKController
108
from rcsss._core.sim import CameraType
@@ -83,7 +81,7 @@ def main():
8381
"wrist": SimCameraConfig(identifier="eye-in-hand_0", type=int(CameraType.fixed)),
8482
}
8583
cam_cfg = SimCameraSetConfig(cameras=cameras, resolution_width=1280, resolution_height=720, frame_rate=20)
86-
camera_set = SimCameraSet(simulation, cam_cfg)
84+
camera_set = SimCameraSet(simulation, cam_cfg) # noqa: F841
8785
simulation.open_gui()
8886

8987
else:

python/examples/grasp_demo.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import mujoco
55
import numpy as np
66
from rcsss._core.common import Pose
7-
from rcsss._core.sim import FR3State
87
from rcsss.envs.base import GripperWrapper
98

109
logger = logging.getLogger(__name__)
@@ -34,9 +33,7 @@ def generate_waypoints(self, start_pose: Pose, end_pose: Pose, num_waypoints: in
3433
return waypoints
3534

3635
def step(self, action: np.ndarray) -> dict:
37-
re = self.env.step(action)
38-
s: FR3State = self.env.unwrapped.robot.get_state()
39-
return re[0]
36+
return self.env.step(action)[0]
4037

4138
def plan_linear_motion(self, geom_name: str, delta_up: float, num_waypoints: int = 20) -> list[Pose]:
4239
end_eff_pose = self.env.unwrapped.robot.get_cartesian_position()
@@ -47,8 +44,7 @@ def plan_linear_motion(self, geom_name: str, delta_up: float, num_waypoints: int
4744
# this does not work if the object is flipped
4845
goal_pose *= Pose(translation=[0, 0, delta_up], quaternion=[1, 0, 0, 0])
4946

50-
waypoints = self.generate_waypoints(end_eff_pose, goal_pose, num_waypoints=num_waypoints)
51-
return waypoints
47+
return self.generate_waypoints(end_eff_pose, goal_pose, num_waypoints=num_waypoints)
5248

5349
def execute_motion(self, waypoints: list[Pose], gripper: float = GripperWrapper.BINARY_GRIPPER_OPEN) -> dict:
5450
for i in range(1, len(waypoints)):

python/tests/test_common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class TestPose:
1010
This class tests the methods of the Pose class and its multiple constructors.
1111
"""
1212

13-
@pytest.fixture
13+
@pytest.fixture()
1414
def identity_pose(self):
1515
"""This fixture can be reused wherever if no transformation pose is needed"""
1616
return common.Pose()

python/tests/test_envs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class Composed(AdvancedNestedSpaceWithLambda, SimpleSpace): ...
7777
class TestGetSpace:
7878

7979
def test_simple_space(self):
80-
get_space(SimpleSpace) == gym.spaces.Dict(
80+
assert get_space(SimpleSpace) == gym.spaces.Dict(
8181
{
8282
"my_int": gym.spaces.Discrete(1),
8383
"my_float": gym.spaces.Box(low=0, high=1, shape=(1,), dtype=np.float32),
@@ -196,4 +196,4 @@ def test_composed_space(self):
196196
)
197197

198198
def test_get_space_keys(self):
199-
get_space_keys(SimpleSpace) == {"my_int", "my_float"}
199+
assert set(get_space_keys(SimpleSpace)) == {"my_int", "my_float"}

python/tests/test_sim_envs.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from collections import OrderedDict
21
import numpy as np
32
import pytest
43
import rcsss
@@ -7,23 +6,22 @@
76
default_fr3_sim_robot_cfg,
87
default_mujoco_cameraset_cfg,
98
fr3_sim_env,
10-
get_urdf_path,
119
)
1210

1311
from rcsss.envs.base import ControlMode, TRPYDictType, GripperDictType, TQuartDictType, JointsDictType
1412

1513

16-
@pytest.fixture
14+
@pytest.fixture()
1715
def cfg():
1816
return default_fr3_sim_robot_cfg()
1917

2018

21-
@pytest.fixture
19+
@pytest.fixture()
2220
def gripper_cfg():
2321
return default_fr3_sim_gripper_cfg()
2422

2523

26-
@pytest.fixture
24+
@pytest.fixture()
2725
def cam_cfg():
2826
return default_mujoco_cameraset_cfg()
2927

@@ -203,7 +201,7 @@ def test_relative_zero_action_tquart(self, cfg, gripper_cfg, cam_cfg):
203201
ControlMode.CARTESIAN_TQuart,
204202
cfg,
205203
gripper_cfg=gripper_cfg,
206-
camera_set_cfg=None,
204+
camera_set_cfg=cam_cfg,
207205
max_relative_movement=0.5,
208206
)
209207
obs_initial, _ = env_rel.reset()

0 commit comments

Comments
 (0)