def main(): db = Database(gps=True, lidar=False, cam=False, imu=True) db.start() path = Path_Planning(0, db) Path.make_path() p = Path.path #db.path.generate_path = p c = Control(db=db) c.start() while True: if db.flag.system_stop: break else: try: time.sleep(0.1) pass except KeyboardInterrupt: #cv2.destroyAllWindows() print("Keyboard Interrupt detected!") db.flag.system_stop = True break c.join() db.join() return 0
import GstCV import cv2 import pyzbar.pyzbar as pyzbar # cv2.aruco joystick = Joystick() joystick.connect("/dev/input/js0") joystick.info() control = Control() control.setJoystick(joystick) control.robot.connect(IP, PORT) joystick.start() control.start() camera = GstCV.CVGstreamer(IP, 5000, 5001, 5005, toAVS=False, codec="JPEG") camera.start() #WIDTH, HEIGHT = 320, 240 WIDTH, HEIGHT = 640, 480 #Для автономных полей SENSIVITY = 80 # чувствительность автономки # Для наклонной #SENSIVITY = 75 INTENSIVITY = 110 # порог интенсивности r = int( WIDTH * 0.14 + 0), int(HEIGHT * 2 / 5 + 0), int(WIDTH * 4 / 6 + 0), int( HEIGHT * 10 / 10 +
type=int, action="store", nargs=2, help="dimensions of the output scenario (format: HOR VERT)", metavar="int", dest="dim") argParser.add_argument("--progress-msg", "-p", action="store_true", help="turn on progress messages", dest="prog_msg") argParser.add_argument("--img-msg", "-i", action="store_true", help="turn on image parsing error/information messages", dest="img_msg") argParser.add_argument("--no-crit-msg", "-c", action="store_true", help="turn off critical messages", dest="no_crit_msg") args = argParser.parse_args() try: Control.start(args) except KeyboardInterrupt: if (not args.no_crit_msg): print("Caught interrupt")
class Start(Thread): avoidThread = None detect = None def __init__(self, routePoints, sensorsAlgorithms={'Vision': [VisionDetectSVM]}, avoidClass=FixAvoid, comunication=AirSimCommunication, fusionAlgorithm=FusionData_Mean, configPath='config.yml', startPoint=None): Thread.__init__(self) self.start_point = startPoint self.status = 'start' # vehicleComunication = comunication.getVehicle() # Conectando ao simulador AirSim self.vehicleComunication = AirSimCommunication() self.control = Control(self.vehicleComunication, routePoints) self.unrealControl = UnrealCommunication() self.stop = False with open(configPath, 'r') as file_config: self.config = yaml.full_load(file_config) if avoidClass is not None: self.avoidThread = avoidClass(self, self.control) if sensorsAlgorithms is not None: self.detect = Detect(self, self.vehicleComunication, sensorsAlgorithms, self.avoidThread, fusionAlgorithm=fusionAlgorithm) #self.start() def start_run(self): # Start drone self.control.takeOff() # got to start point if self.start_point: print("Start point", self.start_point) self.vehicleComunication.moveToPoint(self.start_point[:3], self.start_point[3], True) # Start move path self.control.start() time.sleep(2) # Start thread detect if self.detect is not None: self.detect.start() def run(self): self.start_run() #Wating from time or collision max_time = time.time() + self.config['algorithm']['time_max'] while not self.stop: time.sleep(1) if time.time() >= max_time: print("Max time execution") break #Reset Plane self.end_run() def end_run(self): #stop detect self.detect.stop = True if self.detect is not None: #Wating detect self.detect.join() #stop control if self.control is not None: self.control.join() #Reset Plane self.unrealControl.reset_plane() self.vehicleComunication.client.reset() #Delete detect thread del self.detect def get_status(self): return self.status def set_status( self, status, ): print("Voo status:", status) self.status = status if status == 'collision': self.detect.stop = True self.stop = True
import os import logging import time from gui.MainFrame import MainFrame from Const import * from Control import Control from ConfigUtils import Config from Log import Log Config.load() # pyCurl does not like signal log = Log() try: import signal from signal import SIGPIPE, SIG_IGN signal.signal(signal.SIGPIPE, signal.SIG_IGN) except ImportError, e: log.debug("Main ImportError", e) print "Cannot handle signal..." app = wx.PySimpleApp() app.SetAssertMode(wx.PYAPP_ASSERT_DIALOG) control = Control() mainFrame = MainFrame(None, wx.ID_ANY, "Linux Rapidshare Grabber", (0, 0), (800, 600), control) control.setMainFrame(mainFrame) control.start() app.MainLoop()