Skip to content
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 6 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,12 @@ graph LR

## 集成版
能够在未安装Python和UE4的情况下启动
1. 下载 [发布页面](https://github.com/OpenHUTB/hutb/releases) 中的对应的文件并解压
2. 下载 [虚拟环境、启动脚本及MCP文件](https://pan.baidu.com/s/1TNH-9wZYNy4NhmWJSoZL5A?pwd=hutb)中的`env.UE4-hutb_v1.0.zip`文件,解压到`WindowsNoEditor`文件夹下,确认项目结构如下所示
```
WindowsNoEditor/
├── env.UE4-hutb/
├── llm/
│ └── .env
├── CarlaUE4.exe
└── hutb.bat
```
3. 检查 `llm/.env` 文件中的Github和Deepseek API密钥已配置
4. 双击 `hutb.bat` 启动模拟器

下载 [HUTB项目](https://pan.baidu.com/s/1TNH-9wZYNy4NhmWJSoZL5A?pwd=hutb)中的`hutb_v1.0.zip`文件,解压到`WindowsNoEditor`文件夹下,双击 `hutb.bat` 启动模拟器

可通过修改
`llm/.env` 文件中的Github和Deepseek API密钥进行配置
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Github的密钥应该不需要,后面和github交互的这部分功能可以移除

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

main_ai.py与Github交互部分移除,最新的zip包正在压缩上传至网盘




### 1.1 大模型
Expand Down
34 changes: 34 additions & 0 deletions llm/main_ai.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@ async def spawn_vehicle(self, vehicle_type='model3'):
vehicle = self.world.spawn_actor(blueprint, spawn_point)
self.actors.append(vehicle)
app_logger.info(f"🚗 生成车辆: {vehicle_type}")

return vehicle
except Exception as e:
app_logger.error(f"❌ 生成车辆失败: {str(e)}")
Expand Down Expand Up @@ -392,11 +393,44 @@ async def spawn_pedestrian(self, pedestrian_type='walker'):
pedestrian = self.world.spawn_actor(blueprint, spawn_point)
self.actors.append(pedestrian)
app_logger.info(f"🚶 生成行人: {pedestrian_type}")

# 将视角对准生成的行人
self.set_spectator_view(pedestrian)
return pedestrian
except Exception as e:
app_logger.error(f"❌ 生成行人失败: {str(e)}")
return None

def set_spectator_view(self, target_actor):
"""将视角对准目标actor"""
try:
spectator = self.world.get_spectator()
target_transform = target_actor.get_transform()

# 设置相机位置在目标actor前方5米,上方2米处
# 这样可以从正面看到行人
camera_location = carla.Location(
x=target_transform.location.x + 5.0, # 前方5米
y=target_transform.location.y,
z=target_transform.location.z + 2.0
)

# 计算相机朝向,指向行人
# yaw=180.0 让相机朝向行人方向
camera_rotation = carla.Rotation(
pitch=-15.0, # 略微向下看
yaw=180.0, # 朝向行人
roll=0.0
)

camera_transform = carla.Transform(camera_location, camera_rotation)
spectator.set_transform(camera_transform)
app_logger.info(f"👁️ 视角已对准actor {target_actor.id}")
return True
except Exception as e:
app_logger.error(f"❌ 设置视角失败: {str(e)}")
return False

async def cleanup(self):
"""清理环境"""
for actor in self.actors:
Expand Down