Example #1
0
def main():
    print('STARTING CAR')

    picar.setup()
    db_file = "/home/pi/SunFounder_PiCar-V/remote_control/remote_control/driver/config"
    fw = front_wheels.Front_Wheels(debug=True, db=db_file)
    bw = back_wheels.Back_Wheels(debug=True, db=db_file)
    cam = camera.Camera(debug=True, db=db_file)
    cam.ready()
    bw.ready()
    fw.ready()
    cv2Cam = cv2.VideoCapture(0)

    # bw.speed = 20
    turn_cam_down(cam)
    current_state = 'straight'

    while True:
        print('TAKING PIC')
        np_img = take_picture(cv2Cam)

        print('CLASSIFYING PIC')
        prediction = classify(np_img)
        print('CLASSIFICATION: ' + prediction)

        if prediction == 'straight':
            if current_state == 'veer_left':
                turn_straight_from_left(fw)  # Overcorrect due to faulty car
            else:
                turn_straight(fw)
        elif prediction == 'right':
            turn_right(fw)
        elif prediction == 'veer_right':
            veer_right(fw)
        elif prediction == 'veer_left':
            veer_left(fw)
        current_state = prediction

        print('SLEEPING')
        sleep_car(0.05)
        print('')
        print('')
Example #2
0
* Website     : www.sunfounder.com
* Update      : Cavon    2016-09-13    New release
**********************************************************************
'''

from django.shortcuts import render_to_response
from driver import camera, stream
from picar import back_wheels, front_wheels
from django.http import HttpResponse
import picar

picar.setup()
db_file = "/home/pi/SunFounder_PiCar-V/remote_control/remote_control/driver/config"
fw = front_wheels.Front_Wheels(debug=False, db=db_file)
bw = back_wheels.Back_Wheels(debug=False, db=db_file)
cam = camera.Camera(debug=False, db=db_file)
cam.ready()
bw.ready()
fw.ready()
 
SPEED = 60
bw_status = 0

print stream.start()

def home(request):
	return render_to_response("base.html")

def run(request):
	global SPEED, bw_status
	debug = ''
Example #3
0
 def __init__(self, debug=False):
     self.cam = camera.Camera(debug=debug, db=db_file)
     self.cam.ready()
     self.horizAngle = 0
     self.vertAngle = 0
     self.dirpath = './frameCaptured'