{"id":14992272,"url":"https://github.com/bohonghuang/rov-host","last_synced_at":"2025-09-25T14:31:03.153Z","repository":{"id":44341649,"uuid":"434276151","full_name":"bohonghuang/rov-host","owner":"bohonghuang","description":"A cross-platform, high-performance underwater robot controll program written in Rust","archived":false,"fork":false,"pushed_at":"2022-09-12T06:54:49.000Z","size":1336,"stargazers_count":10,"open_issues_count":0,"forks_count":5,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-09-25T16:10:02.546Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bohonghuang.png","metadata":{"files":{"readme":"README.org","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-12-02T15:33:14.000Z","updated_at":"2024-09-14T06:23:00.000Z","dependencies_parsed_at":"2023-01-18T04:31:05.798Z","dependency_job_id":null,"html_url":"https://github.com/bohonghuang/rov-host","commit_stats":null,"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bohonghuang%2Frov-host","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bohonghuang%2Frov-host/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bohonghuang%2Frov-host/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bohonghuang%2Frov-host/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bohonghuang","download_url":"https://codeload.github.com/bohonghuang/rov-host/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234200176,"owners_count":18795139,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-09-24T15:00:54.111Z","updated_at":"2025-09-25T14:31:02.644Z","avatar_url":"https://github.com/bohonghuang.png","language":"Rust","funding_links":[],"categories":["Motion Control"],"sub_categories":[],"readme":"#+BEGIN_COMMENT\nREADME.org\n\nCopyright 2021-2022 Bohong Huang\n\nThis program is free software: you can redistribute it and/or modify\nit under the terms of the GNU General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or\n(at your option) any later version.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this program. If not, see \u003chttp://www.gnu.org/licenses/\u003e.\n#+END_COMMENT\n#+TITLE: 水下机器人上位机\n#+LATEX_HEADER: \\hypersetup{colorlinks=true,linkcolor=black}\n#+OPTIONS: AUTHOR:nil DATE:nil\n#+AUTHOR: Bohong Huang\n[[./documents/screenshot.png]]\n* 特性\n- 使用 [[https://www.rust-lang.org][Rust]] 进行高性能、内存安全的应用程序的开发\n- 基于 [[https://gtk.org][GTK4]]/[[https://gitlab.gnome.org/GNOME/libadwaita][libadwaita]] 构建现代的[[https://wikipedia.org/wiki/Graphical_user_interface][图形用户界面]]\n  - 跨平台\n    - [[https://wikipedia.org/wiki/Microsoft_Windows][Microsoft Windows]]\n    - [[https://wikipedia.org/wiki/MacOS][MacOS]]\n    - [[https://wikipedia.org/wiki/Linux][GNU/Linux]]\n  - 全屏模式\n  - 夜间模式\n- 通过 [[https://www.libsdl.org][SDL2]] 支持多手柄输入\n- 通过 [[https://gstreamer.freedesktop.org][GStreamer]] 对视频流进行多种格式的实时编解码\n  - 视频协议\n    - [[https://wikipedia.org/wiki/User_Datagram_Protocol][UDP]]\n    - [[https://wikipedia.org/wiki/Real-time_Transport_Protocol][RTP]]\n    - [[https://wikipedia.org/wiki/Real_Time_Streaming_Protocol][RTSP]] \n  - 视频拉流（解码）\n    - [[https://wikipedia.org/wiki/H.264][H.264]]\n    - [[https://wikipedia.org/wiki/H.265][H.265]]\n    - [[https://wikipedia.org/wiki/VP8][VP8]]\n    - [[https://wikipedia.org/wiki/VP9][VP9]]\n    - [[https://wikipedia.org/wiki/AV1][AV1]]\n  - 视频录制（编码）\n    - 不编码（跟随拉取视频流的编码）\n    - [[https://wikipedia.org/wiki/H.264][H.264]]\n    - [[https://wikipedia.org/wiki/H.265][H.265]]\n    - [[https://wikipedia.org/wiki/VP8][VP8]]\n    - [[https://wikipedia.org/wiki/VP9][VP9]]\n    - [[https://wikipedia.org/wiki/AV1][AV1]]\n  - 硬件加速\n    - [[https://wikipedia.org/wiki/CUDA][CUDA]]\n      - [[https://wikipedia.org/wiki/Nvidia_NVENC][NVENC]]\n      - [[https://wikipedia.org/wiki/Nvidia_NVDEC][NVDEC]]\n    - [[https://wikipedia.org/wiki/Direct3D][Direct3D]]\n    - [[https://wikipedia.org/wiki/Video_Acceleration_API][Video Acceleration API]]\n- 使用 [[https://opencv.org][OpenCV]] 进行实时图像后处理（图像增强）\n- 支持使用多种图像格式保存经过后处理的图像\n  - [[https://wikipedia.org/wiki/JPEG][JPEG]]\n  - [[https://wikipedia.org/wiki/Portable_Network_Graphics][PNG]]\n  - [[https://wikipedia.org/wiki/TIFF][TIFF]]\n  - [[https://wikipedia.org/wiki/BMP_file_format][BMP]]\n- 多机位并行操作、并行显示与同步录制\n- 在线固件更新\n- 在线参数调整\n* 构建\n请确保 [[https://www.rust-lang.org][Rust]] 与 [[https://doc.rust-lang.org/cargo][Cargo]] 已正确安装，并运行：\n- [[https://wikipedia.org/wiki/Microsoft_Windows][Microsoft Windows]] \\\\\n  #+BEGIN_SRC bat\n    cargo rustc --release -- -C link-args=-mwindows\n  #+END_SRC\n- [[https://wikipedia.org/wiki/MacOS][MacOS]]、[[https://wikipedia.org/wiki/Linux][GNU/Linux]] \\\\\n  #+BEGIN_SRC sh\n    cargo build --release\n  #+END_SRC\n** 编译依赖\n- [[https://gtk.org][GTK4]]\n- [[https://gitlab.gnome.org/GNOME/libadwaita][libadwaita]]\n- [[https://www.libsdl.org][SDL2]]\n- [[https://gstreamer.freedesktop.org][GStreamer]] \n- [[https://opencv.org][OpenCV]]\n* 通信\n上位机与下位机之间使用 [[https://wikipedia.org/wiki/JSON][JSON]] 数据包通过 [[https://wikipedia.org/wiki/Transmission_Control_Protocol][TCP]] 协议进行通信，一个数据包可以包含任意数量的有效命令，基本框架如下：\n#+BEGIN_SRC json\n  {\n      \"command1\" : null,\n      \"command2\" : \"arg\",\n      \"command3\" : [\"arg1\", \"arg2\"],\n      \"command4\" : { \"key1\": \"value1\", \"key2\": \"value2\" }\n      // ...\n  }\n#+END_SRC\n当前有效的发送命令如下：\n| 命令                               | 描述                    |\n|------------------------------------+-------------------------|\n| ~x~                                  | 控制机器人左右平移      |\n| ~y~                                  | 控制机器人前进或后退    |\n| ~z~                                  | 控制机器人的上浮或下沉  |\n| ~set_debug_mode_enabled~             | 启用/禁用下位机[[调试模式][调试模式]] |\n| ~set_propeller_values~               | [[设置推进器输出][设置推进器输出]]          |\n| ~set_propeller_parameters~           | [[设置参数][设置推进器参数]]          |\n| ~set_control_loop_parameters~        | [[设置参数][设置控制环参数]]          |\n| ~set_propeller_pwm_freq_calibration~ | 设置 PWM 频率           |\n| ~save_parameters~                    | 保存参数                |\n| ~load_parameters~                    | 请求读取参数            |\n| ~firmware_update~                    | 进行固件更新            |\n当前有效的接收命令如下：\n| 命令                        | 描述           |\n|-----------------------------+----------------|\n| ~feedbacks~                   | 反馈数据       |\n| ~set_propeller_parameters~    | [[设置参数][设置推进器参数]] |\n| ~set_control_loop_parameters~ | [[设置参数][设置控制环参数]] |\n| ~info~                        | 显示任意信息   |\n** 发送\n*** 控制\n#+BEGIN_SRC json\n  {\n      \"x\"                : 0.0,   // 左右平移\n      \"y\"                : -0.5,  // 前进后退\n      \"z\"                : 0.8,   // 上浮下沉\n      \"rot\"              : 0.1,   // 左右旋转\n      \"catch\"            : 0.0,   // 机械臂\n      \"depth_locked\"     : false, // 深度锁定\n      \"direction_locked\" : true   // 方向锁定\n  }\n#+END_SRC\n*** 设置推进器输出\n#+BEGIN_SRC json\n  {\n      \"set_propeller_values\": {\n          \"front_left\" : 127,     // 推进器名称与输出\n          \"back_right\" : -128\n          // ...\n      }\n  }\n#+END_SRC\n~set_propeller_values~ 命令可以一次性设置多个推进器输出，范围在 ~-128~ 与  ~127~ 之间。\n*** 设置参数\n#+BEGIN_SRC json\n  {\n      \"set_propeller_parameters\": {    // 推进器参数\n          \"back_right\": {              // 推进器名称\n              \"deadzone_upper\" : 8,    // 死区上限\n              \"deadzone_lower\" : -12,  // 死区下限\n              \"power_positive\" : 0.75, // 正向动力百分比\n              \"power_negative\" : 0.75, // 反向动力百分比\n              \"reversed\"       : false,// 是否反转\n              \"enabled\"        : true  // 启用/禁用推进器\n          }\n          // ...\n      },\n      \"set_control_loop_parameters\": { // 控制环参数\n          \"depth_lock\": {              // 控制环名称\n              \"p\" : 1.0,               // 比例调节\n              \"i\" : 2.0,               // 积分调节\n              \"d\" : 0.5                // 微分调节\n          }\n          // ...\n      },\n      \"set_propeller_pwm_freq_calibration\": 0.01\n  }\n#+END_SRC\n*** 读取/保存参数\n**** 读取参数\n上位机向下位机发送：\n#+BEGIN_SRC json\n  { \"load_parameters\" : null }\n#+END_SRC\n下位机接收到该命令后，向上位机发送[[设置参数][设置参数]]数据包。\n**** 保存参数\n上位机向下位机发送：\n#+BEGIN_SRC json\n  { \"save_parameters\" : null }\n#+END_SRC\n下位机接收到该命令后，将[[https://wikipedia.org/wiki/Random-access_memory][内存]]中的参数写入[[https://wikipedia.org/wiki/Non-volatile_memory][非易失性存储器]]中，以便记忆设置的参数。\n*** 调试模式\n**** 启用调试模式\n上位机向下位机发送：\n#+BEGIN_SRC json\n  { \"set_debug_mode_enabled\": true }\n#+END_SRC\n下位机收到命令后将启用调试模式。\n**** 禁用调试模式\n上位机向下位机发送：\n#+BEGIN_SRC json\n  { \"set_debug_mode_enabled\": false }\n#+END_SRC\n下位机收到命令后将禁用调试模式。\n*** 固件更新\n上位机先向下位机发送：\n#+BEGIN_SRC json\n  {\n      \"firmware_update\": {\n          \"size\"        : 12345678,                          // 数据包大小\n          \"compression\" : \"none\",                            // 压缩方式：\"gzip\" 、\"none\"\n          \"md5\"         : \"3f89ba32a56cb03b5d4e93ed2d033f75\" // MD5 校验\n      }\n  }\n#+END_SRC\n然后直接向下位机发送以 ~compression~ 方式压缩的二进制流。下位机接收到此命令后，\n立即准备接收长度为 ~size~ 的数据包。下位机接收完成后，以 ~compression~ 方式解压并对解压后的数据进行 [[https://wikipedia.org/wiki/MD5][MD5]] 校验。\n如果校验的结果与 ~md5~ 一致，直接替换下位机可执行文件，然后重启完成固件更新。\n** 接收\n*** 反馈\n上位机支持在调节控制环时，通过图表的方式实时可视化显示下位机传感器数据，\n下位机以一定时间间隔向上位机发送反馈数据：\n#+BEGIN_SRC json\n  {\n      \"feedbacks\": {\n          \"control_loops\": {\n              \"depth_lock\"     : 1.0,\n              \"direction_lock\" : -1.0\n              // ...\n          }\n      }\n  }\n#+END_SRC\n上位机接收到数据后，显示的图表会根据用户设置进行更新。\n*** 信息\n上位机支持在操作机器人过程中，实时显示机器人的信息，如航向角、舱内温度等。\n下位机可以向上位机发送任何想要显示的信息：\n#+BEGIN_SRC json\n  {\n      \"info\": {\n          \"温度\"   : \"25℃\",\n          \"航向角\" : \"37°\"\n          // ...\n      }\n  }\n#+END_SRC\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbohonghuang%2Frov-host","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbohonghuang%2Frov-host","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbohonghuang%2Frov-host/lists"}