praveen-palanisamy/macad-gym

How to manually control the agent in the scenario "DEFAULT_SCENARIO_TOWN1_COMBINED_WITH_MANUAL"?

YuffieHuang opened this issue · 7 comments

Hi. I'm using this wonderful platform to do some research about mixed types of vehicles in a traffic flow (automated vehicles along with legacy vehicles). I'm unable to use the keyboard to control the third vehicle named "manual" in the scenario "DEFAULT_SCENARIO_TOWN1_COMBINED_WITH_MANUAL". Can anyone help me out? Thank you!

Hi @YuffieHuang ,
Apologies for the delayed response. I somehow missed this. Good to know about your research direction!

You control an Actor/vehicle using your keyboard if you specify "manual_control": True for the Actor/Vehicle you want to control in the config.
For example, if you wanted to control the car1 actor in the "HomoNcomIndePOIntrxMASS3CTWN3-v0" environment, you would change the following line:


to:
"manual_control": True,

Note that the the above environment ("HomoNcomIndePOIntrxMASS3CTWN3-v0") uses the SSUI3C_TOWN3 scenario as per this configuration line:

If you wanted to use a different scenario, you should that config line as well. For example, you can change it to DEFAULT_SCENARIO_TOWN1_COMBINED_WITH_MANUAL.

As an additional note, when you are researching/experimenting with a new scenario with different configuration, it is better to create a new environment so that you can tweak the number and types of actors in the scenario among other things. You can easily create new environments following this guide: https://github.com/praveen-palanisamy/macad-gym/wiki/creating-new-learning-environments.md
Let me know if you need further help.

Hey @YuffieHuang ,
Just following-up to see if you were able to accomplish your goal. Were able to have mixed-autonomy scenarios with manual control enabled?

Hello. @praveen-palanisamy
Sorry, I'm really busy with another project these days and I haven't got a chance to try your suggestions. Please allow me a few more days and I will let you know the result. Thank you so much for your help!

Hi @praveen-palanisamy,
I have tried the methods you mentioned. Sadly, it doesn't work for me. The camera, which is attached to the manually driven vehicle, disappears in the Pygame window. I tried to hit the keys "w", "a", "s", "d", or "up", "down", "left", "right". The car doesn't move in the CarlaUE4 window.

Hey @YuffieHuang ,
Could you post the environment settings you are using so that I can reproduce the issue?
You can also open a draft PR from a branch on your clone for us to debug.

Once you set "manual_control": True, you should be able to manually control the actor but you will need to have a client script that listens to your keyboard event and sends those as control commands to the actor. A default keyboard event handler (using PyGame) and a vehicle controller is provided as part of the base environment implementation which you can customize.

@YuffieHuang: Converting this thread to a Q&A Discussion and I'll wait for your draft PR to debug it.