Farama-Foundation / HighwayEnv

A minimalist environment for decision-making in autonomous driving
https://highway-env.farama.org/
MIT License
2.62k stars 747 forks source link

Training Parking_her does not work. #392

Closed JoshYank closed 1 year ago

JoshYank commented 1 year ago

Good afternoon, I was trying to train a policy for the parking-env to test against safety validation methods. When I tried to run the code on colab as it is, I was getting an error when creating the environment. AttributeError: 'ParkingEnv' object has no attribute 'np_random' This error could be solved by reinstalling the highway-env or initially installing an older version of gym and highway. After doing this, an error occurs in creating the model before training. TypeError: init() got an unexpected keyword argument 'create_eval_env'

It would be much appreciated if you have any insight on how to solve this problem. My research focuses more on the verification side than training or developing a controller to test. I don't have as much experience in training controllers with RL.

Training_Code_Error_Parking

HarshkumarBorad commented 1 year ago

Hello,

You can try with specified version of SB. stable-baselines3==1.6.1 sb3-contrib==1.6.1

Hope this may help you to solve that issue.

JoshYank commented 1 year ago

This fixed the error that occurred when running the line to make the model. Then, this error comes up when trying to run model.learn().

Training_Code_Error_Parking_2

JoshYank commented 1 year ago

I solved the issue. You also have to set. !pip install gym==0.21.0 !pip install highway-env==1.5

Working with the parking-env itself, how do we input a desired goal position and initial position/velocity for the agent?

HarshkumarBorad commented 1 year ago

Hello,

For the goal position, you have to modify the parameter lane.position(lane.length/2, 0) in parking-env and replace it with the desired goal position. https://github.com/eleurent/highway-env/blob/793c8830ae5be9cbce70f55dfcb33d3c5ed762c3/highway_env/envs/parking_env.py#L153

for the initial position of the vehicle, you have to modify the parameter *[i20, 0]** in parking-env and replace it with the desired initial position of the vehicle. https://github.com/eleurent/highway-env/blob/793c8830ae5be9cbce70f55dfcb33d3c5ed762c3/highway_env/envs/parking_env.py#L148

Thanks and Regards, Harshkumar Borad

JoshYank commented 1 year ago

Is there any way to do this from the created environment rather than from changing the files? The idea is to model uncertainty of the locations within a single script and run multiple simulations.

eleurent commented 1 year ago

Something you could do is to manually override env.goal.position and env.vehicle.position after every call to env.reset()

araffin commented 1 year ago

@JoshYank in case you want to use latest SB3 and highway env version, you can take a look at the instructions in https://github.com/DLR-RM/stable-baselines3/pull/780