コード例 #1
0
def main():
    motob = Motob()
    bbcon = Bbcon(motob)
    arbitrator = Arbitrator(bbcon)
    bbcon.set_arbitrator(arbitrator)

    # sensorer og sensob
    ult_sensor = Ultrasonic()
    ref_sensor = ReflectanceSensors(auto_calibrate=False)
    reflectance_sensob = ReflectanceSensob(ref_sensor)
    ultrasonic_sensob = UltrasonicSensob(ult_sensor)
    camera_sensob = CameraSensob(None, color=0)

    #behaviors
    dont_crash = DontCrash(bbcon, ultrasonic_sensob)
    follow_line = FollowLine(bbcon, reflectance_sensob)
    find_object = FindColoredObject(bbcon, camera_sensob)

    bbcon.add_behavior(dont_crash)
    bbcon.add_behavior(follow_line)
    bbcon.add_behavior(find_object)
    try:
        ZumoButton().wait_for_press()
        while not bbcon.object_found:  # Kjører helt til vi finner objektet
            bbcon.run_one_timestep()
    except KeyboardInterrupt:
        motob.motor.stop()
    finally:
        GPIO.cleanup()
コード例 #2
0
ファイル: main.py プロジェクト: andreajl/proglab2
def main():
	print("Press the button")
	Led().light_on()
	ZumoButton().wait_for_press()
	Led().light_off()
	print("Button pressed")

	# Sensors
	camera_sensor = Camera(img_width=200, img_height=25)
	reflectance_sensor = ReflectanceSensors()
	ultrasonic_sensor = Ultrasonic()

	# Other
	led = Led()
	led.light_off()

	# Sensobs
	camera_sensob = CameraSensob(camera_sensor)
	reflectance_sensob = ReflectanceSensob(reflectance_sensor)
	ultrasonic_sensob = Sensob(ultrasonic_sensor)

	# Motobs
	motob = Motob()

	# Controller
	bbcon = Bbcon()

	# Behaviors
	moveForward_behavior = MoveForward(None, 1, bbcon)
	avoidCollision_behavior = AvoidCollision(ultrasonic_sensob, 4, bbcon)
	followColor_behavior = FollowColor(camera_sensob, 6, bbcon)
	pauseAtLines_behavior = PauseAtLines(reflectance_sensob, 8, bbcon)
	stopCloseColor_behavior = StopCloseColor(camera_sensob, 10, bbcon)

	# Add all sensobs to controller
	bbcon.add_sensob(camera_sensob)
	bbcon.add_sensob(reflectance_sensob)
	bbcon.add_sensob(ultrasonic_sensob)

	# Add all Behaviors to controller
	bbcon.add_behavior(avoidCollision_behavior)
	bbcon.add_behavior(moveForward_behavior)
	bbcon.add_behavior(followColor_behavior)
	bbcon.add_behavior(pauseAtLines_behavior)
	bbcon.add_behavior(stopCloseColor_behavior)

	bbcon.activate_all_behaviors()
	# Add all motobs to controller
	bbcon.add_motob(motob)

	print("starting")

	try:
		while bbcon.active:
			bbcon.run_one_timestep()

	except:
		print("Failed")
		motob.stop()
		print(sys.exc_info()[0])
コード例 #3
0
def main():
    """
    Runs the program
    """

    bbcon = Bbcon()
    #drive_forward = DriveForward(bbcon)
    follow_line = FollowLine(bbcon)
    obstruction = Obstruction(bbcon)

    # Legger til behavior
    #bbcon.add_behavior(drive_forward)
    bbcon.add_behavior(follow_line)
    bbcon.add_behavior(obstruction)

    ZumoButton().wait_for_press()

    while True:
        bbcon.run_one_timestep()
コード例 #4
0
def main():

    bbcon = Bbcon()
    lineRider = FollowLine(bbcon)
    obstruction = Obstruction(bbcon)
    photo = Photo(bbcon)

    bbcon.add_behavior(lineRider)
    bbcon.add_behavior(obstruction)
    bbcon.add_behavior(photo)

    ZumoButton().wait_for_press()

    while True:
        bbcon.run_one_timestep()