Best Python code snippet using SeleniumBase
qtable_storage.py
Source:qtable_storage.py
...
eurobot_fsm.py
Source:eurobot_fsm.py
...63 self.image_processing.start_image_processing()64 if tick == 10: # Gives time to get the image and process it 65 self.puck_colors = self.image_processing.get_puck_colors()66 self.nav.set_speed(0.9)67 self.nav.go_forward(1.48)68 self.__lift_control('down')69 elif tick == 25:70 self.__vacuum_pumps_control('on')71 72 elif tick == 35: # go on blue 73 self.__lift_control('up')74 self.nav.go_forward(-0.95)75 76 elif tick == 45: # go on green. We have reached BLUE77 self.__lift_control('down')78 if not self.puck_colors['error']:79 for place in self.puck_colors:80 if self.puck_colors[place] == 'blue':81 self.__vacuum_pumps_control('off', place)82 self.nav.go_forward(-.30)83 84 elif tick == 55: # go on red, We have reached GREEN85 if not self.puck_colors['error']:86 for place in self.puck_colors:87 if self.puck_colors[place] == 'green':88 self.__vacuum_pumps_control('off', place)89 self.nav.go_forward(-.35)90 elif tick == 65: # We are on RED. Dump everything left here 91 self.__vacuum_pumps_control('off')92 self.nav.go_forward(-.15)93 elif tick == 75:94 self.nav.rotate(-90)95 elif tick == 85: 96 self.nav.go_forward(.50) # 53 if we stop it once | todo: reslove this 97 98 elif tick == 95:99 self.nav.rotate(90)100 elif tick == 110:101 self.__lift_control('down')102 self.nav.go_forward(1.18)103 elif tick == 125:104 self.__vacuum_pumps_control('on')105 106 elif tick == 130:107 self.__lift_control('up')108 elif tick == 135:109 self.nav.go_forward(-.98)110 elif tick == 155:111 self.nav.rotate(90)112 self.__lift_control('down')113 elif tick == 170:114 self.nav.go_forward(.25)115 self.__vacuum_pumps_control('off')116 def strategy_two(self, tick):117 if tick == 5:118 self.__lift_control('down')119 self.nav.go_forward(-.20)120 121 if tick == 20:122 self.__lift_control('down')123 self.nav.rotate(-90)124 if tick == 35:125 self.nav.go_forward(1.5)126 if tick == 55:127 self.nav.rotate(90)128 if tick == 70:129 self.nav.go_forward(1.07)130 131 if tick == 90:132 self.nav.rotate(-90)133 134 if tick == 105:135 self.nav.go_forward(.38)136 if tick == 115:137 self.nav.rotate(90)138 if tick == 130:139 self.nav.set_speed(0.5)140 self.nav.go_forward(.151) # .148141 142 if tick == 150:143 self.__vacuum_pumps_control('on')144 self.nav.go_forward(-.151)145 146 if tick == 160:147 self.nav.set_speed(0.8)148 self.__lift_control('up')149 self.nav.rotate(130)150 if tick == 200:151 self.nav.go_forward(1.25)152 if tick == 215:153 self.nav.rotate(-40)154 if tick == 225:155 self.nav.go_forward(.4)156 if tick == 245:157 self.__vacuum_pumps_control('off')158 if tick == 255:159 self.nav.go_forward(.3)160 def __lift_control(self, data):161 msg = Float32()162 if data == 'up':163 msg.data = 0.1164 elif data == 'down':165 msg.data = 0.0166 self.__right_lift_publisher.publish(msg)167 self.__left_lift_publisher.publish(msg)168 self.__center_lift_publisher.publish(msg)169 def __vacuum_pumps_control(self, data, vacuum_pump='all'):170 msg = Bool()171 if data == 'on':172 msg.data = True173 elif data == 'off':...
3rd_20181658_leesungjin.py
Source:3rd_20181658_leesungjin.py
...19 # =======================================================================20 def car_startup(self):21 # implement the assignment code here22 distance = self.car.distance_detector.get_distance()23 self.car.accelerator.go_forward(40)24 count = 025 print("start")26 countstop = 027 while(True):28 print(self.car.line_detector.read_digital())29 distance = self.car.distance_detector.get_distance()30 print(distance)31 if distance == -1:32 continue33 if distance <= 20:34 count += 135 if count >= 10:36 self.car.accelerator.stop()37 self.car.steering.turn_left(55)38 self.car.accelerator.go_forward(50)39 time.sleep(1)40 self.car.accelerator.stop()41 self.car.steering.turn_right(165)42 self.car.accelerator.go_forward(80)43 time.sleep(1.9)44 countstop += 145 print(countstop)46 count = 047 while(True):48 if(self.car.line_detector.read_digital() != [0,0,0,0,0]):49 break50 51 if(self.car.line_detector.read_digital() == [0,0,1,0,0]):52 self.car.accelerator.go_forward(40)53 elif(self.car.line_detector.read_digital() == [1,0,0,0,0]):54 self.car.steering.turn_left(60)55 self.car.accelerator.go_forward(40)56 elif(self.car.line_detector.read_digital() == [1,1,0,0,0]):57 self.car.steering.turn_left(65)58 self.car.accelerator.go_forward(40)59 elif(self.car.line_detector.read_digital() == [0,1,0,0,0]):60 self.car.steering.turn_left(80)61 self.car.accelerator.go_forward(40)62 elif(self.car.line_detector.read_digital() == [0,1,1,0,0]):63 self.car.steering.turn_left(85)64 self.car.accelerator.go_forward(40)65 elif(self.car.line_detector.read_digital() == [1,1,1,0,0]):66 self.car.steering.turn_left(87)67 self.car.accelerator.go_forward(40)68 elif(self.car.line_detector.read_digital() == [0,0,1,1,0]):69 self.car.steering.turn_right(95)70 self.car.accelerator.go_forward(40)71 elif(self.car.line_detector.read_digital() == [0,0,1,1,1]):72 self.car.steering.turn_right(100)73 self.car.accelerator.go_forward(40)74 elif(self.car.line_detector.read_digital() == [0,0,0,1,0]):75 self.car.steering.turn_right(110)76 self.car.accelerator.go_forward(40)77 elif(self.car.line_detector.read_digital() == [0,0,0,1,1]):78 self.car.steering.turn_right(115)79 self.car.accelerator.go_forward(40)80 elif(self.car.line_detector.read_digital() == [0,0,0,0,1]):81 self.car.steering.turn_right(120)82 self.car.accelerator.go_forward(40)83 elif(self.car.line_detector.read_digital() == [0,0,0,0,0]):84 self.car.steering.turn(100)85 self.car.accelerator.go_backward(40)86 time.sleep(0.33)87 self.car.accelerator.stop()88 elif(self.car.line_detector.read_digital() == [1,1,1,1,1]):89 if countstop == 4:90 self.car.accelerator.stop()91 break92 else:93 continue94 #self.car.accelerator.stop()95 96if __name__ == "__main__":...
3rd_20181703_sunho.py
Source:3rd_20181703_sunho.py
...17 # Complete the code to perform Third Assignment18 # =======================================================================19 def car_startup(self):20 speed = 3021 self.car.accelerator.go_forward(speed)22 cnt = 023 while True:24 l = self.car.line_detector.read_digital()25 if cnt <= 2:26 if self.car.distance_detector.get_distance() > 15:27 if l == [1, 0, 0, 0, 0]:28 self.car.steering.turn_left(78)29 elif l == [0, 1, 0, 0, 0]:30 self.car.steering.turn_left(83)31 elif l == [0, 0, 0, 1, 0]:32 self.car.steering.turn_right(127)33 elif l == [0, 0, 0, 0, 1]:34 self.car.steering.turn_right(132)35 elif l == [1, 1, 0, 0, 0]:36 self.car.steering.turn_left(63)37 elif l == [0, 1, 1, 0, 0]:38 self.car.steering.turn_left(88)39 elif l == [0, 0, 1, 1, 0]:40 self.car.steering.turn_right(92)41 elif l == [0, 0, 0, 1, 1]:42 self.car.steering.turn_right(97)43 elif l == [0, 0, 1, 0, 0]:44 self.car.accelerator.go_forward(speed)45 elif l == [1, 1, 0, 0, 0]:46 self.car.accelerator.go_forward(speed)47 elif l == [0, 0, 0, 1, 0]:48 self.car.accelerator.go_forward(speed)49 elif l == [0, 1, 0, 0, 0]:50 self.car.accelerator.go_forward(speed)51 elif l == [1, 1, 1, 0, 0]:52 self.car.accelerator.go_forward(speed)53 elif l == [0, 1, 0, 0, 1]:54 self.car.accelerator.go_forward(speed)55 elif l == [1, 1, 1, 0, 1]:56 self.car.accelerator.go_forward(speed)57 elif l == [1, 1, 0, 0, 0]:58 self.car.accelerator.go_forward(speed)59 elif l == [1, 0, 0, 1, 0]:60 self.car.accelerator.go_forward(speed)61 elif l == [1, 1, 1, 0, 0]:62 self.car.accelerator.go_forward(speed)63 elif l == [1, 0, 0, 0, 1]:64 self.car.accelerator.go_forward(speed)65 time.sleep(0.2)66 elif l == [0, 0, 0, 0, 1]:67 self.car.accelerator.go_backward(speed)68 time.sleep(0.2)69 elif l == [0, 0, 0, 0, 0]:70 self.car.steering.turn_right(130)71 self.car.accelerator.go_backward(speed)72 time.sleep(0.6)73 self.car.steering.turn_left(45)74 self.car.accelerator.go_forward(speed)75 time.sleep(0.2)76 continue77 else:78 self.car.accelerator.go_forward(speed)79 time.sleep(0.1)80 elif 0 < self.car.distance_detector.get_distance() <= 15:81 self.car.steering.turn_left(50)82 self.car.accelerator.go_forward(speed+7)83 time.sleep(1)84 self.car.steering.turn_right(120)85 self.car.accelerator.go_forward(speed+7)86 time.sleep(1.8)87 88 else:89 self.car.accelerator.power_down()90if __name__ == "__main__":91 try:92 myCar = myCar("CarName")93 myCar.car_startup()94 except KeyboardInterrupt:95 # when the Ctrl+C key has been pressed,96 # the moving object will be stopped...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!