def __init__(self, parent): super(QWidget, self).__init__(parent) self.layout = QVBoxLayout(self) self.test_time = [0] self.test_data = [0] self.filter_counter = 0 self.filter_storage = 0 self.filtered_value = 0 self.tick = 0 # Initialize tab screen self.tabs = QTabWidget() self.tab1 = QWidget() self.tab2 = QWidget() self.tab3 = QWidget() self.tabs.resize(300, 200) # Add tabs self.tabs.addTab(self.tab1, "Main Menu") self.tabs.addTab(self.tab2, "Test") self.tabs.addTab(self.tab3, "Results") # Create first tab self.tab1.layout = QVBoxLayout(self) self.pushButton1 = QPushButton("PyQt5 button") self.tab1.layout.addWidget(self.pushButton1) self.tab1.setLayout(self.tab1.layout) # Create second tab self.tab2.layout = QVBoxLayout(self) self.pushButtonStart = QPushButton("Start the test") self.pushButtonStop = QPushButton("Stop the test") self.pushButtonWeight = QPushButton("Weight") # Set Plotter pg.setConfigOption('background', 'w') pg.setConfigOption('foreground', 'k') self.graphicsView = pg.PlotWidget(title="Coefficient of Friction Test") self.tab2.layout.addWidget(self.pushButtonStart) self.tab2.layout.addWidget(self.pushButtonStop) self.tab2.layout.addWidget(self.pushButtonWeight) self.tab2.setLayout(self.tab2.layout) self.tab2.layout.addWidget(self.graphicsView) self.layout.addWidget(self.tabs) self.setLayout(self.layout) pen = pg.mkPen(color=(255, 0, 0)) self.data_line = self.graphicsView.plot(self.test_time, self.test_data, pen=pen) # button events self.pushButtonStart.clicked.connect(self.start_test) # plot when clicked self.pushButtonStop.clicked.connect(self.stop_test) # tare when clicked self.pushButtonWeight.clicked.connect(self.btn_weight) # weight when clicked self.md = motor_driver()
speed = 0 hdg = 0 oldsteer = 500 oldspeed = 500 oldhdg = 500 auto = False comhdg = 0 left_limit = -36 right_limit = 36 epoch = time.time() wstr = "" cbuff = "" flag = False robot = motor_driver.motor_driver() #=================================================================== # progressive steering def turn(): strang = abs(steer) if (strang < 3): turnang = 1 elif (strang < 10): turnang = 2 elif (strang < 20): turnang = 3 else: turnang = 4 return turnang
import motor_driver md = motor_driver.motor_driver() md.motor_run(0.001, 400, 1)