Repository navigation
无人电车电池表,电池表显示数字 - #3586
Merged
Merged
无人电车电池表,电池表显示数字#3586
Conversation
donghaiwang
force-pushed
the
main
branch
2 times, most recently
from
December 18, 2025 04:55
23d871b to
59c9d90
Compare
donghaiwang
approved these changes
Dec 18, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
修改概述:
Carla无人电车电池表,电池表显示数字,有一百格电,电量七十到一百电池表的数字显示为绿色,二十到六十九数字显示为黄色,三到十九数字显示为红色,零到2显示电量不足四个字
修改的详细描述
1.电池表共 100 格电量,实时显示当前电量数字 / 提示文字
2.电量区间颜色 / 文字规则:
70
100:数字显示为绿色69:数字显示为黄色20
3
19:数字显示为红色2:显示 “电量不足”(红色)0
3.模拟 Carla 车辆电量的消耗与恢复(可替换为真实 Carla 车辆数据交互)
4.多线程处理:避免 UI 卡顿,同时模拟 Carla 数据更新
经过了什么样的测试?
环境准备:
安装 Carla:pip install carla(或下载 Carla 官方包并运行服务器)
确保 Python 环境有 Tkinter(Python 内置,一般默认安装)
运行步骤:
先启动 Carla 服务器(如:./CarlaUE4.sh,Windows 为CarlaUE4.exe)
运行上述 Python 代码,若未启动 Carla,会自动使用模拟电量数据
关键逻辑:
Carla 交互:代码尝试连接本地 Carla 服务器(localhost:2000),筛选电动车辆并生成,若失败则使用模拟数据
电量更新:后台线程模拟车辆电量的消耗与恢复(可替换为真实的 Carla 车辆电量传感器数据)
UI 显示:根据电量区间动态调整显示的文字和颜色,符合需求中的规则
运行效果
动图、视频、截图等
2025-12-18.082953.mp4