def __init__(self, plugin, config = None): """Constructor.""" self._config = config Localization.setup() gtk.Dialog.__init__(self, _("Settings"), None, gtk.DIALOG_DESTROY_WITH_PARENT) self.set_resizable(False) close_button = self.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE) close_button.grab_default() close_button.connect_object("clicked", gtk.Widget.destroy, self) main_box = gtk.VBox(False, 0) main_box.set_border_width(12) title_label = gtk.Label() title_label.set_markup( '<b>' + _("Actions to perform upon saving:") + '</b>') title_label.set_alignment(0, 0) config_box = gtk.VBox(False, 6) config_box.set_border_width(6) checkbox_label = _("_Strip trailing whitespace on every line") whitespace_checkbox = gtk.CheckButton(checkbox_label) whitespace_checkbox.connect('clicked', self.update_setting, 'remove_whitespace') whitespace_checkbox.set_active( self._config.get_bool('remove_whitespace')) checkbox_label = _("_Remove newlines at the end of document") newlines_checkbox = gtk.CheckButton(checkbox_label) newlines_checkbox.connect('clicked', self.update_setting, 'remove_newlines') newlines_checkbox.set_active(self._config.get_bool('remove_newlines')) config_box.pack_start(whitespace_checkbox, True, True, 0) config_box.pack_start(newlines_checkbox, True, True, 0) main_box.pack_start(title_label, True, True, 0) main_box.pack_start(config_box, True, True, 0) self.vbox.pack_start(main_box, True, True, 0) self.show_all()
def __init__(self, window): """Constructor.""" self._window = window self._views = {} self._action_group = None self._ui_id = None self._accel_group = None Localization.setup() self._insert_menu() self._setup_supplementary_accelerators() for view in self._window.get_views(): self._initialize_viewhelper(view) self._tab_add_handler = self._window.connect('tab-added', self._on_tab_added) self._tab_remove_handler = self._window.connect('tab-removed', self._on_tab_removed)
def test_not_dying_when_calling(self): try: Localization.setup() except: self.fail("Localization.setup did raise an error")
def evaluate_lenet5(learning_rate=0.1, n_epochs=100, dataset='paws.json', nkerns=[20, 50], batch_size=10): """ Demonstrates lenet on MNIST dataset :type learning_rate: float :param learning_rate: learning rate used (factor for the stochastic gradient) :type n_epochs: int :param n_epochs: maximal number of epochs to run the optimizer :type dataset: string :param dataset: path to the dataset used for training /testing (MNIST here) :type nkerns: list of ints :param nkerns: number of kernels on each layer """ rng = numpy.random.RandomState(23455) datasets = load_dataset(dataset) train_set_x, train_set_y = datasets[0] valid_set_x, valid_set_y = datasets[1] test_set_x, test_set_y = datasets[2] # compute number of minibatches for training, validation and testing n_train_batches = train_set_x.get_value(borrow=True).shape[0] n_valid_batches = valid_set_x.get_value(borrow=True).shape[0] n_test_batches = test_set_x.get_value(borrow=True).shape[0] n_train_batches //= batch_size n_valid_batches //= batch_size n_test_batches //= batch_size # allocate symbolic variables for the data index = T.lscalar() # index to a [mini]batch x = T.matrix('x') print('... building the model') image_size = numpy.array([400,240]) filter_size = numpy.array([20,20]) pool_size = numpy.array([4,4]) layer0_input = x.reshape((batch_size, 1, image_size[0], image_size[1])) layer0 = LeNetConvPoolLayer( rng, input=layer0_input, image_shape=(batch_size, 1, image_size[0], image_size[1]), filter_shape=(nkerns[0], 1, filter_size[0], filter_size[1]), poolsize=pool_size ) image_size = (image_size - filter_size + 1)/pool_size layer1 = LeNetConvPoolLayer( rng, input=layer0.output, image_shape=(batch_size, nkerns[0], image_size[0], image_size[1]), filter_shape=(nkerns[1], nkerns[0], filter_size[0], filter_size[1]), poolsize=pool_size ) image_size = (image_size - filter_size + 1)/pool_size layer2_input = layer1.output.flatten(2) # construct a fully-connected sigmoidal layer layer2 = HiddenLayer( rng, input=layer2_input, n_in=nkerns[1] * image_size[0] * image_size[1], n_out=500, activation=T.tanh ) # classify the values of the fully-connected sigmoidal layer layer3 = Localization(input=layer2.output, n_in=500, n_out=2) # the cost we minimize during training is the NLL of the model cost = layer3.L2_error(y) # create a function to compute the mistakes that are made by the model test_model = theano.function( [index], layer3.mean_errors(y), givens={ x: test_set_x[index * batch_size: (index + 1) * batch_size], y: test_set_y[index * batch_size: (index + 1) * batch_size] } ) validate_model = theano.function( [index], layer3.mean_errors(y), givens={ x: valid_set_x[index * batch_size: (index + 1) * batch_size], y: valid_set_y[index * batch_size: (index + 1) * batch_size] } ) # create a list of all model parameters to be fit by gradient descent params = layer3.params + layer2.params + layer1.params + layer0.params # create a list of gradients for all model parameters grads = T.grad(cost, params) # train_model is a function that updates the model parameters by # SGD Since this model has many parameters, it would be tedious to # manually create an update rule for each model parameter. We thus # create the updates list by automatically looping over all # (params[i], grads[i]) pairs. updates = [ (param_i, param_i - learning_rate * grad_i) for param_i, grad_i in zip(params, grads) ] train_model = theano.function( [index], cost, updates=updates, givens={ x: train_set_x[index * batch_size: (index + 1) * batch_size], y: train_set_y[index * batch_size: (index + 1) * batch_size] } ) print('... training') # early-stopping parameters patience = 200 # look as this many examples regardless patience_increase = 2 # wait this much longer when a new best is # found improvement_threshold = 0.995 # a relative improvement of this much is # considered significant validation_frequency = min(n_train_batches, patience // 2) # go through this many # minibatche before checking the network # on the validation set; in this case we # check every epoch best_validation_loss = numpy.inf best_iter = 0 test_score = 0. start_time = timeit.default_timer() epoch = 0 done_looping = False while (epoch < n_epochs) and (not done_looping): epoch = epoch + 1 for minibatch_index in range(n_train_batches): iter = (epoch - 1) * n_train_batches + minibatch_index if iter % 1 == 0: print('training @ iter = ', iter) cost_ij = train_model(minibatch_index) print(cost_ij/batch_size, minibatch_index) if (iter + 1) % validation_frequency == 0: # compute zero-one loss on validation set validation_losses = [validate_model(i) for i in range(n_valid_batches)] this_validation_loss = numpy.mean(validation_losses) print('epoch %i, minibatch %i/%i, validation error %f' % (epoch, minibatch_index + 1, n_train_batches, this_validation_loss)) # if we got the best validation score until now if this_validation_loss < best_validation_loss: #improve patience if loss improvement is good enough if this_validation_loss < best_validation_loss * \ improvement_threshold: patience = max(patience, iter * patience_increase) # save best validation score and iteration number best_validation_loss = this_validation_loss best_iter = iter # test it on the test set test_losses = [ test_model(i) for i in range(n_test_batches) ] test_score = numpy.mean(test_losses) print((' epoch %i, minibatch %i/%i, test error of ' 'best model %f') % (epoch, minibatch_index + 1, n_train_batches, test_score)) if patience <= iter: done_looping = True break end_time = timeit.default_timer() print('Optimization complete.') print('Best validation score of %f %% obtained at iteration %i, ' 'with test performance %f %%' % (best_validation_loss * 100., best_iter + 1, test_score * 100.)) print(('The code for file ' + os.path.split(__file__)[1] + ' ran for %.2fm' % ((end_time - start_time) / 60.)), file=sys.stderr)
def on_pubmsg(self, connection, event): source = event.source() nick = source.split('!')[0] args = event.arguments() message = args[0].split(' ') if message[0] == '!!' and len(message) > 1: try: if self.admins[event.source()] == 'admin': command = "say \"^8(^1IRC:^5@^2" + nick + "^8)^7 " + ' '.join(message[1:]) + "\"" elif self.admins[event.source()] == 'mod': command = "say \"^8(^1IRC:^5+^2" + nick + "^8)^7 " + ' '.join(message[1:]) + "\"" self.rcon.send(command) except: #command = "say \"^8(^1IRC:^2" + nick + "^8)^7 " + ' '.join(message[1:]) + "\"" self.connection.privmsg(self.target, self.m.MSG_ERR_ADMIN_PRIV) elif message[0][0] == '@' and len(message[0]) > 1 and len(message) > 1: if message[0][1:].isdigit(): cid = message[0].split("@")[1] output = "tell " + cid + " \"^8(^1IRC:^2" + nick + "^8)^7 " + ' '.join(message[1:]) + "\"" self.rcon.send(output) elif message[0] == '!bigtext' and len(message) > 1: command = "bigtext \"" + ' '.join(message[1:]) + "\"" self.rcon.send(command) elif message[0] == '!kick' and len(message) > 1: try: if self.admins[event.source()] == 'admin': try: c = self.getClientObject(message[1]) self.rcon.send("kick " + message[1]) self.connection.privmsg(self.target, self.m.MSG_RCON_KICK % (nick, c.coloredIrcNickname())) except: self.connection.privmsg(self.target, self.m.MSG_ERR_CID) except KeyError: self.connection.privmsg(self.target, self.m.MSG_ERR_ADMIN) elif message[0] == '!slap' and len(message) > 1: try: if self.admins[event.source()] == 'admin': try: c = self.getClientObject(message[1]) self.rcon.send("slap " + message[1]) self.connection.privmsg(self.target, self.m.MSG_RCON_SLAP % (nick, c.coloredIrcNickname())) except: self.connection.privmsg(self.target, self.m.MSG_ERR_CID) except KeyError: self.connection.privmsg(self.target, self.m.MSG_ERR_ADMIN) elif message[0] == '!nuke' and len(message) > 1: try: if self.admins[event.source()] == 'admin': try: c = self.getClientObject(message[1]) self.rcon.send("nuke " + message[1]) self.connection.privmsg(self.target, self.m.MSG_RCON_NUKE % (nick, c.coloredIrcNickname())) except: self.connection.privmsg(self.target, self.m.MSG_ERR_CID) except KeyError: self.connection.privmsg(self.target, self.m.MSG_ERR_ADMIN) elif message[0] == '!mute' and len(message) > 1: try: if self.admins[event.source()] == 'admin': try: c = self.getClientObject(message[1]) self.rcon.send("mute " + message[1]) self.connection.privmsg(self.target, self.m.MSG_RCON_MUTE % (nick, c.coloredIrcNickname())) except: self.connection.privmsg(self.target, self.m.MSG_ERR_CID) except KeyError: self.connection.privmsg(self.target, self.m.MSG_ERR_ADMIN) elif message[0] == '!nextmap' and len(message) > 1: try: if self.admins[event.source()] == 'admin': self.rcon.send("g_nextmap " + message[1]) self.connection.privmsg(self.target, self.m.MSG_RCON_NEXTMAP % (message[1])) except KeyError: self.connection.privmsg(self.target, self.m.MSG_ERR_ADMIN) elif message[0] == '!map': if len(message) > 1: try: if self.admins[event.source()] == 'admin': self.rcon.send("map " + message[1]) self.connection.privmsg(self.target, self.m.MSG_RCON_MAP %(nick, message[1])) except KeyError: self.connection.privmsg(self.target, self.m.MSG_ERR_ADMIN) else: self.connection.privmsg(self.target, self.m.MSG_CURR_MAP %(self.currentMap)) elif message[0] == "!shuffle": try: if self.admins[event.source()] == 'admin': self.rcon.send("shuffleteams") self.connection.privmsg(self.target, self.m.MSG_RCON_SHUFFLE % (nick)) except KeyError: self.connection.privmsg(self.target, self.m.MSG_ERR_ADMIN) elif message[0] == '!force' and len(message) > 3: try: if self.admins[event.source()] == 'admin': try: c = self.getClientObject(message[1]) self.rcon.send("forcecvar " + message[1] + " " + message[2] + " " + ''.join(message[3:])) self.connection.privmsg(self.target, self.m.MSG_RCON_FORCECVAR % (nick, message[2], ''.join(message[3:]), c.coloredIrcNickname())) except: self.connection.privmsg(self.target, self.m.MSG_ERR_CID) except KeyError: self.connection.privmsg(self.target, self.m.MSG_ERR_ADMIN) elif message[0] == '!list': if self.reader != None: output = (self.m.MSG_LIST % (len(self.reader.clients), self.currentMap)) + " " for key, c in self.reader.clients.iteritems(): output = output + "(" + str(key) + ")" + c.coloredIrcNickname() + " " self.connection.privmsg(self.target, output) else: self.connection.privmsg(self.target, self.m.MSG_ERR_OBJECT) elif message[0] == '!ts3' and self.cfg.ts3enabled: try: ts3client = TS3(self.cfg.ts3host, self.cfg.ts3port, self.cfg.ts3user, self.cfg.ts3pass, self, self.target, "list", "") ts3client.start() except: self.connection.privmsg(self.target, self.m.MSG_ERR_GENERAL) elif message[0] == '!ts3info' and len(message) > 1 and self.cfg.ts3enabled: try: ts3client = TS3(self.cfg.ts3host, self.cfg.ts3port, self.cfg.ts3user, self.cfg.ts3pass, self, self.target, "info", message[1]) ts3client.start() except: self.connection.privmsg(self.target, self.m.MSG_ERR_GENERAL) elif message[0] == '!ban' and len(message) > 1: if self.reader != None: try: if self.admins[event.source()] == 'admin': try: c = self.getClientObject(message[1]) self.rcon.send("addIP " + c.ip) self.rcon.send("kick " + message[1]) self.connection.privmsg(self.target, self.m.MSG_RCON_BAN % (nick, c.coloredIrcNickname(), c.ip)) except: self.connection.privmsg(self.target, self.m.MSG_ERR_CID) except KeyError: self.connection.privmsg(self.target, self.m.MSG_ERR_ADMIN) elif (message[0] == '!banguid' or message[0] == '!permban') and len(message) > 2: if self.reader != None: try: if self.admins[event.source()] == 'admin': try: c = client.Client(-1) if message[1][0] == "#": ext_id = message[1].split("#")[1] ret = self.db.extInfo(int(ext_id)) c.guid = ret[2] c.name = ret[3] c.ip = ret[0] else: c = self.getClientObject(message[1]) guid = c.guid reason = ' '.join(message[2:]) id = self.db.getId(c.guid) try: self.db.permBan(id, reason, nick) except: self.connection.privmsg(self.target, self.m.MSG_ERR_DB) self.rcon.send("addIP " + c.ip) self.rcon.send("kick " + message[1]) self.connection.privmsg(self.target, self.m.MSG_RCON_BANGUID % (nick, c.coloredIrcNickname(), c.guid, c.ip, reason)) except: self.connection.privmsg(self.target, self.m.MSG_ERR_CID) except: self.connection.privmsg(self.target, self.m.MSG_ERR_ADMIN) elif message[0] == '!search' and len(message) > 1: try: if self.admins[event.source()] == 'admin': try: if len(message[1]) >= 3 and message[1].isalnum(): results = self.db.search(message[1]) output = self.m.MSG_SEARCH % (message[1]) + " " if len(results) > 40: output = output + self.m.MSG_ERR_SEARCH_RES else: for result in results: output = output + "(\x02#" + str(result[1]) + "\x02)" + result[0] + " " else: output = self.m.MSG_ERR_SEARCH self.connection.privmsg(self.target, output) except: print sys.exc_info() self.connection.privmsg(self.target, self.m.MSG_ERR_DB) except: self.connection.privmsg(self.target, self.m.MSG_ERR_ADMIN) elif message[0] == '!tempban' and len(message) > 2: try: if self.admins[event.source()] == 'admin': try: c = client.Client(-1) c = self.getClientObject(message[1]) id = self.db.getId(c.guid) duration = float(message[2]) if duration > 0.0: self.db.tempBan(id, duration, nick) self.rcon.send("kick " + message[1]) self.connection.privmsg(self.target, self.m.MSG_RCON_TEMPBAN % (nick, c.coloredIrcNickname(), str(duration))) except: self.connection.privmsg(self.target, self.m.MSG_ERR_DB) except: self.connection.privmsg(self.target, self.m.MSG_ERR_ADMIN) elif message[0] == '!extinfo' and len(message) > 1: try: if self.admins[event.source()] == 'admin': try: ret = self.db.extInfo(int(message[1])) try: (ip_ptr, alias, addr) = socket.gethostbyaddr(ret[0]) added = " [" + ip_ptr + "]" except: added = "" output = self.m.MSG_EXTINFO % (message[1], ret[3], ret[0], added, ret[2], str(ret[1])) self.connection.privmsg(self.target, output) except: print sys.exc_info() self.connection.privmsg(self.target, self.m.MSG_ERR_DB) except: self.connection.privmsg(self.target, self.m.MSG_ERR_ADMIN) elif message[0] == '!aliases' or message[0] == '!alias' and len(message) > 1: if self.reader != None: try: if self.admins[event.source()] == 'mod' or self.admins[event.source()] == 'admin': try: c = client.Client(-1) if message[1][0] == "#": ext_id = message[1].split("#")[1] ret = self.db.extInfo(int(ext_id)) c.guid = ret[2] c.name = ret[3] c.ip = ret[0] else: c = self.reader.clients[int(message[1])] guid = c.guid try: aliases = self.db.getAliases(guid) output = self.m.MSG_ALIASES % (c.coloredIrcNickname()) + " " if len(aliases) == 0: output = output + "None" self.connection.privmsg(self.target, output) else: i = 0 for alias in aliases: output = output + alias[0] + " " i = i + 1 if i == 10: self.connection.privmsg(self.target, output) i = 0 output = self.m.MSG_ALIASES % (c.coloredIrcNickname()) + " " time.sleep(1.0) if i != 0: self.connection.privmsg(self.target, output) except: print sys.exc_info() self.connection.privmsg(self.target, self.m.MSG_ERR_DB) except: self.connection.privmsg(self.target, self.m.MSG_ERR_CID) except: self.connection.privmsg(self.target, self.m.MSG_ERR_ADMIN_MOD) else: self.connection.privmsg(self.target, self.m.MSG_ERR_OBJECT) elif message[0] == '!info' and len(message) > 1: if self.reader != None: try: if self.admins[event.source()] == 'admin' or self.admins[event.source()] == 'mod': try: c = client.Client(-1) c = self.reader.clients[int(message[1])] output = self.m.MSG_INFO + " " + c.coloredIrcNickname() + " " ip = c.ip.split(':')[0] try: (ip_ptr, alias, addr) = socket.gethostbyaddr(ip) added = " [" + ip_ptr + "]" except: print sys.exc_info() added = "" output = output + "(" + c.ip + added + ", " + c.guid + ")" if self.cfg.geoEnabled: loc = Localization(self, c.ip, output, self.target) loc.start() else: self.connection.privmsg(self.target, output) except: self.connection.privmsg(self.target, self.m.MSG_ERR_CID) except: self.connection.privmsg(self.target, self.m.MSG_ERR_ADMIN_MOD) else: self.connection.privmsg(self.target, self.m.MSG_ERR_OBJECT) elif message[0] == '!demo' and len(message) > 1: if self.reader != None: try: if self.admins[event.source()] == 'admin' or self.admins[event.source()] == 'mod': try: if len(message) >= 3: try: duration = int(message[2]) except: duration = 1 else: duration = 1 c = client.Client(-1) c = self.reader.clients[int(message[1])] output = self.m.MSG_DEMO + c.coloredIrcNickname() d = Demo(self, self.rcon, output, self.target, duration, c.id) d.start() except: self.connection.privmsg(self.target, self.m.MSG_ERR_CID) except: self.connection.privmsg(self.target, self.m.MSG_ERR_ADMIN_MOD) else: self.connection.privmsg(self.target, self.m.MSG_ERR_OBJECT) elif message[0] == '!stamina' and len(message) > 2: if self.reader != None: try: if self.admins[event.source()] == 'admin': try: c = self.getClientObject(message[1]) output = self.m.MSG_RCON_STAMINA % (c.coloredIrcNickname(), message[2]) self.rcon.send("stamina " + message[1] + " " + message[2]) self.connection.privmsg(self.target, output); except: self.connection.privmsg(self.target, self.m.MSG_ERR_CID); except: self.connection.privmsg(self.target, self.m.MSG_ERR_ADMIN); else: self.connection.privmsg(self.target, self.m.MSG_ERR_OBJECT); elif message[0] == '!wj' and len(message) > 2: if self.reader != None: try: if self.admins[event.source()] == 'admin': try: c = self.getClientObject(message[1]) output = self.m.MSG_RCON_WJ % (c.coloredIrcNickname(), message[2]) self.rcon.send("walljumps " + message[1] + " " + message[2]) self.connection.privmsg(self.target, output); except: self.connection.privmsg(self.target, self.m.MSG_ERR_CID); except: self.connection.privmsg(self.target, self.m.MSG_ERR_ADMIN); else: self.connection.privmsg(self.target, self.m.MSG_ERR_OBJECT); elif message[0] == '!damage' and len(message) > 3: if self.reader != None: try: if self.admins[event.source()] == 'admin': try: c = self.getClientObject(message[1]) if message[2] == 'source' or message[2] == 'target': output = self.m.MSG_RCON_DAMAGE % (c.coloredIrcNickname(), message[2], message[3]) self.rcon.send("damage " + message[1] + " " + message[2] + " " + message[3]) self.connection.privmsg(self.target, output); else: self.connection.privmsg(self.target, self.m.MSG_ERR_PARAMS); except: self.connection.privmsg(self.target, self.m.MSG_ERR_CID); except: self.connection.privmsg(self.target, self.m.MSG_ERR_ADMIN); else: self.connection.privmsg(self.target, self.m.MSG_ERR_OBJECT);
if k == 27: cv2.destroyAllWindows() break time.sleep(delay) #main if __name__=="__main__": robot = get_robot() filename = Excecute_Params.file_name thread.start_new_thread( show_image, ("Thread-1",robot, ) ) #obtaining start Localization loc=Localization(filename) observation = do_observation_front(robot) loc.add_observation(observation) print '>>Main. Locations: ', loc.locations while len(loc.locations) != 1: action,_ = loc.plan_action() if not robot.apply_action(action, observation): action = action + 1 robot.apply_action(action, observation) observation = do_observation_front(robot) loc.add_observation(observation, action=action) robot.play_sound(2) print 'ACTION: ', action print 'PARTIAL LOCATIONS: ', loc.locations
print('\nVOX coords not available\n') exit(1) leads = build_leads(files_mother, args.add_fs) show_leads(leads) leads_as_dict = leads_to_dict(leads) clean_json_dump(leads_as_dict, open(args.output, 'w'), indent=2, sort_keys=True) print('\nStage 0: json file saved with vox coords\n') """ Add test for fs coordinate """ leads_fs = Localization(args.output) files_fs = file_locations_fs(args.subject) if not os.path.isfile(files_fs["coord_t1"]) or not os.path.isfile( files_fs["fs_orig_t1"]): print('\n\nCoregistration not available\n') exit(1) leads_fs = build_leads_fs(files_fs, leads_fs) leads_fs.to_json(args.output + '_fs') print('\n\nStage 1: json file saved with freesurfer space coordinates\n') """ Add test for localization info """ leads_loc = Localization(args.output + '_fs') files_loc = file_locations_loc(args.subject) if not os.path.isfile(files_loc["native_loc"]):
def __init__(self, window): """Constructor.""" self._window = window self._action_group = None Localization.setup() self._insert_menu()
def text(self, *, loc: localization.Localization, session, user=False): joined_self = session.query(Order).filter_by(order_id=self.order_id).join(Transaction).one() items = "" for item in self.items: items += item.text(loc=loc) + "\n" if self.delivery_date is not None: status_emoji = loc.get("emoji_completed") status_text = loc.get("text_completed") elif self.refund_date is not None: status_emoji = loc.get("emoji_refunded") status_text = loc.get("text_refunded") else: status_emoji = loc.get("emoji_not_processed") status_text = loc.get("text_not_processed") if user and configloader.config["Appearance"]["full_order_info"] == "no": return loc.get("user_order_format_string", status_emoji=status_emoji, status_text=status_text, items=items, notes=self.notes, value=str(utils.Price(-joined_self.transaction.value, loc))) + \ (loc.get("refund_reason", reason=self.refund_reason) if self.refund_date is not None else "") else: return status_emoji + " " + \ loc.get("order_number", id=self.order_id) + "\n" + \ loc.get("order_format_string", user=self.user.mention(), date=self.creation_date.isoformat(), items=items, notes=self.notes if self.notes is not None else "", value=str(utils.Price(-joined_self.transaction.value, loc))) + \ (loc.get("refund_reason", reason=self.refund_reason) if self.refund_date is not None else "")
import rospy import argparse import matplotlib.pyplot as plt import matplotlib.animation as animation from modules.planning.proto import planning_pb2 from subplot_st_main import StMainSubplot from subplot_path import PathSubplot from subplot_sl_main import SlMainSubplot from subplot_st_speed import StSpeedSubplot from subplot_speed import SpeedSubplot from localization import Localization from planning import Planning planning = Planning() localization = Localization() def update(frame_number): # st_main_subplot.show(planning) # st_speed_subplot.show(planning) map_path_subplot.show(planning, localization) dp_st_main_subplot.show(planning) qp_st_main_subplot.show(planning) speed_subplot.show(planning) sl_main_subplot.show(planning) st_speed_subplot.show(planning) def planning_callback(planning_pb): planning.update_planning_pb(planning_pb)
# robotHeight = 0.37 #[m] ROBOT_HEIGHT = 0.42 clock = time.clock() sensor.reset() sensor.set_pixformat(sensor.RGB565) sensor.set_framesize(sensor.QVGA) sensor.set_auto_exposure(False) sensor.set_auto_whitebal(False) sensor.skip_frames(time=2000) sensor.set_auto_gain(False, gain_db=0) sensor.set_auto_whitebal(False, (-6.02073, -5.11, 1.002)) sensor.set_auto_exposure(False, 2000) vision = Vision({}) loc = Localization(-0.7, -1.3, math.pi / 2, side) strat = Strategy() motion = Motion() model = Model() vision_postprocessing = Vision_postprocessing() vision.load_detectors("vision/detectors_config.json") with open("calibration/cam_col.json") as f: calib = json.load(f) # setting model parametrs mass1 = [0, 0, 0, 0, 0, 0] mass2 = [0, 0] model.setParams(calib["cam_col"], ROBOT_HEIGHT, mass1, mass2) #motion.move_head() #model.updateCameraPanTilt(0, -math.pi/6)
const=True, help="Show all signal light stop lines with ids in map") parser.add_argument("-l", "--laneid", nargs='+', help="Show specific lane id(s) in map") parser.add_argument("--loc", action="store", type=str, required=False, help="Specify the localization pb file in txt format") args = parser.parse_args() map = Map() map.load(args.map) lane_ids = args.laneid if lane_ids is None: lane_ids = [] map.draw_lanes(plt, args.showlaneids, lane_ids) if args.showsignals: map.draw_signal_lights(plt) if args.loc is not None: localization = Localization() localization.load(args.loc) localization.plot_vehicle(plt) plt.axis('equal') plt.show()
:param triangles: Nx3 matrix containing the indices of the connected vertices """ mayavi.mlab.triangular_mesh(points[:, 0], points[:, 1], points[:, 2], triangles, opacity=.4, color=(.7, .7, .7)) subject = sys.argv[1] loc_file = sys.argv[2] files = file_locations(subject) loc = Localization(loc_file) contacts = loc.get_contacts() coords = loc.get_contact_coordinates('fs', contacts) coords_corrected = loc.get_contact_coordinates('fs', contacts, 'corrected') plot_coordinates(coords) plot_coordinates(coords_corrected, (0, 0, 1)) p, f = load_surface(files['surface_l']) p2, f2 = load_surface(files['surface_r']) plot_surface(p2, f2) plot_surface(p, f) mayavi.mlab.show()
"-sl", "--showlaneids", action="store_const", const=True, help="Show all lane ids in map") parser.add_argument( "-ss", "--showsignals", action="store_const", const=True, help="Show all signal light stop lines with ids in map") parser.add_argument( "-l", "--laneid", nargs='+', help="Show specific lane id(s) in map") parser.add_argument( "--loc", action="store", type=str, required=False, help="Specify the localization pb file in txt format") args = parser.parse_args() map = Map() map.load(args.map) lane_ids = args.laneid if lane_ids is None: lane_ids = [] map.draw_lanes(plt, args.showlaneids, lane_ids) if args.showsignals: map.draw_signal_lights(plt) if args.loc is not None: localization = Localization() localization.load(args.loc) localization.plot_vehicle(plt) plt.axis('equal') plt.show()