示例#1
0
 def load(self, event, path):
     # 读取场景
     self.timeNow = 0
     self.timeNowStr.set("%.4f" % self.timeNow)
     if self.th and self.th.isAlive():
         stop_thread(self.th)
         self.th = None
     input_path = self.the_path.get()
     scene = BasicClasses.Scene()
     # print(input_path)
     try:
         f = open(input_path, "rb")
         f.close()
     except OSError:
         scene.load(path)
         self.default_scene = copy.deepcopy(scene)
         self.change_scene(scene)
         return
     scene.load(input_path)
     self.default_scene = copy.deepcopy(scene)
     self.change_scene(scene)
示例#2
0
def path_finder_test():
    BasicClasses.pf_test()
    scene = BasicClasses.Scene()
    BasicClasses.Scene.scale_factor = 60
    peds = []
    scene.peds = peds
    ped1 = BasicClasses.Circle(1.0, 3.0, 2.0, 0.0, 80, scene)
    ped1.radius = 0.25
    peds.append(ped1)

    scene.boxes = []
    scene.boxes.append(BasicClasses.Box(0.0, 4.0, 5.0, 5.0))
    scene.boxes.append(BasicClasses.Box(0.0, 0.0, 5.0, 1.0))
    scene.boxes.append(BasicClasses.Box(5.0, 3.5, 6.0, 5.0))
    scene.boxes.append(BasicClasses.Box(5.0, 0.0, 6.0, 1.5))
    scene.boxes.append(BasicClasses.Box(3.0, 2.0, 4.0, 3.0)) # 障碍物

    scene.dests = []
    scene.dests.append(BasicClasses.Box(8.0, 0.0, 9.0, 1.0))
    scene.border = BasicClasses.Vector2D(10.0, 6.0)
    SFM.QuickPathFinder.path_finder_init(scene)
    g_gui = SfmGui(scene, 10000)
示例#3
0
import time
import threading
import copy
import ctypes
import inspect

import tkinter

from SFM import BasicClasses

MAX_X = 500
MAX_Y = 500
MAX_COLOR = 50
CANVAS_BG = "white"
default_path = "D://save.p"
TIME_STEP = BasicClasses.get_time_step()


def _async_raise(tid, exctype):
    """raises the exception, performs cleanup if needed"""
    tid = ctypes.c_long(tid)
    if not inspect.isclass(exctype):
        exctype = type(exctype)
    res = ctypes.pythonapi.PyThreadState_SetAsyncExc(tid,
                                                     ctypes.py_object(exctype))
    if res == 0:
        raise ValueError("invalid thread id")
    elif res != 1:
        # """if it returns a number greater than one, you're in trouble,
        # and you should call it again with exc=NULL to revert the effect"""
        ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, None)
示例#4
0
#!/usr/bin/env python
# coding=utf-8

from GuiModel.Gui import SfmGui
from SFM import BasicClasses
import SFM.PathFinder

if __name__ == '__main__':
    '''
    boxes: 障碍物和墙们,Box类型的列表
    dests: 目标位置们,Box类型的列表,可以包含在boxes中
    peds: 行人们,Circle类型,可以是一个列表
    '''
    BasicClasses.pf_test()
    scene = BasicClasses.Scene()
    BasicClasses.Scene.scale_factor = 60
    peds = []
    scene.peds = peds
    ped1 = BasicClasses.Circle(1.0, 3.0, 2.0, 0.0, 80, scene)
    ped1.radius = 0.25
    peds.append(ped1)

    scene.boxes = []
    scene.boxes.append(BasicClasses.Box(0.0, 4.0, 5.0, 5.0))
    scene.boxes.append(BasicClasses.Box(0.0, 0.0, 5.0, 1.0))
    scene.boxes.append(BasicClasses.Box(5.0, 3.5, 6.0, 5.0))
    scene.boxes.append(BasicClasses.Box(5.0, 0.0, 6.0, 1.5))
    scene.boxes.append(BasicClasses.Box(3.0, 2.0, 4.0, 3.0))  # 障碍物

    scene.dests = []
    scene.dests.append(BasicClasses.Box(8.0, 0.0, 9.0, 1.0))