Ejemplo n.º 1
0
    def Drawing(self):
        point_1 = []
        x, y = self.UTM_get()
        for i in range(0, len(x)):
            point = []
            point.append(x[i])
            point.append(y[i])
            point_1.append(point)

        path_width, offset_width, turn_r = self.Path_Info()
        path_width = path_width * 10
        # 扫描线间隔距离(车辆工作幅宽)
        # path_width = 4 * 10  # 全部数据扩大10倍,画图时在缩小即可,扫描线间隔是4(原因是程序中i不能产生浮点数)
        # 偏置距离(根据转弯来计算)
        d = int(path_width / 10)
        d_ = int(d * (offset_width + 1))
        point_ = []

        # 调用偏置程序 (import Polygon_offset as Pol)
        for x in range(0, d_, d):
            a = cal.Shrink(x, *point_1)
            point_.append(a)
        point_offset = point_[int((d_ / d) - 1)]

        # 多边形顶点数
        POINTNUM_1 = len(point_offset)
        point_1.append(point_1[0])
        P_x_ = []
        P_y_ = []
        for p in point_1:
            P_x_.append(p[0])
            P_y_.append(p[1])
        self.F.axes.plot(P_x_, P_y_)

        for i in range(1, int((d_ / d) - 1)):
            point_[i].append(point_[i][0])
            P_x_ = []
            P_y_ = []
            for p in point_[i]:
                P_x_.append(p[0])
                P_y_.append(p[1])
            self.F.axes.plot(P_x_, P_y_, color='red', linewidth=1)

        Polygon_1 = point_offset
        X = []
        Y = []
        for i in range(POINTNUM_1):
            x = (Polygon_1[i][0])
            y = (Polygon_1[i][1])
            X.append(x)
            Y.append(y)
        X.append(Polygon_1[0][0])
        Y.append(Polygon_1[0][1])
        # 调用algorithm中polyScan_Draw函数画图
        algorithm.polyScan_Draw(self, point_1, point_offset, path_width)

        # 转弯部分
        min_angle, min_distance = algorithm.polyScan(point_1, point_offset,
                                                     path_width)

        top_point, low_point = algorithm.Rec_turn_point(
            self, point_1, point_offset, path_width)
        # print('low_point', low_point)
        # print('top_point', top_point)
        # 首先解决row_list,应该在算法部分,目前随便定义一下(可以连接为经验算法),后面修改
        row_list = []
        for i in range(0, len(low_point)):
            row_list.append(i)
        # 然后是转弯名称all_turn_name
        all_turn_name = []
        for i in range(0, len(low_point)):
            all_turn_name.append('U')  # 定义转弯方式
        # row_list和all_turn_name为算法求解部分

        all_turn = cal.All_Turn(self, point_1, point_offset, path_width,
                                row_list, turn_r, all_turn_name, min_angle)
        # print('all_turn', all_turn)
        for x in all_turn:
            self.F.axes.plot(x[0], x[1], color="red", linewidth=2)

        # 这一部分放在algorithm.py中,放这里会运行2次,加大计算量.
        # 结果展示内容
        # self.textBrowser.setText("最优角度: " + str(min_angle) + "\n最短距离: " + str(min_distance))
        self.F.axes.plot(X, Y, color='red', linewidth=1)
        self.F.axes.axis('equal')
        self.horizontalLayout.addWidget(self.F)
