-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
283 additions
and
49 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
FROM ubuntu:jammy | ||
|
||
RUN echo "chooses:\n" > fish_install.yaml \ | ||
&& echo "- {choose: 5, desc: '一键安装:ROS(支持ROS和ROS2,树莓派Jetson)'}\n" >> fish_install.yaml \ | ||
&& echo "- {choose: 2, desc: 更换源继续安装}\n" >> fish_install.yaml \ | ||
&& echo "- {choose: 1, desc: 清理三方源}\n" >> fish_install.yaml \ | ||
&& apt update && apt install wget python3 python3-distro python3-yaml -y \ | ||
&& wget http://fishros.com/install -O fishros && /bin/bash fishros \ | ||
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \ | ||
&& apt-get clean && apt autoclean \ | ||
&& rm -rf fish_install.yaml | ||
|
||
# RUN DEBIAN_FRONTEND=noninteractive apt install -y tzdata | ||
|
||
|
||
RUN apt-get update && apt-get install -y \ | ||
fonts-wqy-zenhei \ | ||
libgl1 \ | ||
libegl1 \ | ||
&& apt-get clean && apt-get autoclean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* | ||
|
||
COPY "dist/f1.alpha_linux_x64" /fishbot | ||
RUN chmod +x /fishbot | ||
ENTRYPOINT ["/fishbot"] | ||
|
||
# docker run -it --rm --privileged -v /dev:/dev -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=unix$DISPLAY fishbot-tool |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,49 @@ | ||
# 配置工具 | ||
# FishBot配置工具 | ||
|
||
支持设备: | ||
- FishBot二驱板 | ||
- FishBot四驱动板 | ||
- FishBot_Camera无线摄像头 | ||
|
||
## 源码使用 | ||
|
||
首先克隆代码到本地,接着安装 PyQt6,PySide6,pyserial,esptool | ||
## 使用方法(可视化版) | ||
|
||
### 1.直接下载(推荐) | ||
|
||
到[release](https://github.com/fishros/fishbot_tool/releases)页面下载构好的二进制文件(Linux需要下载后右击勾选可执行)双击运行即可。 | ||
|
||
### 2.Docker使用 | ||
|
||
首先确保你的电脑安装了Docker,然后直接运行以下命令(注意,最新版本需要到release页面查看): | ||
|
||
``` | ||
xhost + && sudo docker run -it --rm --privileged -v /dev:/dev -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=unix$DISPLAY fishros2/fishbot-tool:v1.0.0.20240219 python3 main.py | ||
``` | ||
|
||
### 3.源码使用 | ||
首先克隆代码到本地,接着安装 PyQt6,pyserial,esptool,requests | ||
``` | ||
sudo apt install python3-pip | ||
sudo pip3 install PyQt6 PySide6 pyserial esptool -i https://pypi.tuna.tsinghua.edu.cn/simple | ||
sudo pip3 install PyQt6 requests pyserial esptool -i https://pypi.tuna.tsinghua.edu.cn/simple | ||
``` | ||
|
||
接着执行 | ||
接着执行(注意Linux下要给串口设备权限) | ||
|
||
``` | ||
cd fishbot_tool/fishbot_tool/ | ||
sudo DISPLAY=unix$DISPLAY python3 main.py | ||
python3 main.py | ||
``` | ||
|
||
|
||
## 快速使用 | ||
## 使用方法(无界面版本) | ||
|
||
安装好Docker,在你的终端输入下面代码,既可使用 | ||
安装好Python3.8+,到release页面下载fishbot_tool_cli.py,接着执行: | ||
|
||
``` | ||
docker run -it --rm --privileged -v /dev:/dev fishros2/fishbot-tool python main.py | ||
python fishbot_tool_cli.py | ||
``` | ||
|
||
最后根据提示使用即可。 | ||
|
||
## 设计思考 | ||
|
||
``` | ||
功能列表 | ||
固件相关 | ||
1.烧录fishbot固件(手动选择软件版本) | ||
2.烧录雷达转接板固件(只做一个固件即可) | ||
配置相关 | ||
1.配置雷达转接板波特率等(wifi&ip&port&baut) | ||
2.配置运动控制板相关内容(wifi&ip&port&reduce&pid) | ||
``` | ||
|
||
- Autor: [fishros](https://github.com/fishros) |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
import os | ||
import sys | ||
|
||
def check_installation(package_name,install_pkg): | ||
try: | ||
__import__(package_name) | ||
return True | ||
except ImportError: | ||
print(f'{package_name} 未安装,尝试安装') | ||
os.system(f'pip install {install_pkg}') | ||
return False | ||
|
||
check_installation('serial',"pyserial") | ||
check_installation('esptool','esptool') | ||
check_installation('requests','requests') | ||
|
||
import serial #导入模块 | ||
import serial.tools.list_ports | ||
import requests | ||
import time | ||
|
||
|
||
def list_serial_ports(): | ||
port_list = list(serial.tools.list_ports.comports()) | ||
if len(port_list) == 0: | ||
print('无可用串口,请插入串口设备') | ||
return False | ||
else: | ||
print('当前可用串口有:') | ||
for i in range(0,len(port_list)): | ||
print(port_list[i].name) | ||
return True | ||
|
||
def download_firmware(firmware_path): | ||
print('将测到固件在HTTP路径上,开始下载') | ||
response = requests.get(firmware_path, stream=True) | ||
response.raise_for_status() | ||
|
||
filename = os.path.basename(firmware_path) | ||
with open(filename, 'wb') as file: | ||
for chunk in response.iter_content(chunk_size=1024): | ||
if chunk: | ||
file.write(chunk) | ||
|
||
print(f'下载完成:{filename}') | ||
return filename | ||
|
||
def flash_firmware(): | ||
firmware_path = 'firmware.bin' | ||
while not os.path.exists(firmware_path): | ||
print(f"提示:{firmware_path}固件文件不存在,请重新输入") | ||
firmware_path = input("请输入固件文件路径(可以是网址): ") | ||
if firmware_path.startswith('http'): | ||
firmware_path = download_firmware(firmware_path) | ||
|
||
|
||
while list_serial_ports()==False: | ||
time.sleep(1) | ||
port = input("请输入要烧录的串口设备名称: ") | ||
|
||
flash_command = f'esptool.py --port {port} write_flash 0x00000 {firmware_path}' | ||
os.system(flash_command) | ||
|
||
|
||
|
||
def config_board(key: str, value: str, port='/dev/ttyUSB0', baudrate=115200): | ||
try: | ||
ser = serial.Serial(port, baudrate) | ||
except: | ||
return {"error": "串口打开异常,请检查设备是否被占用"} | ||
|
||
config_str = f"${key}={value}\n".encode() | ||
print(f"发送 {str(config_str)} 到 {ser.port}") | ||
ser.write(config_str) | ||
start_time_timeout = time.time() | ||
recv_avaliable_data = False | ||
while (time.time()-start_time_timeout < 5) and (not recv_avaliable_data): | ||
print("开始接收...") | ||
try: | ||
recv = ser.read_all().decode() | ||
print(f"尝试接收..{recv}") | ||
time.sleep(0.5) | ||
if len(recv) > 0: | ||
print(f"接收到有效数据 :{recv}") | ||
recv_avaliable_data = True | ||
except Exception as e: | ||
print(e) | ||
|
||
if len(recv) == 0: | ||
return {"error": "串口数据异常,请确认设备在配置模式"} | ||
|
||
result = {} | ||
lines = recv.splitlines() | ||
for line in lines: | ||
if len(line) > 0 and line[0] == '$': | ||
split_result = line[1:].split("=") | ||
if len(split_result) == 2: | ||
result[split_result[0]] = split_result[1] | ||
ser.close() | ||
if len(result) == 0: | ||
return {"error": "串口数据异常,请确认设备在配置模式"} | ||
return result | ||
|
||
|
||
def restart_device_bt_rst(port): | ||
try: | ||
ser = serial.Serial(port, baudrate=74880) | ||
ser.setRTS(False) | ||
ser.setDTR(False) | ||
time.sleep(0.2) | ||
ser.setRTS(True) | ||
ser.setDTR(True) | ||
time.sleep(0.2) | ||
time.sleep(0.1) | ||
return "[提示]发送RTS成功!" | ||
except Exception as e: | ||
ser.close() | ||
print(e) | ||
return {"error": "串口打开异常,请检查设备是否被占用"} | ||
|
||
|
||
def print_help(): | ||
print("使用方法:") | ||
print(" python fishbot_tool_cli.py list_port - 列出可用的串口") | ||
print(" python fishbot_tool_cli.py flash - 下载固件") | ||
print(" python fishbot_tool_cli.py read_config COMX - 读取配置,COMX替换为设备编号") | ||
print(" python fishbot_tool_cli.py config name value - 设置配置项") | ||
print(" python fishbot_tool_cli.py - 打印帮助信息") | ||
|
||
|
||
def main(): | ||
if len(sys.argv) == 1: | ||
print_help() | ||
elif sys.argv[1] == 'list_port': | ||
list_serial_ports() | ||
elif sys.argv[1] == 'flash': | ||
flash_firmware() | ||
elif sys.argv[1] == 'read_config': | ||
if len(sys.argv)!=3: | ||
print('请在read_config后添加你要读取的设备串口号') | ||
return | ||
all_configs = config_board("command", "read_config", port=sys.argv[2], baudrate=115200) | ||
print(all_configs) | ||
elif sys.argv[1] == 'config': | ||
if len(sys.argv)!=5: | ||
print('请在config后添加你的:设备号 配置项 配置值') | ||
return | ||
result = config_board(sys.argv[3], sys.argv[4], port=sys.argv[2], baudrate=115200) | ||
print(result) | ||
else: | ||
print("未知的命令") | ||
print_help() | ||
|
||
if __name__ == "__main__": | ||
main() |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
- [feat]发布Linux可执行文件(下载后给可执行权限双击运行) | ||
- [feat]改用docker发布模式 | ||
- [feat]添加无界面版本fishbot_tool_cli.py | ||
|
||
版本说明: | ||
- alpha:内部测试版本(不建议使用) | ||
- beta:新功能测试版本(可以尝试) | ||
- release:最终测试版本(推荐) | ||
|
||
使用说明: | ||
- 国内用户可以使用[代理工具](http://github.fishros.org)下载 |
This file contains 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
Oops, something went wrong.