def __init__(self):
     self.processor = Process()
     self.control = Control()
     self.width = 800   
     self.height = 600
     self.fps = 1000 / 60
     self.UI_handler = []
Exemple #2
0
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
    def __init__(self, handle):
        activity.Activity.__init__(self, handle)

        if self._NEW_TOOLBAR_SUPPORT:  #toolbar nuevo
            #self.toolbar_box = sugar.graphics.toolbarbox.ToolbarBox()
            self.toolbar_box = sugar.activity.widgets.ActivityToolbar(self)
            self.toolbar_box.keep.hide()

            #stop_button = sugar.activity.widgets.StopButton(self)
            #stop_button.props.accelerator = '<Ctrl><Shift>Q'
            #self.toolbar_box.toolbar.insert(stop_button, -1)
            #stop_button.show()

            self.set_toolbar_box(self.toolbar_box)
            self.toolbar_box.show()

        else:  #old toolbar
            toolbox = activity.ActivityToolbox(self)

            activity_toolbar = toolbox.get_activity_toolbar()
            activity_toolbar.share.props.visible = False  #Todavia no hay share
            activity_toolbar.show()

            self.set_toolbox(toolbox)
            toolbox.show()

        self.activity = Control()

        self.set_canvas(self.activity.todo)
        self.nomArch = ""

        self.connect('key_press_event', self.activity.onKeyPress)
Exemple #4
0
    def __init__( self, app, options=None, parent=None):
        QtCore.QObject.__init__(self, parent)
        self.app = app

        if os.name == 'posix':
            self.label_font_size = 18
        else:
            self.label_font_size = 12
        
        # #################
        # INITIATE
        self.control = Control(self, self.debug)

        # #################
        # LAYOUTS
        self.init_layout()

        self.setGeometry(self.offset_left, self.offset_top, self.width, self.height)
        self.setSizePolicy(QtWidgets.QSizePolicy.Maximum, QtWidgets.QSizePolicy.Maximum)
        self.setMinimumSize(self.width, self.height)
        self.setWindowTitle(self.control.name)

        # for thread in self.control.threads:
        #     print thread

        # #################
        self.control.start_capture()
Exemple #5
0
 def testInputs_nominal(self):
     """Tests creation of Control instance with valid inputs"""
     s = random.uniform(5, 10)
     w = random.uniform(-math.pi / 4, math.pi / 4)
     c = Control(s, w)
     self.assertEqual(c.s, s)
     self.assertEqual(c.omega, w)
Exemple #6
0
    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)
Exemple #7
0
def up():
    control = Control()
    try:
        steps = int(request.args['steps'])
    except:
        steps = 1
    control.up(steps)
    return "Beam me up Scotty!"
Exemple #8
0
 def __init__(self, media):
     self.titlefont = pygame.font.SysFont('inkfree', 80)
     self.title = self.titlefont.render("Ranking", True, (255, 255, 255))
     self.comment = pygame.font.SysFont('inkfree', 40)
     self.control = Control()
     self.media = media
     self.ranking = []
     self.write_point = 0
Exemple #9
0
def down():
    control = Control()
    try:
        steps = int(request.args['steps'])
    except:
        steps = 1
    control.down(steps)
    return "PUT THAT COOKIE DOWN! NOW!"
Exemple #10
0
    def __init__(self, handle):
        activity.Activity.__init__(self, handle)

        self.build_toolbar()
        self.activity = Control()

        self.set_canvas(self.activity.todo)
        self.nomArch =""
        
        self.connect('key_press_event', self.activity.onKeyPress)
 def __init__(self, media):
     self.titlefont = pygame.font.SysFont('inkfree', 80)
     self.title = self.titlefont.render("Setting", True, (255, 255, 255))
     self.comment = pygame.font.SysFont('inkfree', 40)
     self.choose = [1, 0]  # 現在の選択されている位置
     self.control = Control()
     self.media = media
     self.menu_str = [["SIZE", " SMALL", " NORMAL", " BIG", ""],
                      ["STARS", " FEW", " NORMAL", " MANY", "EXIT"],
                      ["SPEED", " SLOW", " NORMAL", " FAST", ""]]
