create carla scenarios - PacktPublishing/Hands-On-Intelligent-Agents-with-OpenAI-Gym GitHub Wiki

Creating new scenarios is easy with the carla_gym environment implementation in this repository.

The scenarios.json defines several scenario data in the form: [start_pose_node_id, end_pose_node_id] that can be used to compose new driving scenarios.

For example, if you want to create a scenario in Town2 where the vehicle is driving along some curves, you can add the following to scenarios.json:

"Curve1_Town2": {
    "city": "Town02",
    "start_pos_id": 8,
    "end_pos_id": 24,
    "num_vehicles": 25,
    "num_pedestrians": 30,
    "weather_distribution": [0],
    "max_steps": 200
  },

And then change this line: https://github.com/PacktPublishing/Hands-On-Intelligent-Agents-with-OpenAI-Gym/blob/df9ab3984237b3a02998e2c3d3df482f557945f9/ch8/environment/carla_gym/envs/carla_env.py#L75

which reads: "scenarios": [scenario_config["Lane_Keep_Town2"]],

to

"scenarios": [scenario_config["Curve1_Town2"]],

That's it! Now, if you create a new environment instance, the car will be driving in the new scenario!

Additionally, you can automate the scenario building process and also register the new scenarios under different environment names! For example, you can register this curvy scenario as Carla-curvy-town2-v0 etc.

⚠️ **GitHub.com Fallback** ⚠️