File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3535
3636# 定义一个简单的动作策略
3737def get_action (env , obs ):
38- """随机选择简单的手动动作或自动驾驶动作。"""
39- p = random .random ()
40- if p < 0.5 :
41- # 使用自动驾驶(专家模式)
42- env .ego .set_autopilot (True )
43- control = env .ego .get_control ()
44- action = [control .throttle , control .steer , control .brake ]
45- else :
46- # 使用随机动作(新手模式)
47- env .ego .set_autopilot (False )
48- throttle = random .uniform (0.0 , 1.0 )
49- steer = random .uniform (- 0.6 , 0.6 )
50- brake = random .uniform (0.0 , 0.3 )
51- action = [throttle , steer , brake ]
52- return action
38+ env .ego .set_autopilot (True )
39+ control = env .ego .get_control ()
40+ return [control .throttle , control .steer , control .brake ]
5341
5442# 与环境交互
5543for episode in range (5 ): # 运行 5 个 episode
Original file line number Diff line number Diff line change 1- 本项目旨在为 CARLA 模拟器提供了一个轻便易用的兼容 Gym 的界面,专为强化学习(RL)应用量身定制。它集成了激光雷达扫描、车辆状态、附近车辆信息和航点等关键观察组件。环境支持安全意识学习,包括奖励和成本信号、路标可视化以及可定制参数,包括交通设置、车辆数量和传感器范围。
1+ 本项目旨在为 CARLA 模拟器提供了一个轻便易用的兼容 Gym 的界面,专为强化学习(RL)应用量身定制。它集成了激光雷达扫描、车辆状态、附近车辆信息和航点等关键观察组件。环境支持安全意识学习,包括奖励和成本信号、路标可视化以及可定制参数,包括交通设置、车辆数量和传感器范围。
2+
3+ 安装所需依赖:
4+
5+ ``` bash
6+ pip install -r requirements.txt
7+ ```
8+
9+ 将本项目作为本地 Python 包安装:
10+
11+ ``` bash
12+ pip install -e .
13+ ```
14+
15+ ## 快速开始
16+
17+ 运行一个简单的演示,与环境进行交互:
18+
19+ ``` bash
20+ python easycarla_demo.py
21+ ```
22+
23+ 该脚本演示了如何:
24+ - 创建并重置环境
25+ - 选择自动驾驶动作
26+ - 在环境中逐步执行,并获取观测、奖励、代价以及结束信号
27+
28+ 在运行该演示之前,请确保你的 CARLA 服务端已经启动。
You can’t perform that action at this time.
0 commit comments