proroklab / VectorizedMultiAgentSimulator

VMAS is a vectorized differentiable simulator designed for efficient Multi-Agent Reinforcement Learning benchmarking. It is comprised of a vectorized 2D physics engine written in PyTorch and a set of challenging multi-robot scenarios. Additional scenarios can be implemented through a simple and modular interface.
https://vmas.readthedocs.io
GNU General Public License v3.0
335 stars 69 forks source link

[New Scenario] Road Traffic #99

Closed Jianye-Xu closed 4 months ago

Jianye-Xu commented 5 months ago

This PR introduces a road traffic scenario, aiming to provide a MARL benchmark for Connected and Automated Vehicles (CAVs).

This scenario uses a High-Definition (HD) map from the Cyber-Physical Mobility Lab (CPM Lab), an open-source testbed for CAVs. The map features an eight-lane intersection and a loop-shaped highway with multiple merge-in and -outs, offering a range of challenging traffic conditions. Forty loop-shaped reference paths are predefined, allowing for simulations with infinite durations. You can initialize up to 100 agents, with a default number of 20. In the event of collisions during training, the scenario reinitializes all agents, randomly assigning them new reference paths, initial positions, and speeds. This setup is designed to simulate the unpredictability of real-world driving.

PS:

  1. I added the description of this scenario to the README, where a gif file for this scenario is referenced. Therefore, could you upload the gif file below to https://github.com/matteobettini/vmas-media/blob/main/media/scenarios/ with the name road_traffic_cpm_lab.gif?
  2. I included all the utilities needed for this scenario in this scenario file. This avoids the need to add new utilities to /vmas/simulator/utils.py or introduce new files but makes this file "bloated". Let me know if this is what you want.
  3. Aligning with how VMAS updates agents' states using physical forces, I adjusted the kinematic bicycle model.

Let me if you have any suggestions for improvements for this PR.

road_traffic_cpm_lab

matteobettini commented 5 months ago

Perfect, I have merged the dynamics in #102 and uploaded the gif.

Could you merge main in this PR pls?

Next I will review the scenario

matteobettini commented 5 months ago

Also could you please follow the instructions here to format the code and add the scenario to https://github.com/proroklab/VectorizedMultiAgentSimulator/blob/be5deac1f93a5ac84541d0d96580102c88513f9d/vmas/__init__.py#L23 ?

Jianye-Xu commented 5 months ago

Perfect, I have merged the dynamics in #102 and uploaded the gif.

Could you merge main in this PR pls?

Next I will review the scenario

Thank you. Yes sure, I merged main into this PR.

Jianye-Xu commented 5 months ago

Also could you please follow the instructions here to format the code and add the scenario to

https://github.com/proroklab/VectorizedMultiAgentSimulator/blob/be5deac1f93a5ac84541d0d96580102c88513f9d/vmas/__init__.py#L23

?

Thanks for pointing this out. I followed the instructions and updated the PR. Let me know I need do anything else before you start to review this PR.

Jianye-Xu commented 5 months ago

Ah, let me fix the failures of the checks.

Jianye-Xu commented 5 months ago

Thanks for the comments! I will address them.

PS: I am traveling to attend the IEEE IV 2024. Pls expect delayed responses.

Jianye-Xu commented 4 months ago

My latest commit has been pushed (933dfc6). Can you have a look and let me know if you have any comments?

Jianye-Xu commented 4 months ago

Very coll stuff! We are almost there I think.

Could you add a recap of the scenario in the Scenario docstring?

Also a little more depth in the parameters meaning would be super useful. For example what are the scenario_types, testing_mode, etc. This could also go in the Scenario docstring, where we could tell the users how they should typically use this scenario. For example, what parameters are more useful or frequent to change / what they can touch to match the setups in the paper

Glad to hear that!

Good suggestions. I added a recap to the Scenario docstring.

Jianye-Xu commented 4 months ago

Thanks for your code review. I pushed a new version (last commit 001d250) considering all your previous comments. Let me know if you have any more comments.

Jianye-Xu commented 4 months ago

Very nice docstring!

One last thing:

Can you merge main? In particular, we have recently replaced all kwargs.get with kwargs.pop and then at the end of reading all kwargs place ScenarioUtils.check_kwargs_consumed(kwargs) which raises a warning if some params are passed and not read

Thanks!

Sure, will do it

Jianye-Xu commented 4 months ago

My new commit (4e300b9) is ready for review. Let me know if you have any new comments.

Besides, I noticed the background color of the gif I gave you last time is not white. I fixed this. Can you replace it with this one?: road_traffic_cpm_lab

matteobettini commented 4 months ago

My new commit (4e300b9) is ready for review. Let me know if you have any new comments.

Besides, I noticed the background color of the gif I gave you last time is not white. I fixed this. Can you replace it with this one?

I tried but I stll see the same background yellow somehow. Do you want to try to make a PR to that repo to see if that works?

Jianye-Xu commented 4 months ago

I tried but I stll see the same background yellow somehow. Do you want to try to make a PR to that repo to see if that works?

Actually now I see it has a white background. Maybe because of the cache of your browser?

Jianye-Xu commented 4 months ago

Try to see if the xml is included by running python3 setup.py sdist and checking if the xml is in the folder created

Before I added

include vmas/scenarios_data/road_traffic/road_traffic_cpm_lab.xml

to MANIFEST.in, the scenario data was not included in the pip release. Therefore, I pushed a new commit (1955119) to add this line. Now it works as expected.

matteobettini commented 4 months ago

Try to see if the xml is included by running python3 setup.py sdist and checking if the xml is in the folder created

Before I added

include vmas/scenarios_data/road_traffic/road_traffic_cpm_lab.xml

to MANIFEST.in, the scenario data was not included in the pip release. Therefore, I pushed a new commit (1955119) to add this line. Now it works as expected.

Would

include vmas/scenarios_data

work as well? cause we do not want to have the same problem in rthe future

Jianye-Xu commented 4 months ago

Would

include vmas/scenarios_data

work as well? cause we do not want to have the same problem in rthe future

Yes, nice point. It works. The new commit is ed5a4f9.

matteobettini commented 3 months ago

Would

include vmas/scenarios_data

work as well? cause we do not want to have the same problem in rthe future

Yes, nice point. It works. The new commit is ed5a4f9.

I am checking now and this did not include the file, I ll fix it

Jianye-Xu commented 3 months ago

I am checking now and this did not include the file, I ll fix it

That's weird. It worked in my local machine. Thanks.