Ejemplo n.º 2
0
    def Drawing(self):
        point_1 = []
        x, y = self.UTM_get()
        for i in range(0, len(x)):
            point = []
            point.append(x[i])
            point.append(y[i])
            point_1.append(point)

        path_width, offset_width, turn_r = self.Path_Info()
        path_width = path_width * 10
        # 扫描线间隔距离(车辆工作幅宽)
        # path_width = 4 * 10  # 全部数据扩大10倍,画图时在缩小即可,扫描线间隔是4(原因是程序中i不能产生浮点数)
        # 偏置距离(根据转弯来计算)
        d = int(path_width / 10)
        d_ = int(d * (offset_width + 1))
        point_ = []

        # 调用偏置程序 (import Polygon_offset as Pol)
        for x in range(0, d_, d):
            a = cal.Shrink(x, *point_1)
            point_.append(a)
        point_offset = point_[int((d_ / d) - 1)]

        # 多边形顶点数
        POINTNUM_1 = len(point_offset)
        point_1.append(point_1[0])
        P_x_ = []
        P_y_ = []
        for p in point_1:
            P_x_.append(p[0])
            P_y_.append(p[1])
        self.F.axes.plot(P_x_, P_y_)

        for i in range(1, int((d_ / d) - 1)):
            point_[i].append(point_[i][0])
            P_x_ = []
            P_y_ = []
            for p in point_[i]:
                P_x_.append(p[0])
                P_y_.append(p[1])
            self.F.axes.plot(P_x_, P_y_, color='red', linewidth=1)

        Polygon_1 = point_offset
        X = []
        Y = []
        for i in range(POINTNUM_1):
            x = (Polygon_1[i][0])
            y = (Polygon_1[i][1])
            X.append(x)
            Y.append(y)
        X.append(Polygon_1[0][0])
        Y.append(Polygon_1[0][1])
        #
        distance_set = []
        angle = 0
        for i in range(0, 180):
            if angle <= 180:
                t_distance = algorithm.polyScan(point_1, point_offset,
                                                path_width, angle)
                distance_set.append(t_distance)
                angle += 1
            else:
                pass
        min_angle = distance_set.index(
            min(distance_set))  # 求最小值在列表中位置,得到的数据其实就是角度大小
        min_distance = min(distance_set)  # 最短距离
        # 结果展示内容
        self.textBrowser.setText("最优角度: " + str(min_angle) + "\n最短距离: " +
                                 str(min_distance))

        # 调用algorithm中polyScan_Draw求解需要的参数
        boundary_point, route_point, top_list, low_list, point = algorithm.polyScan_Draw(
            point_1, point_offset, path_width, min_angle)

        # 转弯部分
        # 首先解决row_list,应该在算法部分,目前随便定义一下(可以理解为经验算法),后面修改
        row_list = []
        for i in range(0, len(low_list)):
            row_list.append(i)
        # 然后是转弯名称all_turn_name
        all_turn_name = []
        for i in range(0, len(low_list)):
            all_turn_name.append('M2')  # 定义转弯方式
        # row_list和all_turn_name为算法求解部分

        all_turn = cal.All_Turn(top_list, low_list, row_list, turn_r,
                                all_turn_name)
        all_turn = cal.Data_Spin(all_turn, min_angle, point)
        # 画转弯线
        for x in all_turn:
            self.F.axes.plot(x[0], x[1], color="red", linewidth=1)

        # 画车辆边界线与车辆路线
        for x in boundary_point:
            self.F.axes.plot(x[0], x[1], color='green', linewidth=0.5)
        for x in route_point:
            self.F.axes.plot(x[0],
                             x[1],
                             color='red',
                             linewidth=0.25,
                             linestyle='--',
                             dashes=[20, 15])

        self.F.axes.plot(X, Y, color='red', linewidth=1)
        self.F.axes.axis('equal')
        self.horizontalLayout.addWidget(self.F)
Ejemplo n.º 3
0
# ax.axis([0, LENGTH, 0, LENGTH])

point_1 = point
print('point_1', point_1)

# 扫描线间隔距离
path_width = 4 * 10  # 全部数据扩大10倍,画图时在缩小即可,扫描线间隔是4(原因是程序中i不能产生浮点数)
# 偏置距离
d = int(path_width / 10)
d_ = d * (2 + 1)
point_ = []

# 调用偏置程序 (import Polygon_offset as Pol)
for x in range(0, d_, d):
    print(x)
    a = cal.Shrink(x, *point_1)
    point_.append(a)

point_offset = point_[int((d_ / d) - 1)]


# 画图部分,此部分画边界,
def paint():
    # 多边形顶点数
    POINTNUM_1 = len(point_offset)

    point_1.append(point_1[0])
    P_x_ = []
    P_y_ = []
    for p in point_1:
        P_x_.append(p[0])