Exemple #12
0
    def createControlSequence(self):
        """Based on the simulation constraints, builds a control dictionary with instances of the Control class to
        drive the Groundvehicle at time intervals determined within this method."""
        # Set predetermined vehicle dynamics constraints
        max_turn_rate = math.pi/4
        max_speed = 10
        min_speed = 5

        # Determine turn radius for vehicle at max turn rate and minimum speed
        small_circumference = min_speed * 2 * math.pi / max_turn_rate  # C = s * t = s * 2pi / omega
        small_radius = small_circumference / (2 * math.pi)
        # Determine turn time for an N-sided polygon
        turn_angle = 2*math.pi / self.n
        turn_time = turn_angle / max_turn_rate

        # Determine drive time for straight segments of an N-sided polygon
        # Use the law of cosines to determine chord length, c^2 = a^2 + b^2 - 2ab*cosC
        big_chord = math.sqrt(2 * (self.circle_radius ** 2) * (1 - math.cos(turn_angle)))
        # Determine straight segment length, to keep motion within inscribing circle, making it necessary to
        # consider linear displacement during turns (use one full turn since there is a half turn at each end)
        linear_displacement_turn = small_radius * math.sin(turn_angle/2.0)
        straight_segment_length = big_chord - linear_displacement_turn*2
        straight_segment_time = straight_segment_length / max_speed

        # Get starting positions for ground vehicle for a polygon inscribed by a circle centered at (50, 50)
        self.start_x = 50 - (straight_segment_length / 2.0)
        self.start_y = 50 - (self.circle_radius * math.cos((turn_angle)/2.0)) - (small_radius * (1 - math.cos(turn_angle / 2.0)))

        # Create control dictionary, alternating linear and curved segments spaced by previously determined time intervals
        time = 0
        while True:
            # Add a straight line segment control (linear motion at max speed)
            self.control_dictionary[round(time,2)] = Control(max_speed, 0)
            time += straight_segment_time
            # Add a turn segment control (max turn rate at slowest speed)
            self.control_dictionary[round(time,2)] = Control(min_speed, max_turn_rate)
            time += turn_time
            # Finish if controls for entire simulation have been set, otherwise loop
            if time >= self.time_limit:
                self.ControlsSet = True
                break
Exemple #13
0
 def __init__(self, media):
     self.titlefont = pygame.font.SysFont('inkfree', 80)
     self.title = self.titlefont.render("Catch a star game!", True,
                                        (255, 255, 255))
     self.comment = pygame.font.SysFont('inkfree', 40)
     self.title_menu = [
         self.comment.render(st, True, (255, 255, 255))
         for st in ["PLAY", "SETTING", "RANKING", "BYE"]
     ]
     self.choose = 0  # 現在の選択されている位置
     self.control = Control()
     self.media = media
    def __init__(self, id, largo, alto, ancho, robot):
        if id < 1 or id > 255:
            raise ValueError("El id debe estar entre 1-255.")
        if largo < 1 or largo > 200 or alto < 1 or alto > 200 or ancho < 1 or ancho > 200:
            raise ValueError("Las dimensiones deben tener un valor comprendido entre 1 y 200mm")

        self.id = id
        self.largo = largo
        self.alto = alto
        self.ancho = ancho
        self.robot = robot
        self.control = Control(self)
Exemple #15
0
    def __init__(self, **kwargs):
        super(loop_Control, self).__init__(**kwargs)

        ### Activate encoders
        self.loop_encoder = loop_Encoder(fps=6000,
                                         display_rt=0,
                                         resolution=2048)
        self.loop_encoder.start_loop()

        ### Link Controller with encoders
        self.controller = Control(
            encoder_left=self.loop_encoder.encoder_left,
            encoder_right=self.loop_encoder.encoder_right)
Exemple #16
0
 def __init__(self,
              initialPC=Bus(64),
              IMem=Memory(True),
              DMem=Memory(False)):
     self.ALU = ALU()
     self.IMem = IMem
     self.DMem = DMem
     self.signExtender = SignExtender()
     self.regFile = RegisterFile()
     self.Control = Control()
     self.nextPCLogic = NextPCLogic()
     self.PC = initialPC
     self.aluZero = 0
def test_toml_loading():
    control = Control.Control()
    control.loadFile()
    configs = control.getConfigs()
    assert configs[0].symbol == "DEBUG"
    assert configs[0].description == "My Config"
    assert configs[0].detail == "my first config"
    assert configs[0].enable == True

    assert configs[1].symbol == "DEBUG2"
    assert configs[1].description == "My Config2"
    assert configs[1].detail == "my second config"
    assert configs[1].enable == False
