ScheiklP / sofa_zoo

Reinforcement learning scripts for sofa_env environments.
MIT License
5 stars 5 forks source link

Precision Cutting TypeError #11

Closed KantaphatLeelakunwet closed 3 weeks ago

KantaphatLeelakunwet commented 2 months ago

When I tried to run ppo.py for precision cutting, I encountered a TypeError.

[ERROR]   [PythonScript] TypeError: 'tuple' object does not support item assignment
  File "/bd_targaryen/users/kleelakunwet/sofa_zoo/sofa_zoo/envs/precision_cutting/ppo.py", line 136, in <module>
    model.learn(
  File "/bd_targaryen/users/kleelakunwet/miniconda3/envs/sofa/lib/python3.9/site-packages/stable_baselines3/ppo/ppo.py", line 315, in learn
    return super().learn(
  File "/bd_targaryen/users/kleelakunwet/miniconda3/envs/sofa/lib/python3.9/site-packages/stable_baselines3/common/on_policy_algorithm.py", line 277, in learn
    continue_training = self.collect_rollouts(self.env, callback, self.rollout_buffer, n_rollout_steps=self.n_steps)
  File "/bd_targaryen/users/kleelakunwet/miniconda3/envs/sofa/lib/python3.9/site-packages/stable_baselines3/common/on_policy_algorithm.py", line 194, in collect_rollouts
    new_obs, rewards, dones, infos = env.step(clipped_actions)
  File "/bd_targaryen/users/kleelakunwet/miniconda3/envs/sofa/lib/python3.9/site-packages/stable_baselines3/common/vec_env/base_vec_env.py", line 206, in step
    return self.step_wait()
  File "/bd_targaryen/users/kleelakunwet/miniconda3/envs/sofa/lib/python3.9/site-packages/stable_baselines3/common/vec_env/vec_frame_stack.py", line 33, in step_wait
    observations, rewards, dones, infos = self.venv.step_wait()
  File "/bd_targaryen/users/kleelakunwet/miniconda3/envs/sofa/lib/python3.9/site-packages/stable_baselines3/common/vec_env/vec_normalize.py", line 181, in step_wait
    obs, rewards, dones, infos = self.venv.step_wait()
  File "/bd_targaryen/users/kleelakunwet/miniconda3/envs/sofa/lib/python3.9/site-packages/stable_baselines3/common/vec_env/vec_video_recorder.py", line 88, in step_wait
    obs, rews, dones, infos = self.venv.step_wait()
  File "/bd_targaryen/users/kleelakunwet/miniconda3/envs/sofa/lib/python3.9/site-packages/stable_baselines3/common/vec_env/vec_monitor.py", line 76, in step_wait
    obs, rewards, dones, infos = self.venv.step_wait()
  File "/bd_targaryen/users/kleelakunwet/sofa_zoo/sofa_zoo/common/reset_process_vec_env.py", line 110, in step_wait
    obs[i], self.reset_infos[i] = remote.recv()  # collect reset observation

I think the reason might come from the return of zip function to self.reset_infos since the return is the iteration of tuple, which is immutable. The error occurred at line 110 in /sofa_zoo/sofa_zoo/common/reset_process_vec_env.py

image

Do you know any other cause of this problem? Thank you in advance!

KantaphatLeelakunwet commented 2 months ago

There are also a bunch of other error like invalid triangleS2D size, and pointS2D size.

image
ScheiklP commented 2 months ago

Hi @KantaphatLeelakunwet , i fixed that bug in this commit https://github.com/ScheiklP/sofa_zoo/commit/708c8f29afb45c3d22c49dd90ffe5afc0178369a. Could you update your local repository and try again? :)

Cheers, Paul

KantaphatLeelakunwet commented 1 month ago

Hi, @ScheiklP Thanks a lot! What about the ERROR of Invalid triangleS2D size and others? Or the ERROR doesn't harm anything?

ScheiklP commented 1 month ago

Hi @KantaphatLeelakunwet , I have not seen this error before. Could you give me some more information about your setup? What are your github commits of

Cheers, Paul

KantaphatLeelakunwet commented 1 month ago

@ScheiklP , Is there any command to check those version?

ScheiklP commented 1 month ago

Hi @KantaphatLeelakunwet , in the respective directories, run the command git log -1.

FOLDER_SRC=$HOME/sofa/src
FOLDER_SP3=$FOLDER_SRC/applications/plugins/SofaPython3

and wherever you cloned sofa_env and sofa_zoo.

Cheers, Paul

KantaphatLeelakunwet commented 1 month ago

Got it. Thanks! Below are the commits.

SOFA: cfaeadccb418337c48d63e05adbf7d09e412d375 (FOLDER_SRC) SofaPython3: b5e28c15305cb8cc21a7dc04d51db47730962f61 (FOLDER_SP3) sofa_env: 0621d12bad12c496b4efa3070cb86eaa5e006582 sofa_zoo: 708c8f29afb45c3d22c49dd90ffe5afc0178369a

ScheiklP commented 1 month ago

Could you update the repositories to the following commits? SOFA: v23.12 (so just git checkout v23.12) SofaPython3: f1ac0f03efd6f6e7c30df8b18259e16da523f0b2 sofa_env: 3c496f109955d7b2608091e26960db95f996b6d4

KantaphatLeelakunwet commented 1 month ago

I can successfully checkout SOFA and SofaPython3, but sofa_env report an error saying that fatal: reference is not a tree: 3c496f109955d7b2608091e26960db95f996b6d4

ScheiklP commented 1 month ago

Please do a git fetch before trying to checkout the commit.

KantaphatLeelakunwet commented 1 month ago
image

I found this error while running just now. It seems like in sofa_env/scenes/precision_cutting/precision_cutting_env.py, at line 382, the number of arguments is 2, but 3 is expected. Should I add rng=self.rng?

The Invalid thing is still there T.T

ScheiklP commented 1 month ago

Hi @KantaphatLeelakunwet , Two problems:

  1. The rng bug was already fixed in commit 830d677e785d54f8e33001d9b35e35db43ec17cb of sofa_env, which is 2 commits before the one you should have checked out.
commit 3c496f109955d7b2608091e26960db95f996b6d4 (HEAD -> main, origin/main, origin/HEAD)
Author: Paul Maria Scheikl <paul.m.scheikl@fau.de>
Date:   Fri Mar 15 15:31:24 2024 +0100

    [Docs] Update installation instructions.
  1. You have to recompile SOFA, so that the binary is up to date with the updated SOFA and SofaPython3 repos.
KantaphatLeelakunwet commented 1 month ago

Thanks a lot. I will try to install it from the beginning as some new error shows up when I recompile CMake.

KantaphatLeelakunwet commented 1 month ago

When I tried to run the command to test the installation python3 sofa_env/scenes/controllable_object_example/controllable_env.py, I received an Import Error.

image

\ I have asked one of the cluster admin to install the dependencies using sudo (because I have no access) sudo apt -y install libtinyxml2-dev, and libtinyxml2.so.9 is installed. He has tried to find an update version of it but he could not find libtinyxml2.so.10. Do you anyway to solve this problem? Thank you in advance!

ScheiklP commented 1 month ago

Hi @KantaphatLeelakunwet , no, sorry, I also just installed libtinyxml2-dev https://www.sofa-framework.org/community/doc/getting-started/build/linux/#:~:text=tinyXML2,install%20libtinyxml2%2Ddev

ScheiklP commented 1 month ago

Hi @KantaphatLeelakunwet, Were you able to resolve the issue?