学习如何创建和管理复杂的无人船任务。
1. 航点任务 (Waypoint Mission)
Section titled “1. 航点任务 (Waypoint Mission)”最常用的任务类型,USV 按顺序访问指定的航点。
适用场景:
- 水质采样
- 巡逻监控
- 数据采集
示例:
mission: type: "waypoint" waypoints: - lat: 31.2304 lon: 121.4737 altitude: 0 speed: 52. 区域巡航 (Area Survey)
Section titled “2. 区域巡航 (Area Survey)”在指定区域内按规定模式巡航。
巡航模式:
- 栅格模式 (Grid)
- 螺旋模式 (Spiral)
- 蛇形模式 (Snake)
示例:
mission: type: "area_survey" area: type: "polygon" coordinates: - [31.2304, 121.4737] - [31.2354, 121.4787] - [31.2404, 121.4787] - [31.2354, 121.4737]
pattern: "grid" spacing: 50 # 米 angle: 0 # 度3. 轨迹跟踪 (Path Following)
Section titled “3. 轨迹跟踪 (Path Following)”沿预定义的连续路径行驶。
适用场景:
- 河道巡查
- 管线检测
- 航道测量
示例:
mission: type: "path_following" path: type: "line" # line, curve, spline points: - [31.2304, 121.4737] - [31.2324, 121.4757] - [31.2344, 121.4777]
speed: 5 tolerance: 2 # 米4. 目标跟踪 (Target Tracking)
Section titled “4. 目标跟踪 (Target Tracking)”自动跟踪移动目标。
适用场景:
- 船只跟踪
- 漂浮物监测
示例:
mission: type: "target_tracking" target: id: "target-001" type: "vessel"
tracking: distance: 50 # 保持距离(米) update_rate: 1 # Hz max_speed: 10 # 节任务规划工具
Section titled “任务规划工具”Web 规划器
Section titled “Web 规划器”使用 Web 界面进行可视化规划:
- 打开控制台:
http://localhost:8080/planner - 选择任务类型
- 在地图上标记航点或区域
- 设置参数
- 预览路径
- 保存任务
使用 CLI 工具创建任务:
# 创建航点任务jhusv mission create waypoint \ --name "water_survey" \ --waypoint 31.2304,121.4737 \ --waypoint 31.2354,121.4787 \ --speed 5
# 创建区域巡航jhusv mission create area \ --name "harbor_patrol" \ --area area.geojson \ --pattern grid \ --spacing 50Python API
Section titled “Python API”使用 Python 编程创建任务:
from jhusv import Mission, Waypoint
# 创建任务mission = Mission(name="water_quality_survey")
# 添加航点wp1 = Waypoint(lat=31.2304, lon=121.4737, speed=5)wp1.add_action("sample", duration=60)
wp2 = Waypoint(lat=31.2354, lon=121.4787, speed=5)wp2.add_action("photo")
mission.add_waypoints([wp1, wp2])
# 设置任务参数mission.set_auto_return(True)mission.set_max_time(3600)
# 保存任务mission.save("water_survey.yaml")根据条件执行不同动作:
waypoints: - lat: 31.2304 lon: 121.4737 actions: - type: "conditional" condition: "water_temp > 25" then: - type: "sample" duration: 120 else: - type: "sample" duration: 60重复执行任务:
mission: type: "waypoint" loop: enabled: true count: 3 # 重复次数(0 = 无限) interval: 600 # 循环间隔(秒)在任务执行中动态添加航点:
from jhusv import MissionController
controller = MissionController()
# 执行任务中添加航点new_waypoint = Waypoint(lat=31.2404, lon=121.4837)controller.insert_waypoint(new_waypoint, index=2)串联多个任务:
mission_chain: - mission: "survey_area_1.yaml" - mission: "survey_area_2.yaml" - mission: "return_to_base.yaml"
options: stop_on_error: true auto_continue: true优化航点顺序以减少距离:
jhusv mission optimize \ --input mission.yaml \ --algorithm tsp \ --output optimized.yaml估算任务完成时间:
jhusv mission estimate mission.yaml输出:
Total Distance: 2.5 kmAverage Speed: 5 knotsEstimated Time: 27 minutesBattery Usage: 35%根据电池电量规划任务:
mission: battery_management: enabled: true reserve_percent: 25 # 保留电量百分比 return_threshold: 30 # 返航阈值
# 自动分段 auto_split: true segment_distance: 2000 # 米限制 USV 活动范围:
geofence: enabled: true mode: "hard" # hard(硬限制),soft(警告)
# 方式 1:多边形围栏 polygon: - [31.2304, 121.4737] - [31.2354, 121.4787] - [31.2404, 121.4837] - [31.2354, 121.4887]
# 方式 2:圆形围栏 # circle: # center: [31.2354, 121.4787] # radius: 1000 # 米
action: "return_home" # 超出围栏后的动作自动避障配置:
obstacle_avoidance: enabled: true detection_range: 30 # 米 safety_distance: 15 # 米
sensors: - type: "sonar" enabled: true - type: "camera" enabled: true
strategy: "potential_field" # potential_field, rrt, apf定义紧急情况的处理:
emergency: # 低电量 low_battery: threshold: 20 # % action: "return_home"
# 失去连接 lost_connection: timeout: 60 # 秒 action: "hold_position"
# 如果长时间失联 extended_timeout: 300 extended_action: "return_home"
# 恶劣天气 bad_weather: wind_threshold: 12 # m/s wave_threshold: 1.5 # 米 action: "seek_shelter"多艘 USV 协同作业:
formation_mission: usvs: - id: "USV-001" role: "leader" - id: "USV-002" role: "follower" offset: [20, 0] # 相对位置(米) - id: "USV-003" role: "follower" offset: [-20, 0]
formation: type: "line" # line, triangle, diamond spacing: 50
mission: type: "area_survey" area: "area.geojson"保存常用任务为模板:
jhusv template create \ --from mission.yaml \ --name "water_quality_template"从模板创建新任务:
jhusv mission new \ --template "water_quality_template" \ --param area="area2.geojson" \ --output new_mission.yaml内置模板:
water_quality_survey- 水质监测harbor_patrol- 港口巡逻coastline_mapping- 海岸线测绘emergency_search- 应急搜索
✅ 必做事项:
- 检查天气预报
- 确认电池电量充足
- 验证地理围栏设置
- 测试通信连接
- 检查传感器状态
任务设计原则
Section titled “任务设计原则”- 航点间距: 建议 > 50m
- 速度设置: 根据海况调整(3-8节)
- 任务时间: 预留 30% 余量
- 数据采样: 避免过高频率(建议 ≤ 10Hz)
# 1. 验证任务文件jhusv mission validate mission.yaml
# 2. 预览任务路径jhusv mission preview mission.yaml
# 3. 模拟执行jhusv mission simulate mission.yaml --duration 60
# 4. 实际执行jhusv mission start mission.yaml- 📊 了解 数据管理
- 🔌 探索 Control API
- 🛠️ 查看 故障排除
案例 1: 湖泊水质监测
Section titled “案例 1: 湖泊水质监测”mission: name: "lake_water_quality" type: "area_survey"
area: type: "polygon" coordinates: [[...]]
pattern: "grid" spacing: 100
sensors: water_quality: enabled: true sample_rate: 0.5 parameters: ["ph", "do", "temp"]
duration: 7200案例 2: 港口安全巡逻
Section titled “案例 2: 港口安全巡逻”mission: name: "harbor_patrol" type: "waypoint" loop: enabled: true count: 0
waypoints: [[...]]
sensors: camera: enabled: true recording: true radar: enabled: true alert_on_target: true案例 3: 应急搜救
Section titled “案例 3: 应急搜救”mission: name: "emergency_search" type: "spiral"
center: [31.2354, 121.4787] max_radius: 1000 spacing: 20
sensors: camera: enabled: true ai_detection: true targets: ["person", "debris"]
priority: "high"