mirror of
https://github.com/kuhyx/WUT_Computer_Science.git
synced 2026-07-04 14:43:08 +02:00
modified repo
This commit is contained in:
parent
02a8644f93
commit
f7c0756f7e
1
CoPO
Submodule
1
CoPO
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit 86975e924df9f7d0bee701955228e6855ae3f9ff
|
||||
29
README.md
29
README.md
@ -6,20 +6,31 @@ wykorzystując algorytmy **wieloagentowe** (MA), na co
|
||||
najmniej trzech różnych mapach. Omów otrzymane wyniki oraz zwizualizuj działanie
|
||||
wytrenowanych agentów.
|
||||
|
||||
## How to run:
|
||||
|
||||
### Install metadrive
|
||||
## Setup
|
||||
```
|
||||
pip install metadrive-simulator
|
||||
python -m metadrive.pull_asset
|
||||
conda create -n copo python=3.7
|
||||
conda activate copo
|
||||
|
||||
# Install MetaDrive version 0.2.5
|
||||
pip install git+https://github.com/metadriverse/metadrive.git@releases/0.2.5
|
||||
|
||||
pip install torch
|
||||
|
||||
git clone https://github.com/decisionforce/CoPO
|
||||
cd CoPO/copo_code
|
||||
pip install -e .
|
||||
|
||||
pip install -U ray==1.2.0 "ray[rllib]==1.2.0"
|
||||
pip install -U "numpy<1.24.0"
|
||||
pip uninstall opencv-python
|
||||
pip uninstall opencv-python-headless
|
||||
pip install opencv-python==4.5.5.64
|
||||
pip install pydantic==1.9.0
|
||||
```
|
||||
|
||||
#### Verify
|
||||
`python -m metadrive.examples.profile_metadrive`
|
||||
## How to train a RL agents
|
||||
|
||||
Install swig, python and pip
|
||||
|
||||
Install other libraries required by program:
|
||||
|
||||
`pip install -r requirements.txt`
|
||||
|
||||
|
||||
@ -1,83 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
"""
|
||||
This script demonstrates how to setup the Multi-agent RL environments.
|
||||
|
||||
|
||||
Usage: python -m metadrive.examples.drive_in_multi_agent_env --env pgma
|
||||
|
||||
Options for --env argument:
|
||||
(1) roundabout
|
||||
(2) intersection
|
||||
(3) tollgate
|
||||
(4) bottleneck
|
||||
(5) parkinglot
|
||||
(6) pgma
|
||||
|
||||
"""
|
||||
import argparse
|
||||
from metadrive.component.sensors.rgb_camera import RGBCamera
|
||||
from metadrive import (
|
||||
MultiAgentMetaDrive, MultiAgentTollgateEnv, MultiAgentBottleneckEnv, MultiAgentIntersectionEnv,
|
||||
MultiAgentRoundaboutEnv, MultiAgentParkingLotEnv
|
||||
)
|
||||
from metadrive.constants import HELP_MESSAGE
|
||||
from metadrive.policy.idm_policy import ManualControllableIDMPolicy
|
||||
|
||||
if __name__ == "__main__":
|
||||
envs = dict(
|
||||
roundabout=MultiAgentRoundaboutEnv,
|
||||
intersection=MultiAgentIntersectionEnv,
|
||||
tollgate=MultiAgentTollgateEnv,
|
||||
bottleneck=MultiAgentBottleneckEnv,
|
||||
parkinglot=MultiAgentParkingLotEnv,
|
||||
pgma=MultiAgentMetaDrive
|
||||
)
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("--env", type=str, default="roundabout", choices=list(envs.keys()))
|
||||
parser.add_argument("--top_down", "--topdown", action="store_true")
|
||||
args = parser.parse_args()
|
||||
env_cls_name = args.env
|
||||
extra_args = dict(film_size=(800, 800)) if args.top_down else {}
|
||||
assert env_cls_name in envs.keys(), "No environment named {}, argument accepted: \n" \
|
||||
"(1) roundabout\n" \
|
||||
"(2) intersection\n" \
|
||||
"(3) tollgate\n" \
|
||||
"(4) bottleneck\n" \
|
||||
"(5) parkinglot\n" \
|
||||
"(6) pgma" \
|
||||
.format(env_cls_name)
|
||||
env = envs[env_cls_name](
|
||||
{
|
||||
"use_render": True if not args.top_down else False,
|
||||
"crash_done": False,
|
||||
"sensors": dict(rgb_camera=(RGBCamera, 400, 300)),
|
||||
"interface_panel": ["rgb_camera", "dashboard"],
|
||||
"agent_policy": ManualControllableIDMPolicy
|
||||
}
|
||||
)
|
||||
try:
|
||||
env.reset()
|
||||
# if env.current_track_agent:
|
||||
# env.current_track_agent.expert_takeover = True
|
||||
print(HELP_MESSAGE)
|
||||
env.switch_to_third_person_view() # Default is in Top-down view, we switch to Third-person view.
|
||||
for i in range(1, 10000000000):
|
||||
o, r, tm, tc, info = env.step({agent_id: [0, 0] for agent_id in env.agents.keys()})
|
||||
env.render(
|
||||
**extra_args,
|
||||
mode="top_down" if args.top_down else None,
|
||||
text={
|
||||
"Quit": "ESC",
|
||||
"Number of existing vehicles": len(env.agents),
|
||||
"Tracked agent (Press Q)": env.engine.agent_manager.object_to_agent(env.current_track_agent.id),
|
||||
"Keyboard Control": "W,A,S,D",
|
||||
# "Auto-Drive (Switch mode: T)": "on" if env.current_track_agent.expert_takeover else "off",
|
||||
} if not args.top_down else {}
|
||||
)
|
||||
if tm["__all__"]:
|
||||
env.reset()
|
||||
# if env.current_track_agent:
|
||||
# env.current_track_agent.expert_takeover = True
|
||||
finally:
|
||||
env.close()
|
||||
@ -1,4 +0,0 @@
|
||||
wheel
|
||||
metadrive-simulator
|
||||
gymnasium
|
||||
gym
|
||||
Loading…
Reference in New Issue
Block a user