Example #1
0
def move25():

    speed4 = Speed(25)
    speed4.start()
    # time.sleep(2)
    fc.forward(35)
    fc.stop()
    time.sleep(0.5)
    fc.turn_right(50)
    print('distance:', fc.us.get_distance())
Example #2
0
def turnRight():
    speed4 = Speed(25)
    speed4.start()
    # time.sleep(2)
    fc.turn_right(80)
    x = 0
    for i in range(15):
        time.sleep(0.1)
        speed = speed4()
        x += speed * 0.1
        print("%smm/s" % speed)
    print("%smm" % x)
    speed4.deinit()
    fc.stop()
Example #3
0
    def drive(self, speed=__INITIAL_SPEED):
        """ Main entry point of the car, and put it in drive mode
        Keyword arguments:
        speed -- speed of back wheel, range is 0 (stop) - 100 (fastest)
        """
        logging.info('Starting to drive at speed %s...' % speed)
        i = 0
        while self.camera.isOpened() and i < 30:
            _, image_lane = self.camera.read()
            image_objs = image_lane.copy()
            i += 1
            self.video_orig.write(image_lane)

            #      image_objs = self.process_objects_on_road(image_objs)
            #      self.video_objs.write(image_objs)
            #     show_image('Detected Objects', image_objs)

            image_lane = self.follow_lane(image_lane)
            self.video_lane.write(image_lane)
            # show_image('Lane Lines', image_lane)
            cv2.imshow('Lane Lines', image_lane)

            if cv2.waitKey(1) & 0xFF == ord('q'):
                self.cleanup()
                break
        speed4 = Speed(25)
        speed4.start()
        # time.sleep(2)
        fc.forward(20)
        x = 0
        for i in range(25):
            time.sleep(0.1)
            speed = speed4()
            x += speed * 0.1
        #    time.sleep(0.5)
        #print("%smm/s"%speed)
        print("%smm" % x)
        speed4.deinit()
        fc.stop()