def test_recording():
env = RobotEnv(
recording_enabled=True
)
env.reset()
# Run the simulation for a few timesteps
for _ in range(10):
action = env.action_space.sample() # replace with your action sampling logic
env.step(action)
# Save the recording
env.reset()
# Check that the file was created
filename = max(
os.listdir('recordings'), key=lambda x: os.path.getctime(os.path.join('recordings', x)))
assert os.path.exists(os.path.join('recordings', filename))
# Load the recording
with open(os.path.join('recordings', filename), 'rb') as f:
recorded_states = pickle.load(f)
# Check that the recording has the correct length
assert len(recorded_states) == 10
E assert 2 == 10
E + where 2 = len(([VisualizableSimState(timestep=1, action=VisualizableAction(robot_pose=((92.46019724926325, 180.30430294205246), -1.5...e=((61.25, 33.69), (61.25, 40.69), (69.12, 40.69)), goal_zone=((309.31, 176.75), (309.31, 182.0), (314.56, 182.0)))]})))
tests/test_recording.py:30: AssertionError
----------------------------- Captured stderr call -----------------------------
2024-06-04 09:05:18.670 | WARNING | robot_sf.gym_env.robot_env:save_recording:253 - No states recorded, skipping save
2024-06-04 09:05:18.757 | INFO | robot_sf.gym_env.robot_env:save_recording:261 - Recording saved to recordings/2024-06-04_09-05-18.pkl
2024-06-04 09:05:18.757 | INFO | robot_sf.gym_env.robot_env:save_recording:262 - Reset state list
=============================== warnings summary ===============================
tests/sb3_test.py::test_can_load_model_snapshot
/opt/hostedtoolcache/Python/3.10.14/x64/lib/python3.10/site-packages/stable_baselines3/common/save_util.py:283: UserWarning: Path 'temp' does not exist. Will create it.
warnings.warn(f"Path '{path.parent}' does not exist. Will create it.")
=================================== FAILURES =================================== ____ test_recording ____
tests/test_recording.py:30: AssertionError ----------------------------- Captured stderr call ----------------------------- 2024-06-04 09:05:18.670 | WARNING | robot_sf.gym_env.robot_env:save_recording:253 - No states recorded, skipping save 2024-06-04 09:05:18.757 | INFO | robot_sf.gym_env.robot_env:save_recording:261 - Recording saved to recordings/2024-06-04_09-05-18.pkl 2024-06-04 09:05:18.757 | INFO | robot_sf.gym_env.robot_env:save_recording:262 - Reset state list =============================== warnings summary =============================== tests/sb3_test.py::test_can_load_model_snapshot /opt/hostedtoolcache/Python/3.10.14/x64/lib/python3.10/site-packages/stable_baselines3/common/save_util.py:283: UserWarning: Path 'temp' does not exist. Will create it. warnings.warn(f"Path '{path.parent}' does not exist. Will create it.")
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html =========================== short test summary info ============================ FAILED tests/test_recording.py::test_recording - assert 2 == 10