JingYue2000 / In-context_Learning_for_Automated_Driving

MIT License
4 stars 4 forks source link

[Bug Report]ValueError in agent_train.py When Checking Truth Value of Array #1

Open Scarecrow777 opened 1 week ago

Scarecrow777 commented 1 week ago

Description:

When I running the agent_train.py script, an error occurs that halts the execution. The issue appears to be related to checking the truth value of an array with more than one element.

Environment

Error Trace:

/workspace/anaconda3/envs/rl_context2/lib/python3.9/site-packages/gymnasium/core.py:311: UserWarning: WARN: env.configure to get variables from other wrappers is deprecated and will be removed in v1.0, to get this variable you can do `env.unwrapped.configure` for environment variables or `env.get_wrapper_attr('configure')` that will search the reminding wrappers.
  logger.warn(
Initial Observation: (array([[  1.      , 180.30904 ,   0.      ,  25.      ,   0.      ],
       [  1.      , 190.35237 ,   0.      ,  22.364283,   0.      ],
       [  1.      , 200.60976 ,   8.      ,  22.949116,   0.      ],
       [  1.      , 211.85056 ,   0.      ,  22.695644,   0.      ],
       [  1.      , 222.68523 ,   4.      ,  22.61005 ,   0.      ]],
      dtype=float32), {'speed': 25, 'crashed': False, 'action': 0, 'rewards': {'collision_reward': 0.0, 'right_lane_reward': 0.0, 'high_speed_reward': 0.5, 'on_road_reward': 1.0}})
Observation space: Box(-inf, inf, (5, 5), float32)
/workspace/anaconda3/envs/rl_context2/lib/python3.9/site-packages/gymnasium/core.py:311: UserWarning: WARN: env.get_available_actions to get variables from other wrappers is deprecated and will be removed in v1.0, to get this variable you can do `env.unwrapped.get_available_actions` for environment variables or `env.get_wrapper_attr('get_available_actions')` that will search the reminding wrappers.
  logger.warn(
Traceback (most recent call last):
  File "/workspace/new_test/In-context_Learning_for_Automated_Driving/Auto_Driving_Highway/agent_train.py", line 181, in <module>
    main()
  File "/workspace/new_test/In-context_Learning_for_Automated_Driving/Auto_Driving_Highway/agent_train.py", line 123, in main
    sce.updateVehicles(obs, frame)
  File "/workspace/new_test/In-context_Learning_for_Automated_Driving/Auto_Driving_Highway/scenario.py", line 82, in updateVehicles
    if presence == 1:  # Check if the vehicle is present
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

Please let me know if further details are required.

JingYue2000 commented 1 week ago

hi @Scarecrow777 , can you provide a snippet of the code in your jupyter?

Scarecrow777 commented 4 days ago

hi @Scarecrow777 , can you provide a snippet of the code in your jupyter?

Thank you for your response @JingYue2000, I only used console commands for this. I believe each step ran successfully. Here is the code:

source /workspace/anaconda3/bin/activate
conda activate rl_context
cd /workspace/RL_context
git clone https://github.com/JingYue2000/In-context_Learning_for_Automated_Driving.git
cd /workspace/RL_context/In_context_Learning_for_Automated_Driving/Auto_Driving_Highway
pip install setuptools==65.5.0
pip install --user wheel==0.38.0
pip install -r requirements.txt
python agent_train.py