Example #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()
Example #2
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()
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()
Example #4
0
from bbcon import Bbcon
from behaviours.avoid_line_behaviour import AvoidLineBehaviour
from behaviours.follow_red_behaviour import FollowRedBehaviour
from sensobs.line_sensob import LineSensob
from sensobs.red_detector import RedDetector
from sensors import *
from robot.motors import Motors
from motob import WheelMotob
from behaviours.avoid_collision_behaviour import AvoidCollisionBehaviour
from sensobs.ultra_sensob import UltraSensob
from sensors.ultrasonic import Ultrasonic

if __name__ == '__main__':
    bb = Bbcon()

    # Line detection
    ir_sensor = ir.ReflectanceSensors(auto_calibrate=True)
    line_sensob = LineSensob(ir_sensor)
    avl = AvoidLineBehaviour(bb, line_sensob)

    bb.add_sensor(ir_sensor)
    bb.add_sensory_object(line_sensob)
    bb.add_behaviour(avl)
    bb.activate_behaviour(avl)


    # Motor

    motors = Motors()
    wheel_motob = WheelMotob(motors, bb.time_step)
    bb.motobs.append(wheel_motob)
Example #5
0
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])