def perf_graph(self): global graph cpugraph = self.cpugraph cpuplot = MeshLinePlot(color=[1, 0, 1]) ramgraph = self.ramgraph RAMplot = MeshLinePlot(color=[0, 1, 0]) while True: for key in ['cpu', 'RAMpc']: if len(graph[key]) >= 100: del graph[key][0] if len(graph[key]) >= 100: del graph[key][0] #print (plot) #self.cpugraph.remove_plot(plot) graph['cpu'].append(int(psutil.cpu_percent())) graph['RAMpc'].append(psutil.virtual_memory().percent) RAMplot.points = [(i, j) for i, j in enumerate(graph['RAMpc'])] cpuplot.points = [(i, j) for i, j in enumerate(graph['cpu'])] try: self.ramgraph.add_plot(RAMplot) self.cpugraph.add_plot(cpuplot) except: pass #print (graph['cpu']) time.sleep(0.6)
def updatePoints(self, *args): instant_imu = self.imu_instance.dq.get() self.c_time = instant_imu[0] - 1609477200 #epoch time since beg 2021 if len(self.psi) > 1000: self.psi.append([self.c_time, instant_imu[1]]) self.phi.append([self.c_time, instant_imu[2]]) self.theta.append([self.c_time, instant_imu[3]]) self.psi = self.psi[-1:-7 * self.sensor_refresh] self.phi = self.phi[-1:-7 * self.sensor_refresh] self.theta = self.theta[-1:-7 * self.sensor_refresh] else: self.psi.append([self.c_time, instant_imu[1]]) self.phi.append([self.c_time, instant_imu[2]]) self.theta.append([self.c_time, instant_imu[3]]) plot_psi = MeshLinePlot(color=[1, 0, 0, 1]) plot_phi = MeshLinePlot(color=[0, 1, 0, 1]) plot_theta = MeshLinePlot(color=[0, 0, 1, 1]) plot_psi.points = self.psi plot_phi.points = self.phi plot_theta.points = self.theta self.root.ids.graph01.add_plot(plot_psi) self.root.ids.graph01.add_plot(plot_phi) self.root.ids.graph01.add_plot(plot_theta) self.root.ids.testYawOut.text = f'{instant_imu[1]}-> yaw'
def make_plot(plot_price, plot_dates, tickers_on_plot, plot_colors, xlabel='Bitcoin'): x = list(range(1, (len(plot_price) + 1))) y = plot_price y_axis_ticks = (max(y) - min(y)) / 5 plot = None graph = Graph(xlabel=xlabel, x_ticks_major=1, y_ticks_major=y_axis_ticks, y_grid_label=True, x_grid_label=True, padding=10, x_grid=False, y_grid=False, xmin=min(x), xmax=max(x), ymin=min(y), ymax=max(y)) for i in range(0, len(tickers_on_plot)): plot = MeshLinePlot(color=plot_colors[i]) plot.points = [(i, j) for i, j in zip(x, (y))] graph.add_plot(plot) return graph
def make_plot(ratings_list, plot_dates, plot_tickers, plot_colors): # Prepare the data x = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] # make the graph graph = Graph(ylabel='Ratings', x_ticks_major=1, y_ticks_minor=1, y_ticks_major=1, y_grid_label=True, x_grid_label=False, padding=5, x_grid=True, y_grid=True, xmin=0, xmax=10, ymin=0, ymax=10) if (len(plot_tickers) > 0): i = 0 while (i < len(plot_tickers)): plot = MeshLinePlot(color=plot_colors[i]) plot.points = [(i, j) for i, j in zip(x, ratings_list[i])] graph.add_plot(plot) i += 1 return graph
def updatePoints(self, *args): #Pull data from LIFO queue from imu instance instant_imu = self.imu_instance.dq.get() instant_imu = instant_imu[1:5] #try with 4 or 5... odd behabior so debug opp # epoch time since beg 2021 self.c_time = instant_imu[0] - 1609477200 h_vec = [self.height, 0, 0] rr = R.from_quat(instant_imu) s = rr.apply(h_vec) self.cop.append([s[0], -1*s[1]]) if len(self.cop) > 50: self.cop = self.cop[-50:] plot_cop = MeshLinePlot(color=[0, 1, 0, 1]) plot_cop.points = self.cop self.root.ids.graph01.remove_plot(plot_cop) self.root.ids.graph01._clear_buffer(plot_cop) self.root.ids.graph01.add_plot(plot_cop)
def create_graph(self): colors = itertools.cycle([ rgb('7dac9f'), rgb('dc7062'), rgb('66a8d4'), rgb('e5b060') ]) graph_theme = { 'label_options': { 'color': (0, 0, 0, 1), 'bold': False}, 'background_color': (.9, .9, .9, 1), 'tick_color': rgb('808080'), 'border_color': rgb('808080') } graph = Graph(xlabel='', ylabel='Glicemia', font_size=14, x_ticks_minor=0, x_ticks_major=25, y_ticks_major=1, y_grid_label=True, x_grid_label=True, padding=5, x_grid=True, y_grid=True, xmin=-0, xmax=100, ymin=-1, ymax=1, **graph_theme) #plot = MeshLinePlot(color=[1, 0, 0, 1]) plot = MeshLinePlot(color=next(colors)) plot.points = [(x, sin(x/10.)) for x in range(0, 101)] graph.add_plot(plot) return graph
def compute_contours(self): graph = self.graph if graph is None or not self.x2_variable: return for plot in self._contour_plots: self.graph.remove_plot(plot) plots = self._contour_plots = [] data = np.clip(self._yvals, self.y_start, self.y_end) xscale = (self.end - self.start) / self.num_points x2scale = (self.x2_end - self.x2_start) / self.num_points color = next(self.colors) for val in np.linspace(self.y_start, self.y_end, self.num_contours): contours = measure.find_contours(data, val) for contour in contours: contour[:, 0] *= xscale contour[:, 0] += self.start contour[:, 1] *= x2scale contour[:, 1] += self.x2_start plot = MeshLinePlot(color=color) plots.append(plot) graph.add_plot(plot) plot.points = contour
def build(self): graph = Graph(xlabel='X', ylabel='Y', x_ticks_minor=5, x_ticks_major=25, y_ticks_major=1, y_grid_label=True, x_grid_label=True, padding=5, x_grid=True, y_grid=True, xmin=-0, xmax=100, ymin=-1, ymax=1) plot = MeshLinePlot(color=[1, 0, 0, 1]) plot.points = [(x, sin(x / 10.)) for x in range(0, 101)] graph.add_plot(plot) return graph
def __init__(self, **kwargs): super().__init__(**kwargs) print([type(widget) for widget in self.walk(loopback=True)]) plot = MeshLinePlot(color=[1, 0, 0, 1]) plot.points = [(x, sin(x / 10.)) for x in range(0, 101)] # Appel du widget avec l'id graph self.ids.graph.add_plot(plot)
def update_graph(self): self.graph.ymax = 10 # plot = MeshLinePlot(color=[1, 1, 0, 1]) # plot.points = [(x, sin(x / 10.)) for x in range(0, 101)] # # plot1 = MeshLinePlot(color=[1, 0, 0, 1]) # plot1.points = [(x, sin(x / 5.)) for x in range(0, 101)] plot2 = MeshLinePlot(color=[0, 0, 0, 1]) plot2.points = [(1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (1, 7), (1, 8)] self.graph.add_plot(plot2)
def rainGraph(self): rainY = [] for i in range(len(self.fileData) - 19, len(self.fileData)): rainY.append(str(math.floor((float(self.fileData[i][8]))))) plot = None graph = Graph(size_hint = (0.5,0.8), pos_hint = {'x': .24, 'y': 0}, ylabel='Rain Events', xlabel='Time', x_ticks_major=1, y_ticks_minor=1, y_ticks_major=1, y_grid_label=True, x_grid_label=True, padding=5, x_grid=True, y_grid=True, xmin=0, xmax=20, ymin=0, ymax=50, background_color = [1,1,1,.2]) plot = MeshLinePlot(color=[.5, 0, .5, 1]) plot.points = [(int(i), int(rainY[i])) for i in range(0, 19)] graph.add_plot(plot) return graph
def humidGraph(self): humidY = [] for i in range(len(self.fileData) - 19, len(self.fileData)): humidY.append(str(math.floor((float(self.fileData[i][4]))))) humidityPlot = None humidityGraph = Graph(size_hint = (0.5,0.8), pos_hint = {'x': .24, 'y': 0}, ylabel='% Humidity', xlabel='Time', x_ticks_major=1, y_ticks_minor=1, y_ticks_major=1, y_grid_label=True, x_grid_label=True, padding=5, x_grid=True, y_grid=True, xmin=0, xmax=20, ymin=0, ymax=100, background_color = [1,1,1,.2]) humidityPlot = MeshLinePlot(color=[.5,0 ,.5, 1]) humidityPlot.points = [(int(i), int(humidY[i])) for i in range(0, 19)] humidityGraph.add_plot(humidityPlot) return humidityGraph
def tempGraph(self): tempY =[] for i in range(len(self.fileData) - 19, len(self.fileData)): tempY.append(str(math.floor((float(self.fileData[i][6]))))) plot = None graph = Graph(size_hint = (.5,.8), ylabel='Outside Temperature (C)', xlabel = 'Time', x_ticks_major = 1, y_ticks_minor = 1, y_ticks_major = 1, y_grid_label=True, x_grid_label=True, padding=5, x_grid=True, y_grid=True, xmin=0, xmax=20, ymin=-10, ymax=50, pos_hint = {'x': .24, 'y': .2}, background_color = [1,1,1,.2]) plot = MeshLinePlot(color = [1,1,1,1]) plot.points = [(int(i), int(tempY[i])) for i in range(0, 19)] graph.add_plot(plot) return graph
def draw_graph(self): sessions = App.get_running_app().root.loadDrill() screen_width = self.get_root_window().width self.xmax = 1 if len(sessions)== 0 else len(sessions) #numero de sessoes feitas if self.xmax <= self.X_TICKS_DEFAULT: self.width = screen_width if self.xmax > self.X_TICKS_DEFAULT: self.width = (screen_width)+((self.xmax - self.X_TICKS_DEFAULT)*(screen_width * self.RATIO_OF_TEN_TICKS)) plot = MeshLinePlot(color=[1, 1, 0, 1]) plot_start = PointPlot(color=[.7, .7, 0, 1], point_size=5) # print(plot.get_drawings()) self.remove_plot(plot) self.remove_plot(plot_start) plot.points = [((sessions.index(session)), round(session['accuracy']*100, 1)) for session in sessions] plot_start.points = [((sessions.index(session)), round(session['accuracy']*100, 1)) for session in sessions] self.add_plot(plot) self.add_plot(plot_start)
def all_graph(Shear_list, length, position, label): datapoints = np.arange(0, length, 0.01) point_data_list = [] multiplier = 1 if label == "Bending moment (kNm)" or label == "Deflection (1/EI)" or 'Axial Stress (kN)': multiplier = -1 ymax = 0 ymin = 0 min_y = 0 max_y = 0 for i in range(len(datapoints)): point_data = 0 for all in Shear_list: point_data += all.calculate(datapoints[i])*multiplier if point_data + abs(point_data / 5) > ymax: ymax = point_data + abs(point_data / 5) elif ymin > point_data - abs(point_data / 5): ymin = point_data - abs(point_data / 5) point_data_list.append((datapoints[i], point_data)) if i == 0: max_y = point_data min_y = point_data else: max_y = max(point_data, max_y) min_y = min(point_data, min_y) ymax = int(round(ymax, 0)) ymin = int(round(ymin, 0)) max_y = round(max_y, 3) min_y = round(min_y, 3) if ymax == 0: ymax = 1 if ymin == 0: ymin = -1 graph = Graph(pos_hint=position, size_hint=(0.7, 0.9), xlabel='Position', ylabel=label, x_ticks_minor=5, x_ticks_major=length / 10, x_grid_label=True, y_grid_label=True, y_ticks_major=(ymax-ymin)/5, y_ticks_minor=5, padding=5, x_grid=True, y_grid=True, xmax=length, xmin=0, ymin=ymin, ymax=ymax) plot = MeshLinePlot() plot.points = point_data_list graph.add_plot(plot) return graph, [min_y, max_y]
def createPlot(self): ''' Clear existing plots, and add a plot for each specificed test to the graph. Each will be colour coded to match the background of the test rowButtons Could (should!) do actual stats stuff to get expected values of each dice pool, but 10k tests takes negligible time even on a phone ''' for plot in self.plotList: self.graph.remove_plot(plot) self.plotList = [] maxCount = [500] maxValue = [6] numberOfTests = 10000 for index, test in enumerate(self.testList): outcomes = {} diceList = re.findall(r"[\w\d']+", test[0].text) if len(diceList) > 0: bonus = 0 if len(test[1].text) == 0 else int(test[1].text) for i in range(0,numberOfTests): diceResult = diceRoll.rollDicePool(diceList = diceList, bonus = bonus)[0] if diceResult in outcomes: outcomes[diceResult]+=1 else: outcomes[diceResult] = 1 plot = MeshLinePlot(color=self.plotColorMap[index],mode = 'points') xList = [key for key in outcomes] xList.sort() plot.points = [(key, outcomes[key]) for key in xList] maxCount.append(max(outcomes[key] for key in outcomes)) maxValue.append(max(key for key in outcomes)) expectedValue = round(sum([key * outcomes[key] for key in outcomes])/numberOfTests,1) test[2].text = str(expectedValue) if expectedValue != 0 else 'Error with {diceList}'.format(diceList = diceList) self.results=outcomes self.graph.add_plot(plot) self.plotList.append(plot) #Pad graph axes to make maximum values clear and prevent them being lost over the edge of the visible space self.graph.xmax = max(maxValue) + 2 self.graph.ymax = max(maxCount) + 500
from math import sin from kivy_garden.graph import Graph, MeshLinePlot graph = Graph(xlabel='X', ylabel='Y', x_ticks_minor=5, x_ticks_major=25, y_ticks_major=1, y_grid_label=True, x_grid_label=True, padding=5, x_grid=True, y_grid=True, xmin=-0, xmax=100, ymin=-1, ymax=1) plot = MeshLinePlot(color=[1, 0, 0, 1]) plot.points = [(x, sin(x / 10.)) for x in range(0, 101)] graph.add_plot(plot)
def oil_get(self): try: for plot in self.displ.plots: self.displ.remove_plot(plot) except: pass df_prediction = 0 self.plot = 0 if (self.wti.state == 'normal' and self.brent.state == 'normal') or ( self.lr.state == 'normal' and self.svm.state == 'normal'): return None else: header = { 'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.64 Safari/537.11', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.3', 'Accept-Encoding': 'none', 'Accept-Language': 'en-US,en;q=0.8', 'Connection': 'keep-alive' } df = 0 real_date = [] real_price = [] if self.wti.state == 'down': url = "https://www.investing.com/commodities/crude-oil-historical-data" req = urllib.request.Request(url, headers=header) html = urlopen(req).read() soup_html = soup(html, 'html.parser') data = soup_html.find(id="curr_table").find_all("tr") for i in data[1:]: j = i.find_all("td") real_price.append(j[1].text) real_date.append(j[0].text) self.displ.ylabel = 'Price ($)' self.gtitle.text = 'WTI Price Forecast Using' elif self.brent.state == 'down': url = "https://www.investing.com/commodities/brent-oil-historical-data" req = urllib.request.Request(url, headers=header) html = urlopen(req).read() soup_html = soup(html, 'html.parser') data = soup_html.find(id="curr_table").find_all("tr") for i in data[1:]: j = i.find_all("td") real_price.append(j[1].text) real_date.append(j[0].text) self.displ.ylabel = 'Brent Crude Oil Price' self.gtitle.text = 'Brent Price Forecast Using' df = pd.DataFrame({'Date': real_date, 'Price': real_price}) df['Date'] = pd.to_datetime(df['Date']) df = df.sort_index(ascending=False).reset_index(drop=True) df['Price'] = df['Price'].astype(float) new_row = [] if df.shape[0] == 23: for i in range(1, 3): new_row.append(df.iloc[-1][0] + timedelta(days=i)) new_row = pd.DataFrame({ 'Date': new_row, 'Price': [np.nan, np.nan] }) elif df.shape[0] == 24: new_row = pd.DataFrame({ 'Date': df.iloc[-1][0] + timedelta(days=1), 'Price': [np.nan] }) df = df.append(new_row, ignore_index=True) df.fillna(df.mean(), inplace=True) array_df = np.array(df['Price']).reshape(-1, 1) scaler = MinMaxScaler(feature_range=(0, 1)) scaled_df = scaler.fit_transform(array_df) x_forecast = np.array([[i[0]] for i in scaled_df][-25:]) prediction = 0 if self.lr.state == 'down' and self.wti.state == 'down': lr_model = pickle.load(open('lr.pkl', 'rb')) lr_prediction = lr_model.predict(x_forecast) prediction = scaler.inverse_transform( lr_prediction.reshape(-1, 1)) self.gtitle.text = self.gtitle.text + ' LR' elif self.svm.state == 'down' and self.wti.state == 'down': svm_model = pickle.load(open('svr.pkl', 'rb')) svm_prediction = svm_model.predict(x_forecast) prediction = scaler.inverse_transform( svm_prediction.reshape(-1, 1)) self.gtitle.text = self.gtitle.text + ' SVM' elif self.svm.state == 'down' and self.brent.state == 'down': svm_model = pickle.load(open('svrbrent.pkl', 'rb')) svm_prediction = svm_model.predict(x_forecast) prediction = scaler.inverse_transform( svm_prediction.reshape(-1, 1)) self.gtitle.text = self.gtitle.text + ' SVM' elif self.lr.state == 'down' and self.brent.state == 'down': svm_model = pickle.load(open('lrbrent.pkl', 'rb')) svm_prediction = svm_model.predict(x_forecast) prediction = scaler.inverse_transform( svm_prediction.reshape(-1, 1)) self.gtitle.text = self.gtitle.text + ' LR' date = [] for i in range(1, 26): date.append(df.loc[24, 'Date'] + timedelta(days=i)) df_prediction = pd.DataFrame({ 'Date': date, 'Price': [i[0] for i in prediction] }) df_prediction = df.append(df_prediction, ignore_index=True) self.displ.ymin = int(df_prediction['Price'].min() - 2) self.displ.ymax = int(df_prediction['Price'].max() + 2) self.displ.y_ticks_major = ( int(df_prediction['Price'].max() + 2) - int(df_prediction['Price'].min() - 2)) / 2 self.displ.y_grid_label = True plot = MeshLinePlot(color=[1, 0, 0, 1]) plot.points = [(i, df_prediction.iloc[i][1]) for i in range(50)] self.displ.add_plot(plot) # plot = MeshLinePlot(color=[1, 0, 0, 1]) # plot.points = [(x, sin(x / 10.)) for x in range(0, 101)] # self.displ.add_plot(plot) return df_prediction
def on_start(self): self.animate_background() self.animate_card() counter = 0 wall_user_options = { "checkerboard-plus": "Add New Problem", "cloud-download-outline": "Load Problem", "engine-outline": "Generate Problem", "new-box": "Reset Wall", "home-lightbulb": "Show Problem", } wall_ids = { 1: "A11", 2: "B11", 3: "C11", 4: "D11", 5: "E11", 6: "F11", 7: "G11", 8: "H11", 9: "I11", 10: "J11", 11: "K11", 13: "A10", 14: "B10", 15: "C10", 16: "D10", 17: "E10", 18: "F10", 19: "G10", 20: "H10", 21: "I10", 22: "J10", 23: "K10", 25: "A9", 26: "B9", 27: "C9", 28: "D9", 29: "E9", 30: "F9", 31: "G9", 32: "H9", 33: "I9", 34: "J9", 35: "K9", 37: "A8", 38: "B8", 39: "C8", 40: "D8", 41: "E8", 42: "F8", 43: "G8", 44: "H8", 45: "I8", 46: "J8", 47: "K8", 49: "A7", 50: "B7", 51: "C7", 52: "D7", 53: "E7", 54: "F7", 55: "G7", 56: "H7", 57: "I7", 58: "J7", 59: "K7", 61: "A6", 62: "B6", 63: "C6", 64: "D6", 65: "E6", 66: "F6", 67: "G6", 68: "H6", 69: "I6", 70: "J6", 71: "K6", 73: "A5", 74: "B5", 75: "C5", 76: "D5", 77: "E5", 78: "F5", 79: "G5", 80: "H5", 81: "I5", 82: "J5", 83: "K5", 85: "A4", 86: "B4", 87: "C4", 88: "D4", 89: "E4", 90: "F4", 91: "G4", 92: "H4", 93: "I4", 94: "J4", 95: "K4", 97: "A3", 98: "B3", 99: "C3", 100: "D3", 101: "E3", 102: "F3", 103: "G3", 104: "H3", 105: "I3", 106: "J3", 107: "K3", 109: "A2", 110: "B2", 111: "C2", 112: "D2", 113: "E2", 114: "F2", 115: "G2", 116: "H2", 117: "I2", 118: "J2", 119: "K2", 121: "A1", 122: "B1", 123: "C1", 124: "D1", 125: "E1", 126: "F1", 127: "G1", 128: "H1", 129: "I1", 130: "J1", 131: "K1", } """ Fill Side Menu with items START""" for icon_name in wall_user_options.keys(): self.root.ids.content_drawer.ids.md_list.add_widget( ItemDrawer(icon=icon_name, text=wall_user_options[icon_name])) """ serves as a seperator for two itemdrawers""" self.root.ids.content_drawer.ids.md_list.add_widget( OneLineListItem(text="")) """ Adds logout option in the drawer menu""" self.root.ids.content_drawer.ids.md_list.add_widget( ItemDrawer(icon="logout", text="Sign Out")) """ Fill Side Menu with items END""" """ Fill ClimbingGrid with holds START""" for i in range(0, 132): if i % 12 == 0 or i == 0: self.root.ids.wall_system.add_widget( MDLabel(text=str(11 - counter), halign="center", size_hint_x=None, width=25, theme_text_color="Custom", text_color=(1, 1, 1, 1), font_style="H6", font_name="JetBrainsMono")) counter = counter + 1 else: self.root.ids.wall_system.add_widget( HoldLayout(id=wall_ids[i])) """Draw GRAPH""" graph = Graph(xlabel='X', ylabel='Y', x_ticks_minor=5, x_ticks_major=25, y_ticks_major=1, y_grid_label=True, x_grid_label=True, padding=5, x_grid=True, y_grid=True, xmin=-0, xmax=100, ymin=-1, ymax=1) plot = MeshLinePlot(color=[1, 0, 0, 1]) plot.points = [(x, sin(x / 10.)) for x in range(0, 101)] graph.add_plot(plot) self.root.ids.screen_three.add_widget(graph) self.initiate_problem_list() """ Fill ClimbingGrid with holds END"""
def motors_plot(self, *args): """ The method takes the variable from Mainscreen class that returns: return [self.m, self.snap_shot] reg = MainScreen().show_snapshot()[0] which must be initialized in the init :param args: None :return: None """ # Graph Constants motor_0 = self.ids.motor0_graph motor_1 = self.ids.motor1_graph motor_2 = self.ids.motor2_graph motor_3 = self.ids.motor3_graph # Color Yellow plot_set_val_0 = MeshLinePlot(color=[1, 1, 0, 1]) plot_set_val_1 = MeshLinePlot(color=[1, 1, 0, 1]) plot_set_val_2 = MeshLinePlot(color=[1, 1, 0, 1]) plot_set_val_3 = MeshLinePlot(color=[1, 1, 0, 1]) # Color Blue plot_pid_val_0 = MeshLinePlot(color=[0, 0, 1, 1]) plot_pid_val_1 = MeshLinePlot(color=[0, 0, 1, 1]) plot_pid_val_2 = MeshLinePlot(color=[0, 0, 1, 1]) plot_pid_val_3 = MeshLinePlot(color=[0, 0, 1, 1]) # Color violet plot_input_val_0 = MeshLinePlot(color=[0, 1, 1, 1]) plot_input_val_1 = MeshLinePlot(color=[0, 1, 1, 1]) plot_input_val_2 = MeshLinePlot(color=[0, 1, 1, 1]) plot_input_val_3 = MeshLinePlot(color=[0, 1, 1, 1]) motor_0.add_plot(plot_set_val_0) motor_0.add_plot(plot_pid_val_0) motor_0.add_plot(plot_input_val_0) motor_1.add_plot(plot_set_val_1) motor_1.add_plot(plot_pid_val_1) motor_1.add_plot(plot_input_val_1) motor_2.add_plot(plot_set_val_2) motor_2.add_plot(plot_pid_val_2) motor_2.add_plot(plot_input_val_2) motor_3.add_plot(plot_set_val_3) motor_3.add_plot(plot_pid_val_3) motor_3.add_plot(plot_input_val_3) # Graph Variables # the Reg value must be initialized in order to get the right values # print(len(self.reg[0])) # Sampled only 100 values reg_stream = our_value[0] # reg_stream = [self.rollSet_list, self.pitchSet_list, self.yawSet_list, self.rollPID_list, self.pitchPID_list, # self.yawPID_list, self.rollInput, self.pitchInput, self.yawInput] reg_snap = our_value[1] # print(reg_snap) # print(yaw) set_point = reg_stream[0:3] pid_point = reg_stream[3:6] output_point = reg_stream[6:9] reg_0 = set_point[0] # Set_point reg_1 = pid_point[0] # Input reg_2 = output_point[0] # Output reg_3 = set_point[1] # Set_point reg_4 = pid_point[1] # Input reg_5 = output_point[1] # Output # print("Hwll ", reg_4) reg_6 = set_point[2] # Set_point reg_7 = pid_point[2] # Input reg_8 = output_point[2] # Output # TODO The speed gets smaller as values increases, should i pop some out? delete? # TODO The speed is also slow when there is no connection # do i need the data? if self.pressed == "Continua": # print("x min is ", self.x_min0) # print(self.pop_counter) # self.x_min0 = self.x_min0 + 1 # self.x_max0 = len(reg_0) + self.x_min0 + 1 # self.x_max0 = len(reg_0) # self.x_max1 = len(reg_1) # self.x_max2 = len(reg_2) # self.x_max3 = len(reg_3) # if self.x_max0 % 100 == 0: # self.n = self.n + 1 d = self.x_max0 - self.x_min0 if self.x_max0 <= self.dazzle: a = self.dazzle // d * d # self.x_max0 = self.x_max0 + a + 1 self.x_min0 = a self.x_max0 = d + a self.x_min1 = a self.x_max1 = d + a self.x_min2 = a self.x_max2 = d + a self.x_min3 = a self.x_max3 = d + a # self.dazzle = 2 * self.x_max0 self.dazzle = self.dazzle + 1 if self.dazzle == 100: self.dazzle = self.x_max0 # if (self.dazzle - self.x_min0) < 5: # self.x_min0 = self.dazzle # print("the dazzle value is ", self.dazzle) # print("x max is ", self.x_max0) # for i in range(0, len(self.recv_reg)): # if len(self.recv_reg[i]) % 100 == 0: # reg_100.append(self.recv_reg[i][-100:-1]) # # if self.zoom_index != 0: # if len(reg_100) % 3 == 0: # reg_0 = reg_100[0 + 3 * self.zoom_index] # reg_1 = reg_100[1 + 3 * self.zoom_index] # reg_2 = reg_100[2 + 3 * self.zoom_index] # # print(reg_0) else: if self.pressed == "Continua": self.pressed = "0" """ALERT ALERT ALERT bug here Press Slowly as you Can, We(reg_snap) are gathering data and we can not predict the future yet I SMELL A BIG BUG, AND I'M LEAVING IT :) TODO: Access the axises from here ?? SOLN: Binding is the cure: I leave this one as a battle scare (reminder next time) self.x_max0 = self.x_max0 self.x_min0 = self.x_min0 """ # reg_snap consists of 100 values of snaps each time a = int(self.pressed) # gives output of n_snaps lists consisting of nine lists each of 100 values # if a > len(reg_snap): # a = a - 1 # self.pressed = str(a - 1) print("the value of a is ", a) print("the value of len(reg_snap) is ", reg_snap) dm = [] for i in range(0, len(reg_snap)): if len(reg_snap[i]) != 0: for j in range(0, len(reg_snap[i])): if len(reg_snap[i][j]) != 0: dm.append(reg_snap[i][j]) if len(dm) != 0: self.reg.append(dm) print("Reg self.reg is ", self.reg) print(len(self.reg)) if a <= len(self.reg): a = a - 1 reg_number = self.reg[ a] # Now we have 9 values consisting of lists # print("Reg value ", reg_number[a]) print("reg a ", self.reg[a]) set_point_snap = reg_number[0:3] pid_point_snap = reg_number[3:6] output_point_snap = reg_number[6:9] print(set_point_snap) reg_0_snap = set_point_snap[0] # Set_point reg_1_snap = pid_point_snap[0] # Input reg_2_snap = output_point_snap[0] # Output reg_3_snap = set_point_snap[1] # Set_point reg_4_snap = pid_point_snap[1] # Input reg_5_snap = output_point_snap[1] # Output # print("Hwll ", reg_4) reg_6_snap = set_point_snap[2] # Set_point reg_7_snap = pid_point_snap[2] # Input reg_8_snap = output_point_snap[2] # Output # 0 up to 10 for the first 100 values # 10 up to 20 f0r the second 100 values reg_0 = reg_0_snap[self.yaw_id_from:self.yaw_id_to] reg_1 = reg_1_snap[self.yaw_id_from:self.yaw_id_to] reg_2 = reg_2_snap[self.yaw_id_from:self.yaw_id_to] reg_3 = reg_3_snap[self.pitch_id_from:self.pitch_id_to] reg_4 = reg_4_snap[self.pitch_id_from:self.pitch_id_to] reg_5 = reg_5_snap[self.pitch_id_from:self.pitch_id_to] reg_6 = reg_6_snap[self.roll_id_from:self.roll_id_to] reg_7 = reg_7_snap[self.roll_id_from:self.roll_id_to] reg_8 = reg_8_snap[self.roll_id_from:self.roll_id_to] # self.x_max0 = len(reg_0) # self.x_min0 = self.x_min0 # self.x_max1 = len(reg_1) # self.x_min1 = self.x_min1 # self.x_max2 = len(reg_2) # self.x_min2 = self.x_min2 # self.x_max3 = len(reg_3) # self.x_min3 = self.x_min2 a = (len(reg_6)) * (a + 1) # self.x_max0 = self.x_max0 + a + 1 self.x_min0 = a self.x_max0 = 100 + a self.x_min1 = a self.x_max1 = 100 + a self.x_min2 = a self.x_max2 = 100 + a self.x_min3 = a self.x_max3 = 100 + a # self.dazzle = 2 * self.x_max0 self.dazzle = self.dazzle + 1 if self.dazzle == 100: self.dazzle = self.x_max0 self.size_snap = [ len(reg_0), len(reg_1), len(reg_2), len(reg_3), len(reg_4), len(reg_5), len(reg_6), len(reg_7), len(reg_8) ] print("Got here") # print("reached here") # # print(self.pressed) # self.x_min0 = self.x_min0 + 1 # self.x_max0 = len(reg_0) + self.x_min0 + 1 # if self.counter >= 10: # self.x_max0 = self.x_max0 + 1 # self.x_min0 = self.x_min0 + 1 # # self.x_max1 = self.x_max2 + 1 # self.x_min1 = self.x_min1 + 1 # # self.x_max2 = self.x_max2 + 1 # self.x_min2 = self.x_min2 + 1 # # self.x_max3 = self.x_max3 + 1 # self.x_min3 = self.x_min3 + 1 # # self.counter = self.counter + 1 # print(self.counter) plot_set_val_0.points = [(x, int(reg_0[x])) for x in range(0, len(reg_0))] plot_pid_val_0.points = [(x, int(reg_1[x])) for x in range(0, len(reg_1))] plot_input_val_0.points = [(x, int(reg_2[x])) for x in range(0, len(reg_2))] # if len(recv_reg[1]) > 100: # recv_reg[1].clear() # self.x_max1 = len(recv_reg[1]) plot_set_val_1.points = [(x, int(reg_3[x])) for x in range(0, len(reg_3))] plot_pid_val_1.points = [(x, int(reg_4[x])) for x in range(0, len(reg_4))] plot_input_val_1.points = [(x, int(reg_5[x])) for x in range(0, len(reg_5))] # if len(recv_reg[2]) > 100: # recv_reg[2].clear() # self.x_max2 = len(recv_reg[2]) plot_set_val_2.points = [(x, int(reg_6[x])) for x in range(0, len(reg_6))] plot_pid_val_2.points = [(x, int(reg_7[x])) for x in range(0, len(reg_7))] plot_input_val_2.points = [(x, int(reg_8[x])) for x in range(0, len(reg_8))] # # if len(recv_reg[3]) > 100: # recv_reg[3].clear() # self.x_max3 = len(recv_reg[3]) plot_set_val_3.points = [(x, x) for x in range(0, len(reg_3))] plot_pid_val_3.points = [(x, x * x) for x in range(0, len(reg_3))] plot_pid_val_3.points = [(x, 10 * x) for x in range(0, len(reg_3))] # send PID values global pid_values pid_values = [ self.yaw_Ki, self.yaw_Kd, self.yaw_Kp, self.pitch_Ki, self.pitch_Kd, self.pitch_Kp, self.roll_Ki, self.roll_Kd, self.roll_Kp ]