Exemple #18
0
    def __init__(self, path):
        self.cuteloading = None
        self.asynckey = None
        try:
            self.key = Key()
            self.asynckey = threading.Thread(target=self.key.storechar,
                                             args=(),
                                             daemon=False)
            self.asynckey.start()
            self.time = time.time()

            width, height = shutil.get_terminal_size((80, 20))
            Display.setdisplay(width - 1, height)
            self.skipupdate = False
            self.restart = False

            sys.stdout.write(Display.screen(True))
            sys.stdout.flush()
            self.cuteloading = threading.Thread(target=Display.startloading,
                                                args=(width, ),
                                                daemon=False)
            self.cuteloading.start()

            self.path = path
            self.now = datetime.datetime.now()
            self.control = Control(self)

            self.filedisplay = Display(Display.width, Display.height - 1, 0, 0,
                                       False, False)
            self.infodisplay = Display(Display.width, Display.height, 0, 0,
                                       True, True)
            self.cmddisplay = Display(Display.width, Display.height, 0, 0,
                                      False, True)
            self.currentdisplay = self.filedisplay
            self.currentfile = self.filedisplay
            self.loadfile()

            Display.stoploading(self.cuteloading)
            self.update()

            self.key.settrackkeys(True)
            self.loop()

        finally:
            Display.stoploading(self.cuteloading)
            Key.close()
            self.asynckey.join()
            if not self.restart:
                sys.stdout.write(Display.screen(False))
                sys.stdout.flush()
    def __init__(self):
        QMainWindow.__init__(self)
        self.control = Control()

        self.setMinimumSize(QSize(500, 240))
        self.setWindowTitle('Markov\'s Algorithm')

        self.b = QPlainTextEdit(self)
        self.b.move(10, 10)
        self.b.resize(400, 200)

        button = QPushButton('Enter', self)
        button.clicked.connect(self.enterPressed)
        button.resize(50, 32)
        button.move(420, 180)
Exemple #20
0
def main(auto):
    os.environ['SDL_VIDEO_WINDOW_POS'] = "%d,%d" % (500, 30)
    walls, trophies, car = Map1
    lidar = LiDAR()
    control = Control()
    database = Database(lidar, control, car)
    brain = Brain(database) # Get LiDAR data, Set Control data
    game = Game(walls, trophies, car, database) # Get Control data Set LiDAR data
    if auto:
        brain_thread = threading.Thread(target=brain.run,)
        brain_thread.start()
    game.run(auto=auto)
    pygame.quit()

    return 0
Exemple #21
0
 def testControlVehicle_Valid(self):
     """Tests ControlVehicle method functionality with valid Control parameters"""
     pose = [
         random.uniform(0, 100),
         random.uniform(0, 100),
         random.uniform(-math.pi, math.pi)
     ]
     s = random.uniform(5, 10)
     w = random.uniform(-math.pi / 4, math.pi / 4)
     g = GroundVehicle(pose, s, w)
     new_s = random.uniform(5, 10)
     new_omega = random.uniform(-math.pi / 4, -math.pi / 4)
     c = Control(new_s, new_omega)
     g.controlVehicle(c)
     self.assertEqual(g.s, new_s)
     self.assertEqual(g.getVelocity()[2], new_omega)
Exemple #22
0
    def __init__(self, parent=None, flags=0):
        super(TaskEditor, self).__init__(parent=None)
        self.setWindowTitle(u"BLOB Data Extract Tool")
        self.setWindowIcon(QtGui.QIcon('./blobdata_pump.ico'))
        self.globalLayout = QtGui.QGridLayout()
        self.setLayout(self.globalLayout)
        self.setMinimumSize(500, 700)
        self.globalLayout.setVerticalSpacing(4)
        self.globalLayout.setHorizontalSpacing(4)		
        self.globalLayout.setAlignment(Qt.Qt.AlignTop | Qt.Qt.AlignLeft)
        self.setWindowFlags(Qt.Qt.WindowStaysOnTopHint)

        self.dbConnStatus = False
        self.chooseColumnStatus = False
        self.control = Control()
        self.initUI()
Exemple #23
0
 def start_button_clicked(self):
     if self.dim is not None:
         if self.t is not None and self.t.isAlive():
             self.center_label.config(text="Process already started")
             return
         time = str(self.time_entry.get().strip())
         if not time:
             self.center_label.config(
                 text="Invalid duration:\nPlease enter number of\nseconds")
         else:
             self.control = Control(self.dim[0], self.dim[1], self.dim[2],
                                    self.dim[3])
             self.control.time = int(time)
             self.t = Thread(target=self.control.start_main)
             self.t.start()
             self.center_label.config(text="Starting in 3 Seconds")
     else:
         self.center_label.config(text="No Target")