Ejemplo n.º 4
0
    def Drawing_1(self):
        point_1 = []
        x, y = self.UTM_get()
        for i in range(0, len(x)):
            point = []
            point.append(x[i])
            point.append(y[i])
            point_1.append(point)

        path_width, offset_width, turn_r = self.Path_Info()
        path_width = path_width * 10
        # 扫描线间隔距离(车辆工作幅宽)
        # path_width = 4 * 10  # 全部数据扩大10倍,画图时在缩小即可,扫描线间隔是4(原因是程序中i不能产生浮点数)
        # 偏置距离(根据转弯来计算)
        d = int(path_width / 10)
        d_ = int(d * (offset_width + 1))
        point_ = []

        # 调用偏置程序 (import Polygon_offset as Pol)
        for x in range(0, d_, d):
            a = cal.Shrink(x, *point_1)
            point_.append(a)
        point_offset = point_[int((d_ / d) - 1)]

        # 多边形顶点数
        POINTNUM_1 = len(point_offset)

        point_1.append(point_1[0])

        # 偏置程序输出point_1 point_offset path_width point_ d_ d

        # angle = 0
        # for i in range(0, 180):
        #     if angle <= 180:
        # 画线部分
        #############
        # 最外面的多边形
        # self.F.canvas.draw()
        # self.F.canvas.draw_idle()
        # self.F.plt.ion()
        # plt.ion()
        P_x_ = []
        P_y_ = []
        for p in point_1:
            P_x_.append(p[0])
            P_y_.append(p[1])
        self.F.axes.plot(P_x_, P_y_)

        # 中间多边形
        for i in range(1, int((d_ / d) - 1)):
            point_[i].append(point_[i][0])
            P_x_ = []
            P_y_ = []
            for p in point_[i]:
                P_x_.append(p[0])
                P_y_.append(p[1])
            self.F.axes.plot(P_x_, P_y_, color='red', linewidth=1)

        # 最内部的多边形
        Polygon_1 = point_offset
        X = []
        Y = []
        for i in range(POINTNUM_1):
            x = (Polygon_1[i][0])
            y = (Polygon_1[i][1])
            X.append(x)
            Y.append(y)
        X.append(Polygon_1[0][0])
        Y.append(Polygon_1[0][1])
        self.F.axes.plot(X, Y, color='red', linewidth=1)

        angle = 0
        for i in range(0, 181):
            if angle < 180:
                print('angle', angle)
                min_angle = angle
                boundary_point, route_point, top_list, low_list, point = algorithm.polyScan_Draw(
                    point_1, point_offset, path_width, min_angle)
                # 画车辆边界线与车辆路线
                print('boundary_point', boundary_point)
                for x in boundary_point:
                    self.F.axes.plot(x[0], x[1], color='green', linewidth=0.5)
                for x in route_point:
                    self.F.axes.plot(x[0],
                                     x[1],
                                     color='red',
                                     linewidth=0.25,
                                     linestyle='--',
                                     dashes=[20, 15])
                #
                plt.cla()
                self.F.axes.axis('equal')
                # plt.ioff()
                # plt.show()
                self.horizontalLayout.addWidget(self.F)
                print('画图')
                # plt.pause(5)
                angle += 1

            else:
                plt.cla()
Ejemplo n.º 5
0
    def Drawing(self):
        point_1 = []
        x, y = self.UTM_get()
        for i in range(0, len(x)):
            point = []
            point.append(x[i])
            point.append(y[i])
            point_1.append(point)

        path_width, offset_width = self.Path_Info()
        path_width = path_width * 10
        # 扫描线间隔距离(车辆工作幅宽)
        # path_width = 4 * 10  # 全部数据扩大10倍,画图时在缩小即可,扫描线间隔是4(原因是程序中i不能产生浮点数)
        # 偏置距离(根据转弯来计算)
        d = int(path_width / 10)
        d_ = int(d * (offset_width + 1))
        point_ = []

        # 调用偏置程序 (import Polygon_offset as Pol)
        for x in range(0, d_, d):
            a = cal.Shrink(x, *point_1)
            point_.append(a)
        point_offset = point_[int((d_ / d) - 1)]

        # 多边形顶点数
        POINTNUM_1 = len(point_offset)
        point_1.append(point_1[0])
        P_x_ = []
        P_y_ = []
        for p in point_1:
            P_x_.append(p[0])
            P_y_.append(p[1])
        self.F.axes.plot(P_x_, P_y_)

        for i in range(1, int((d_ / d) - 1)):
            point_[i].append(point_[i][0])
            P_x_ = []
            P_y_ = []
            for p in point_[i]:
                P_x_.append(p[0])
                P_y_.append(p[1])
            self.F.axes.plot(P_x_, P_y_, color='red', linewidth=1)

        Polygon_1 = point_offset
        X = []
        Y = []
        for i in range(POINTNUM_1):
            x = (Polygon_1[i][0])
            y = (Polygon_1[i][1])
            X.append(x)
            Y.append(y)
        X.append(Polygon_1[0][0])
        Y.append(Polygon_1[0][1])
        algorithm.polyScan_Draw(self, point_1, point_offset, path_width)
        # 这一部分放在algorithm.py中,放这里会运行2次,加大计算量.
        # 结果展示内容
        # min_angle, min_distance = algorithm.polyScan(point_1, point_offset, path_width)
        # self.textBrowser.setText("最优角度: " + str(min_angle) + "\n最短距离: " + str(min_distance))
        self.F.axes.plot(X, Y, color='red', linewidth=1)
        self.F.axes.axis('equal')
        self.horizontalLayout.addWidget(self.F)