HighwayEnv icon indicating copy to clipboard operation
HighwayEnv copied to clipboard

Manual Control (arrow control)

Open kenrlck opened this issue 2 years ago • 3 comments

Hi! i've been looking at similar thread in controlling the vehicles manually using the arrow key, but cant find any lead on when and how the arrow keys are being used. I believe that it has something to do with the real_time_rendering: True, but how can we get the visualization to control the vehicles manually? If i just run the code below, it will complete itself but without any lane change or acceleration/ deceleration. Should i add show_videos or anything else before i get to control the vehicle?

`import gym import highway_env

env = gym.make("intersection-v0") env.configure({ "manual_control": True, "real_time_rendering": True, }) env.reset() done = False while not done: _, _, done, _ = env.step(env.action_space.sample()) # with manual control, these actions are ignored env.render()`

kenrlck avatar Jun 03 '22 15:06 kenrlck

As I said in https://github.com/eleurent/highway-env/issues/321, with this configuration,

You can use the Left and Right arrows to control the vehicle target speed, and usually you can change lanes with Up and Down, but in this environment there is only a single lane that the agent, so these actions have no effect.

I believe that it has something to do with the real_time_rendering

No, real-time rendering only slows down the simulation speed (to real-time) so that it is easier to control the car (otherwise it can be too fast, depending on the number of vehicles in the scene etc.)

It is the "manual_control": True, option which enables manual control.

Should i add show_videos or anything else before i get to control the vehicle

No, env.render() should be enough.

eleurent avatar Jun 04 '22 09:06 eleurent

HI Mr Laurent! Thank you for your prompt reply! I believe that I did something wrong (as when i extract the info, the vehicle operate by itself even when the manual control is turned on. Would you happen to identify where i made the mistake? In addition, I didn't seem to be able to get any visual feed to enable me to view simulation. Should it somehow pop up on my screen?

image

kenrlck avatar Jun 04 '22 10:06 kenrlck

Hi, I'm not sure, but it may because you are using a jupyter notebook to run the code, maybe this prevents from opening the rendering window. Could you try running the same code from a python script instead? You should see a rendering window pop up, which will allow you to do manual control.

eleurent avatar Jun 18 '22 16:06 eleurent