Exemple #24
0
def main(auto):
    os.environ['SDL_VIDEO_WINDOW_POS'] = "%d,%d" % (500, 30)
    _ = (Map1, Map2, Map3)
    walls, trophies, parkings, crosswalks, traffic_signs, schoolzone, car = Map3
    lidar = LiDAR()
    control = Control()
    database = Database(lidar, control, car)
    # Get LiDAR data, Set Control data
    brain = Brain(database)
    # Get Control data Set LiDAR data
    game = Game(walls, trophies, parkings, crosswalks, traffic_signs,
                schoolzone, car, database)
    if auto:
        brain_thread = threading.Thread(target=brain.run, )
        brain_thread.start()
    game.run(auto=auto)
    pygame.quit()

    return 0
Exemple #25
0
 def __init__(self, media):
     self.start_time = time.time()
     self.star_list = []  # 降ってくる星用のリスト
     self.get_star = 0  # 取得した星の数
     self.titlefont = pygame.font.SysFont('inkfree', 80)
     self.comment = pygame.font.SysFont('inkfree', 40)
     self.title = self.titlefont.render("Play", True, (255, 255, 255))
     self.result = self.titlefont.render("Result", True, (255, 255, 255))
     self.control = Control()
     self.media = media
     self.ranking = Ranking(media)
     self.read_ranking = False  # ランキングを読み込んだかどうか
     self.write_point = False  # ランキングに書き込めるかどうか
     self.eng_chara = [[
         'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
         ' '
     ],
                       [
                           'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w',
                           'x', 'y', 'z', 'Back'
                       ]]
     self.choose = [0, 0]
     self.your_name = ''
Exemple #26
0
def main():
    individuals = 3
    survivors = 3
    img_size = 28
    num_layers = 3
    batch_size = 256
    num_classes = 10
    num_epoch = 7
    max_number_filter_change = 4
    max_size_filter_change = 1
    max_number_filter = 9
    max_filter_size = 2
    #(self, num_layers, maxFilterChange, maxSizeChange, maxFilterNumber, maxFilterSize, img_size)
    control = Control(num_layers, max_number_filter_change,
                      max_size_filter_change, max_number_filter,
                      max_filter_size, img_size)
    #(self, num_conv_layers, data_train_path, data_test_path, img_rows, img_cols, epoch_number, batch_size, num_classes)
    cnn = CNN(num_layers, 'data/fashionmnist/fashion-mnist_train.csv',
              'data/fashionmnist/fashion-mnist_test.csv', img_size, img_size,
              num_epoch, batch_size, num_classes)
    cnn.configure_data()
    #(self, initialPoblation, control, num_survivors, condition_precision, condition_generations, cnn, sim_per_config)
    simulator = Simulator(individuals, control, survivors, 0.88, None, cnn, 3)
    simulator.simulate()
Exemple #27
0
import sys, time, signal, numpy, json
from AudioCapture import AudioCapture
from Control import Control
from Tkinter import *
import pyqtgraph as pg

signal.signal(signal.SIGINT, signal.SIG_DFL)
c = Control()

low_b1 = 750.0
low_b2 = 1000.0

mid_b1 = 95.0
mid_b2 = 120.0

update_threshold = 1
update_counter = 1

def toggle_slow_mode():
    global update_threshold
    if slow_mode_var.get():
        update_threshold = 5
    else:
        update_threshold = 1

def low_slider1_func(val):
    global low_b1
    low_b1 = int(val)

def low_slider2_func(val):
    global low_b2
Exemple #28
0
 def testGetSpeed(self):
     """Tests nominal functioning of getSpeed() method"""
     s = random.uniform(5, 10)
     w = random.uniform(-math.pi / 4, math.pi / 4)
     c = Control(s, w)
     self.assertEqual(c.getSpeed(), s)
Exemple #29
0
 def testInputOmega_wrongtype(self):
     """Tests creation of Control instance with invalid omega parameter"""
     s = random.uniform(5, 10)
     w = 'test input'
     with self.assertRaises(TypeError):
         c = Control(s, w)
Exemple #30
0
 def testInputOmega_edgehigh(self):
     """Tests creation of Control instance with edge case omega parameter"""
     s = random.uniform(5, 10)
     w = math.pi / 4
     c = Control(s, w)
     self.assertEqual(c.s, s)