在调研 matplotlib 动态绘制曲线方法中,和 matlab 相似有 animation 方法和交互式绘图,但是 animation 方法灵活性不高,不太适合路径的实时动态显示,本文最后采用交互式绘图模(interactive mode)-- Using matplotlib in a python shell。
The interactive property of the pyplot interface controls whether a figure canvas is drawn on every pyplot command. If interactive is False, then the figure state is updated on every plot command, but will only be drawn on explicit calls to draw(). When interactive is True, then every pyplot command triggers a draw.
# -*- coding: utf-8 -*- """ Created on Sat Mar 25 23:28:29 2017 @author: wyl original link: https://www.yanlongwang.net/Python/python-interactive-mode/ """
import matplotlib.pyplot as plt from matplotlib.patches import Circle import numpy as np import math plt.close() #clf() # 清图 cla() # 清坐标轴 close() # 关窗口 fig=plt.figure() ax=fig.add_subplot(1,1,1) ax.axis("equal") #设置图像显示的时候XY轴比例 plt.grid(True) #添加网格 plt.ion() #interactive mode on IniObsX=0000 IniObsY=4000 IniObsAngle=135 IniObsSpeed=10*math.sqrt(2) #米/秒 print('开始仿真') try: for t inrange(180): #障碍物船只轨迹 obsX=IniObsX+IniObsSpeed*math.sin(IniObsAngle/180*math.pi)*t obsY=IniObsY+IniObsSpeed*math.cos(IniObsAngle/180*math.pi)*t ax.scatter(obsX,obsY,c='b',marker='.') #散点图 #ax.lines.pop(1) 删除轨迹 #下面的图,两船的距离 plt.pause(0.001) except Exception as err: print(err)
Posted onEdited onInUSVWord count in article: 973Reading time ≈4 mins.
[toc]
Unmanned surface vehicles (USVs) are autonomous marine vessels that can execute multiple tasks in a variety of cluttered marine environments without human supervision. The future progress of USVs depends on the development of full autonomy, which would enable USVs to work in any unstructured or unpredictable environment without human intervention.
One of the main challenges in enhancing USV autonomy is the simultaneous detection and avoidance of obstacles in either open or confined waters. Local obstacle avoidance for USVs is used to avoid static and dynamic obstacles by adopting a timely avoidance manoeuvre. Local obstacle avoidance algorithms are of two types: path searching-based local path planning, which can generate appropriate trajectories or waypoints followed by the vehicle, and the behaviour-based reactive obstacle avoidance method, which can generate the guidance angle and guidance velocity realized by the navigation controller in real time.
A novel path searching-based algorithm called the local normal distribution-based trajectory (LNDT) is proposed in this paper to address the local obstacle avoidance problem of USVs in complicated encounter situations. The design and implementation of LNDT has been published in Ocean Engineering with reference link. Besides, there is a copy only for personal research purpose.
The following sections mainly discuss the implementation principle of the algorithm and provide some critical information to facilitate the following researchers. About the detailed information, you can refer my master thesis - Research on the Technology of Path Planning for Unmanned Surface Vehicle, while it is written in Chinese. The LNDS method is mainly extracted from my master thesis and polished in simulation.
Abstract
英文在中文之后 / English follows Chinese
本文讲述了一种新型的、遵守 COLREGs 规则的无人水面艇 (USV) 自动避障方法的初步研究结果。这个方法本质上是一种基于路径搜索的算法,称为局部正态分布轨迹法,该算法可以在存在静态和动态障碍物的情况下规划出可行的避障轨迹。算法可以根据正态分布的钟形曲线生成符合 COLREGs 的次优轨迹,并提取航路点以供导航控制器安全操纵 USV。此外,我们讨论了构成钟形曲线的三个关键参数,并提出了一种轨迹重新规划策略,以提高该方法的安全性和灵活性。我们在实验中模拟了常见的超车、交叉和正面碰撞情况来验证算法,仿真表明该方法考虑了多个因素,可以规划出能够安全、平滑地避开障碍物的路径。此外,该方法还和另一种遵守 COLREGs 规则的反应式避障方法做了比较。
This paper reports the preliminary research results of a novel automatic obstacle avoidance approach based on the COLREGs for unmanned surface vehicles (USVs). The approach presented is essentially a path searching-based algorithm called the local normal distribution-based trajectory, which plans viable avoidance trajectories in the presence of both static and dynamic obstacles. The proposed algorithm can generate a COLREGs-compliant suboptimal trajectory based on the bell-shaped curve of normal distribution and extract waypoints for the navigation controller to steer USVs safely. In addition, we discuss three key parameters and present a trajectory replanning strategy to improve the safety and flexibility of our approach. The common overtaking, crossing and head-on collision scenarios are each simulated in experiments. It is shown through simulations that the proposed approach considers multiple factors and can plan paths to avoid obstacles safely and smoothly. A comparison is also made with a reactive path planning algorithm which has been modified to follow the COLREGs.
Design and Implementation
The overall scheme of obstacle avoidance is illustrated in following figure. The decision-making module in the dashed frame includes a two-layered distributed architecture of obstacle avoidance; we primarily study the COLREGs-based obstacle avoidance approach.
The LNDT algorithm includes six processes, as shown below. We first integrates COLREGs rules into the obstacle avoidance approach of USVs. When there is a collision risk, it would determine three key parameters of the trajectory by a fixed procedure, and the primitive trajectory would be rotated and translated to adapt the real collision scenario. The USV then follows the planned trajectories. We would replan the trajectory once USVs can not follow the planned trajectory.
Besides, we propose a scalable and flexible obstacle avoidance architecture. And we proposes six evaluation indicators to establish a scientific and impartial obstacle avoidance behaviour assessment (OABA) method in this paper.
Others
The LNDT algorithm is mainly implemented in 2018, and it has not been tested in complex sea trial, so there must be some drawbacks to improve.
In order to put it into wide practice, I’m glad to discuss some topics with you via email and polish this method, even share part of the source code with you.
水面无人艇 (Unmanned Surface Vehicles, USVs) 是一种新型的水面智能载具,其中全局路径规划是 USV 研究的关键技术,它可以反映出 USV 的智能程度。为了解决 USV 的全局路径规划问题,本文基于电子海图提出航行代价寻优 (sailing cost optimization) 的改进 A * 算法。我们使用 S-57 电子海图实现八叉树网格的环境模型建立,并基于航行安全权重、引导量和路径曲线平滑处理,提出优化的 A * 算法来实现规划路径航行安全,减少规划时间,提高路径平滑度。仿真结果表明,环境建模方法和改进 A * 算法可以规划出安全合理的全局路径。
Unmanned Surface Vehicle (USV) is a new type of intelligent surface boat, and global path planning is the key technology of USV research, which can reflect the intelligent level of USV. In order to solve the problem of global path planning of USV, this paper proposes an improved A* algorithm for sailing cost optimization based on electronic chart. This paper uses the S-57 electronic chart to realize the establishment of the octree grid environment model, and proposes an improved A* algorithm based on sailing safety weight, pilot quantity and path curve smoothing to ensure the safety of the route, reduce the planning time, and improve path smoothness. The simulation results show that the environmental model construction method and the improved A* algorithm can generate safe and reasonable global path.
本文提出基于电子海图的 USV 全局路径规划方案,分为电子海图解析、全局环境模型建立和路径搜索算法三部分。通过解析电子海图文件,提取其中的海域地理信息及碍航物等信息,将海图信息渲染成为自主航路规划系统能够识别的信息模式,建立由可航行网格和不可航行网格组成的环境模型。在此基础上,本文综合考虑航行安全性、航行距离、路径平滑度等因素,采用基于航行代价寻优的改进 A * 算法来搜索环境模型中的最优路径,实现水面无人艇的全局航路自主规划,提高水面无人艇的自主决策能力和智能化水平。
水面无人艇全局路径规划系统无法直接利用电子海图进行自主路径规划,所以需要研究矢量电子海图 S-57 数据结构,提取出全局路径规划需要的海洋环境信息,裁剪无关数据,将电子海图转换为全局航路规划系统能够直接使用的信息。其中,利用开源的 TinyXML 库保存到 xml 文件中,供路径规划系统的后续分析和处理。
在提取得到电子海图 xml 文件后,通过网格化的方法把感兴趣区域划分为若干块大小相等的矩形网格,然后利用 Shapely 开源地理库依次判断网格中是否存在从电子海图中解析的静态障碍物(如陆地、海岛、浅滩),从而将网格环境地图划分为可航区域和不可航区域。
在实现环境建模后,全局路径搜索算法优化的目标是在确保航行安全性的前提下,尽可能使规划的路径航行代价最小,最大程度地减小与最短路径、最小航行代价无关的计算量。其中,Hart 等使用启发式函数来评估从初始点到目标点的代价,在 Dijkstra 算法基础上,结合启发式函数形成新的路径搜索策略–A * 算法,通过减少搜索空间来提高搜索效率,所以更适合网格情形下的全局路径规划。本文对传统的 A * 算法进行改进,实现全局路径的初步搜索。
网格环境下,如果直接把 A * 算法搜索得到的节点顺序连接起来作为水面无人艇的全局规划路径,通常会出现阶梯或者锯齿状路径的情况,很明显规划的路径并不是两点间的期望路径。所以,本文提出去除多余航点的曲线平滑算法,在保证安全的前提下减少路径中不必要的航点,使多段折线化为直线,增加路径的光滑度,规划的路径会更加符合起止点之间的期望路径,符合水面无人艇的运动学特性。
英文在中文之后 / English follows Chinese
全局路径规划是水面无人艇设计的关键技术之一。本文基于电子海图和六边形网格建立全局环境模型,并且证明六边形网格在有效性,安全性和快速性方面优于传统的正方形网格。此外,本文引入 Cube 坐标系来简化六边形坐标运算。进一步地,我们提出了一种改进的 A * 算法来实现两点之间的路径规划。在此基础上,我们构建了多个任务点的全局路径规划模型,并提出了一种改进的蚁群优化算法来准确实现多任务点的全局路径规划。仿真结果表明,全局路径规划系统可以安全、快速地规划出多个任务点的最优路径,在安全性,快速性和路径长度方面均优于传统方法。此外,全局规划路径可直接用于 USV 的实际场景。
Global path planning is the key technology in the design of unmanned surface vehicles. This paper establishes global environment modelling based on electronic charts and hexagonal grids which are proved to be better than square grids in validity, safety and rapidity. Besides, we introduce Cube coordinate system to simplify hexagonal algorithms. Furthermore, we propose an improved A* algorithm to realize the path planning between two points. Based on that, we build the global path planning modelling for multiple task points and present an improved ant colony optimization to realize it accurately. The simulation results show that the global path planning system can plan an optimal path to tour multiple task points safely and quickly, which is superior to traditional methods in safety, rapidity and path length. Besides, the planned path can directly apply to actual applications of USVs.
The S-57 reader depends on having two supporting files, s57objectclasses.csv, and s57attributes.csv available at runtime in order to translate features in an object class specific manner. These should be in the directory pointed to by the environment variable S57_CSV, or in the current working directory.
保存到 xml 文件中
因为项目需要,需要把 S-57 文件里特定图层的信息提取出来,S-57 文件解析后,把感兴趣的信息保存到 xml 文件中,方便后续的处理。
在 C++ 中,对 XML 文件处理中,使用一个开源的解析 XML 的解析库 – TinyXML,这个解析库的模型通过解析 XML 文件,然后在内存中生成 DOM 模型,从而让我们很方便的遍历这棵 XML 树。
Posted onEdited onInEnglishWord count in article: 977Reading time ≈4 mins.
[toc]
音标
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
graph LR A[音标_48个] --> B(元音音标_20个) A --> C(辅音音标_28个) B --> D(元音是构成英文单词发音的基本元素) D --> E(单元音) D --> F(双元音) B --> G(发音时声带振动且气流在通路上不受发音器官阻挡的是元音) C --> H(发音时气流在通路上受到发音器官阻挡的是辅音)
G --> I(舌位不移动,在发音过程中没有摩擦,不受发音器官的任何阻碍) F --> J(双元音的发音要领是发音饱满,舌行和唇形都要到位) C --> K(辅音依元音而存在,与元音配合产生音节) H --> L(清辅音) L --> M(发音时声带不振动,送气的叫清辅音) H --> N(浊辅音) N --> O(发音时声带振动,不送气的叫浊辅音)