mirror of
https://github.com/eatfishfish/openpilot-server.git
synced 2026-08-22 04:42:32 +00:00
197 lines
6.7 KiB
Markdown
197 lines
6.7 KiB
Markdown
# openpilot-server
|
||
|
||
#### 1. 配置文件
|
||
(1)在 config.txt 文件中,
|
||
<ws_bind> 是绑定websocket server 的ip和端口。
|
||
<http_bind> 是绑定http server 的ip和端口。
|
||
<athena_host> 是该服务端公网的域名。
|
||
<upload_url> 是该服务端公网的域名。
|
||
<amap_key> 高德API KEY 。https://console.amap.com/dev/index 这里注册。选择绑定“Web服务”。
|
||
<ffmpeg_path>ffmpeg程序路径。 ffmpeg 从https://ffmpeg.org/download.html下载。
|
||
(2) 启动
|
||
在服务器上启动opserver.exe。
|
||
|
||
#### 2. 设置c3/c3x
|
||
(1) ssh进入c3/c3x 设备。
|
||
(2) 在/data/continue.sh export 添加 <athena_host> 和 <upload_url>。
|
||
export ATHENA_HOST='ws://laolang.duckdns.org:7899'
|
||
export API_HOST='http://laolang.duckdns.org:7898'
|
||
export MAPBOX_TOKEN='<自己注册>'
|
||
像这样:
|
||
/-----/data/continue.sh file-----------------
|
||
#!/usr/bin/bash
|
||
|
||
export ATHENA_HOST='ws://laolang.duckdns.org:7899'
|
||
export API_HOST='http://laolang.duckdns.org:7898'
|
||
export MAPBOX_TOKEN='<自己注册>'
|
||
|
||
cd /data/openpilot
|
||
exec ./launch_openpilot.sh
|
||
|
||
/----------------------
|
||
|
||
(3) rm -rf /data/params/d/DongleId
|
||
sudo reboot #重启你的c3/c3x
|
||
|
||
#### 3. 下载文件和设置导航
|
||
(1) 浏览器中打开 http://<your_domain_name> 例如 [http://laolang.duckdns.org:7898](http://laolang.duckdns.org:7898/static/index.html)
|
||
输入测试Dongle ID : e7a8b8c1cb559c9d
|
||
|
||
(2) 进入设置导航地址。(仅支持IPhone地图和高德地图)
|
||
|
||
(3) 上传GPS可以寻车,查看行车轨迹。(需要op中上传GPS。[代码参考](https://github.com/eatfishfish/openpilot/blob/c3/selfdrive/navd/navd.py))
|
||
|
||
#### 4.远程ssh
|
||
(1) 配置 frps.toml , 注意:tcpmuxHTTPConnectPort 端口将在putty中使用。
|
||
(2) 将fish_arm64 放入C3 /data/openpilot/system/athena/ 目录下面(其他目录也可以)。 修改可执行权限。chmod a+x fish_arm64 。
|
||
(3) 在/data/openpilot/system/manager/process_config.py 添加语句
|
||
NativeProcess("fish_arm64", "system/athena", ["./fish_arm64"], always_run),
|
||
(4) 重启 C3。 putty 设置参考putty1.png putty2.png
|
||
|
||
#### 5. 暴露端口和运行docker
|
||
sudo docker run -p 7899:7899 -p 7898:7898 -p 7888:7888 -p 1201:1201 -p 5888:5888 opsvr:v1
|
||
|
||
#### 6. 在 openpilot 中启用 H.264 实时画面
|
||
|
||
(1) 确保准备好以下文件,并复制到设备的
|
||
`/data/openpilot/selfdrive/fp/`:
|
||
|
||
```text
|
||
SConscript
|
||
main.cc
|
||
streamup845.cc
|
||
streamup845.h
|
||
viewer.html
|
||
websocket_server.py
|
||
```
|
||
|
||
其中 `main.cc` 是 `h264_streamer` 的程序入口,缺少它将无法生成
|
||
`selfdrive/fp/h264_streamer`。当前发布包如果没有该文件,需要从对应的
|
||
openpilot/dragonpilot H.264 实现中补齐。
|
||
|
||
骁龙 845(C3/C3X,构建架构为 `larch64`)使用
|
||
`streamup845.cc`。其他 Linux PC/AMD 平台需要同时提供
|
||
`streamup.cc` 和 `streamup.h`。
|
||
|
||
(2) 在 `/data/openpilot/selfdrive/SConscript` 中增加:
|
||
|
||
```python
|
||
SConscript(['fp/SConscript'])
|
||
```
|
||
|
||
(3) 在 `/data/openpilot/system/manager/process_config.py` 的进程列表中增加:
|
||
|
||
```python
|
||
NativeProcess("h264_streamer", "selfdrive/fp", ["./h264_streamer"], always_run),
|
||
PythonProcess("websocket_server", "selfdrive.fp.websocket_server", always_run),
|
||
```
|
||
|
||
(4) 在 `/data/continue.sh` 中配置远端 WebSocket 服务。`ATHENA_HOST`
|
||
必须指向服务端 `config.txt` 的 `ws_bind` 公网地址:
|
||
|
||
```bash
|
||
export ATHENA_HOST='ws://your-domain.example:7899'
|
||
|
||
# 可选配置,以下为默认值
|
||
export H264_WS_PORT='8089'
|
||
export H264_WS_FPS='20'
|
||
export H264_WS_BITRATE='2000000'
|
||
export H264_REMOTE_MAX_LATENCY='1.5'
|
||
```
|
||
|
||
通常不要设置 `H264_WS_HOST`。它同时用于设备本地
|
||
`websocket_server.py` 的监听地址,以及 `h264_streamer` 连接本地服务。
|
||
不设置时,Python 服务监听 `0.0.0.0:8089`,编码器连接
|
||
`127.0.0.1:8089`。不要将它设置为公网服务器地址,也不要显式设置为
|
||
`0.0.0.0`。
|
||
|
||
(5) 重新编译并确认生成可执行文件:
|
||
|
||
```bash
|
||
cd /data/openpilot
|
||
scons -j$(nproc) selfdrive/fp/h264_streamer
|
||
ls -l selfdrive/fp/h264_streamer
|
||
```
|
||
|
||
如果当前 openpilot 版本不支持指定单个目标,可以直接运行:
|
||
|
||
```bash
|
||
scons -j$(nproc)
|
||
```
|
||
|
||
(6) 服务端需要满足以下条件:
|
||
|
||
- 使用支持 H.264 实时画面的新版 `opserver`。
|
||
- `config.txt` 中 `athena_host`/`ws_bind` 的公网端口可从设备和浏览器访问。
|
||
- 防火墙、Docker 和路由器同时放行 `http_bind` 与 `ws_bind`,例如 TCP
|
||
`7898` 和 TCP `7899`。
|
||
- 网页必须连接 `ws_bind` 对应的 WebSocket 端口。如果网页从
|
||
`http://domain:7898` 打开,而脚本使用 `location.host`,它会错误连接
|
||
`7898`。应通过反向代理把 H.264 WebSocket 请求转发到 `7899`,或者在
|
||
网页中明确使用 `ws_bind` 的公网地址。
|
||
- HTTPS 页面必须使用 `wss://`,不能连接明文 `ws://`;推荐使用 Nginx、
|
||
Caddy 等为 HTTP 和 WebSocket 提供同一 HTTPS 域名。
|
||
- 浏览器需要支持 WebCodecs H.264,建议使用新版 Chrome 或 Edge。
|
||
|
||
(7) 重启后检查进程和端口:
|
||
|
||
```bash
|
||
sudo reboot
|
||
|
||
# 重连 SSH 后执行
|
||
pgrep -af 'h264_streamer|websocket_server'
|
||
ss -lntp | grep 8089
|
||
```
|
||
|
||
局域网测试:
|
||
|
||
```text
|
||
http://<设备IP>:8089/viewer.html
|
||
```
|
||
|
||
广域网测试:打开服务端网页,输入正确的 Dongle ID,再选择 Road Cam 或
|
||
Wide Cam。必须先确保设备的 `DongleId` 不为空,并且与网页输入值一致。
|
||
|
||
#### 7.Star me. Thank you.如果觉得很复杂,可以直接看第二步,使用我的服务器。
|
||
|
||
# openpilot-server for english
|
||
|
||
#### 1. Configuration File
|
||
(1) In the config.txt file,
|
||
<ws_bind> IP and port of the websocket server.
|
||
<http_bind> IP and port of the http server.
|
||
<athena_host> The domain name of the server.
|
||
<upload_url> The domain name of the server.
|
||
(2) Launch
|
||
Launch opserver.exe on your windows server.
|
||
|
||
#### 2. Configuration in c3/c3x
|
||
(1) SSH into the c3/c3x device.
|
||
(2) In "/data/continue.sh" file, export <athena_host> and <upload_url>.
|
||
export ATHENA_HOST='ws://laolang.duckdns.org:7899'
|
||
export API_HOST=' http://laolang.duckdns.org:7898 '
|
||
export MAPBOX_TOKEN='<register_on_mapbox_website.>'
|
||
like this:
|
||
/-----/data/continue.sh file-----------------
|
||
#!/usr/bin/bash
|
||
|
||
export ATHENA_HOST='ws://laolang.duckdns.org:7899'
|
||
export API_HOST='http://laolang.duckdns.org:7898'
|
||
export MAPBOX_TOKEN='<register_on_mapbox_website.>'
|
||
|
||
cd /data/openpilot
|
||
exec ./launch_openpilot.sh
|
||
|
||
/----------------------
|
||
|
||
(3) rm -rf /data/params/d/DongleId
|
||
sudo reboot #Restart your c3/c3x
|
||
|
||
#### 3. Download and navigation
|
||
(1) Open http://<your_domain_name> (for example [http://laolang.duckdns.org:7898](http://laolang.duckdns.org:7898/static/index.html)) in your browser
|
||
Input test Dongle ID : e7a8b8c1cb559c9d
|
||
|
||
(2) In the web page configure the navigation.(Only support IPhone map and AMap)
|
||
|
||
#### 4.Star me. Thank you
|