Esempio n. 1
0
def main():
    wanderer = Tortoise()

    while True:

        wanderer.moveForwards(500)
        time.sleep(0.5)
        #wanderer.gentleTurn(1000, enums.Direction.forward_left)
        #time.sleep(1)
        #wanderer.moveMotors(1000, enums.Direction.forward_right)
        #time.sleep(1)
        wanderer.moveBackwards(500)
        time.sleep(0.5)
Esempio n. 2
0
from tortoise import Tortoise
from enums import Direction, SensorType, ActuatorType

Name = Tortoise()

while True:

    touchSensor = Name.getSensorData(SensorType.touch, 1)
    print "Front switch is:"
    print touchSensor
    touchSensor2 = Name.getSensorData(SensorType.touch, 3)
    print "Back switch is: "
    print touchSensor2
    if touchSensor == 1:
        print "Switch is on"
        Name.moveBackwards(30)
        Name.setLEDValue(1, 1)  #self.setLEDValue(position, value)
        Name.setLEDValue(2, 0)  #self.setLEDValue(position, value)
        touchSensor2Loop = Name.getSensorData(SensorType.touch, 3)
        print "Back switch as read inside loop: "
        print touchSensor2Loop
        if touchSensor2 == 1:
            print "Back switch has been hit"
            Name.moveForwards(30)
            Name.setLEDValue(2, 0)  #self.setLEDValue(position, value)
            if touchSensor == 0:
                break
# else:
#print "Switch is off"
#Name.moveForwards(30)
#Name.setLEDValue(1, 0) #self.setLEDValue(position, value)
Esempio n. 3
0
def main():
    wanderer = Tortoise()

    while True:

        print "Moving forwards"
        wanderer.moveForwards(500)
        time.sleep(0.5)

        print
        print "\tPress enter to continue"
        print
        raw_input()


        print "Moving backwards"
        wanderer.moveBackwards(500)
        time.sleep(0.5)

        print
        print "\tPress enter to continue"
        print
        raw_input()


        print "Turning on the spot forwards_left"
        wanderer.turnOnTheSpot(500, enums.Direction.forwards_left)
        time.sleep(0.5)

        print
        print "\tPress enter to continue"
        print
        raw_input()

        print "Turning on the spot forwards_right"
        wanderer.turnOnTheSpot(500, enums.Direction.forwards_right)
        time.sleep(0.5)

        print
        print "\tPress enter to continue"
        print
        raw_input()

        print "Turning on the spot backwards_left"
        wanderer.turnOnTheSpot(500, enums.Direction.backwards_left)
        time.sleep(0.5)

        print
        print "\tPress enter to continue"
        print
        raw_input()

        print "Turning on the spot bakwards_right"
        wanderer.turnOnTheSpot(500, enums.Direction.backwards_right)
        time.sleep(0.5)

        print
        print "\tPress enter to continue"
        print
        raw_input()

        print "Turning naturally forwards_left"
        wanderer.turn(200, 500, enums.Direction.forwards_left)
        time.sleep(0.5)

        print
        print "\tPress enter to continue"
        print
        raw_input()

        print "Turning naturally backwards_left"
        wanderer.turn(200, 500, enums.Direction.backwards_left)
        time.sleep(0.5)

        print
        print "\tPress enter to continue"
        print
        raw_input()

        print "Turning naturally forwards_right"
        wanderer.turn(500, 200, enums.Direction.forwards_right)
        time.sleep(0.5)

        print
        print "\tPress enter to continue"
        print
        raw_input()

        print "Turning naturally backwards_right"
        wanderer.turn(500, 200, enums.Direction.backwards_right)
        time.sleep(0.5)

        print
        print "\tPress enter to continue"
        print
        raw_input()

        print "Gyrating clockwise"
        wanderer.shuffleOnTheSpot(500, enums.Direction.clockwise)
        time.sleep(0.5)

        print
        print "\tPress enter to continue"
        print
        raw_input()

        print "Gyrating counter clockwise"
        wanderer.shuffleOnTheSpot(500, enums.Direction.counterClockwise)
        time.sleep(0.5)

        print
        print "\tPress enter to continue"
        print
        raw_input()
from tortoise import Tortoise
from enums import Direction, SensorType, ActuatorType

Name=Tortoise()

lastFrontSwitch = 0
lastBackSwitch = 0

while True:
	currentFrontSwitch = Name.getSensorData(SensorType.touch,3)
	currentBackSwitch = Name.getSensorData(SensorType.touch,1)
    
	forwards = abs(lastBackSwitch - currentBackSwitch)
	backwards = abs(lastFrontSwitch - currentFrontSwitch)

	if forwards==1 and backwards==0:
		lastFrontSwitch=currentFrontSwitch
		print "Moving forwards"
        	Name.moveForwards(5)
		
	if backwards ==1 and forwards==0:
		lastbackSwitch=currentBackSwitch
		print "Moving backwards"
		Name.moveBackwards(5)
	else:
		print "No switches on"

Esempio n. 5
0
        else:
                print "Switch 1 is off"

        if backwardSwitch == 1:
                print "Switch 2 is on"
        else:
                print "Switch 2 is off"

	print " "
        Name.moveForwards(100)
        Name.setLEDValue(1, 1) #self.setLEDValue(position, value)
        Name.setLEDValue(2, 0) #self.setLEDValue(position, value)

#    if (forwardSwitch != backwardSwitch):
    if (forwardSwitch == 1 and backwardSwitch == 0) or (forwardSwitch == 0 and backwardSwitch == 1):
	print "donkey"
	if forwardSwitch == 1:
                print "Switch 1 is on"
        else:
                print "Switch 1 is off"

        if backwardSwitch == 1:
                print "Switch 2 is on"
        else:
                print "Switch 2 is off"

	print " "
        Name.moveBackwards(100)
        Name.setLEDValue(1, 0) #self.setLEDValue(position, value)
        Name.setLEDValue(2, 1) #self.setLEDValue(position, value)
Esempio n. 6
0
from tortoise import Tortoise
from enums import Direction, SensorType, ActuatorType

Elmer=Tortoise()

while True:

    proxSensor = Elmer.getSensorData(SensorType.proximity,1)
    proxSensor2 = Elmer.getSensorData(SensorType.proximity,2)

    if proxSensor == 1 and proxSensor2 == 0:

        print "Obstacle detected in front"
        Elmer.setLEDValue(1, 1) #self.setLEDValue(position, value)
        Elmer.setLEDValue(2, 0) #self.setLEDValue(position, value)
        Elmer.moveBackwards(150)

    elif proxSensor == 1 and proxSensor2 == 1:

        print "Obstacles detected in front and behind!"
        Elmer.setLEDValue(1, 1) #self.setLEDValue(position, value)
        Elmer.setLEDValue(2, 1) #self.setLEDValue(position, value)

    elif proxSensor == 0 and proxSensor2 == 1:

        print "Obstacle detected behind"
        Elmer.setLEDValue(1, 0) #self.setLEDValue(position, value)
        Elmer.setLEDValue(2, 1) #self.setLEDValue(position, value)
        Elmer.moveForwards(150)

    else:
Esempio n. 7
0
from tortoise import Tortoise
from enums import Direction, SensorType, ActuatorType
Walter=Tortoise()

lastMove = "forward"

while True:

    frontSwitch = Walter.getSensorData(SensorType.touch, 1)
    backSwitch = Walter.getSensorData(SensorType.touch, 2)

    if frontSwitch ==1 and backSwitch ==0:
        print "Obstacle in front - moving backwards"    
        Walter.setLEDValue(1, 0) #self.setLEDValue(position, value)
        Walter.setLEDValue(2, 1) #self.setLEDValue(position, value)
        Walter.moveBackwards(100)
        lastMove = "back"
    elif backSwitch ==1 and frontSwitch ==1:
        print "Can't move!"    
    elif frontSwitch ==0 and backSwitch ==1:
        print "Obstacle behind - moving forwards"    
        Walter.setLEDValue(1, 1) #self.setLEDValue(position, value)
        Walter.setLEDValue(2, 0) #self.setLEDValue(position, value)
        Walter.moveForwards(100)
        lastMove = "forward"
    else:
        print "Exploring"
        Walter.setLEDValue(1, 1) #self.setLEDValue(position, value)
        Walter.setLEDValue(2, 1) #self.setLEDValue(position, value)
	if lastMove == "forward":
	        Walter.moveForwards(100)
from tortoise import Tortoise
from enums import Direction, SensorType, ActuatorType

Name=Tortoise()

while True:

    touchSensor = Name.getSensorData(SensorType.touch,1)
    print "Front switch is:" 
    print touchSensor
    touchSensor2 = Name.getSensorData(SensorType.touch,3)
    print "Back switch is: " 
    print touchSensor2
    if touchSensor == 1:
        print "Switch is on"
        Name.moveBackwards(30)
        Name.setLEDValue(1, 1) #self.setLEDValue(position, value)
        Name.setLEDValue(2, 0) #self.setLEDValue(position, value)
	touchSensor2Loop = Name.getSensorData(SensorType.touch,3)
	print "Back switch as read inside loop: " 
        print touchSensor2Loop
	if touchSensor2 == 1:
		print "Back switch has been hit"
		Name.moveForwards(30)
		Name.setLEDValue(2, 0) #self.setLEDValue(position, value)
		if touchSensor == 0:
			break
   # else:
        #print "Switch is off"
        #Name.moveForwards(30)
        #Name.setLEDValue(1, 0) #self.setLEDValue(position, value)
Esempio n. 9
0
def main():
    wanderer = Tortoise()

    while True:

        print "Moving forwards"
        wanderer.moveForwards(500)
        time.sleep(0.5)

        print
        print "\tPress enter to continue"
        print
        raw_input()

        print "Moving backwards"
        wanderer.moveBackwards(500)
        time.sleep(0.5)

        print
        print "\tPress enter to continue"
        print
        raw_input()

        print "Turning on the spot forwards_left"
        wanderer.turnOnTheSpot(500, enums.Direction.forwards_left)
        time.sleep(0.5)

        print
        print "\tPress enter to continue"
        print
        raw_input()

        print "Turning on the spot forwards_right"
        wanderer.turnOnTheSpot(500, enums.Direction.forwards_right)
        time.sleep(0.5)

        print
        print "\tPress enter to continue"
        print
        raw_input()

        print "Turning on the spot backwards_left"
        wanderer.turnOnTheSpot(500, enums.Direction.backwards_left)
        time.sleep(0.5)

        print
        print "\tPress enter to continue"
        print
        raw_input()

        print "Turning on the spot bakwards_right"
        wanderer.turnOnTheSpot(500, enums.Direction.backwards_right)
        time.sleep(0.5)

        print
        print "\tPress enter to continue"
        print
        raw_input()

        print "Turning naturally forwards_left"
        wanderer.turn(200, 500, enums.Direction.forwards_left)
        time.sleep(0.5)

        print
        print "\tPress enter to continue"
        print
        raw_input()

        print "Turning naturally backwards_left"
        wanderer.turn(200, 500, enums.Direction.backwards_left)
        time.sleep(0.5)

        print
        print "\tPress enter to continue"
        print
        raw_input()

        print "Turning naturally forwards_right"
        wanderer.turn(500, 200, enums.Direction.forwards_right)
        time.sleep(0.5)

        print
        print "\tPress enter to continue"
        print
        raw_input()

        print "Turning naturally backwards_right"
        wanderer.turn(500, 200, enums.Direction.backwards_right)
        time.sleep(0.5)

        print
        print "\tPress enter to continue"
        print
        raw_input()

        print "Gyrating clockwise"
        wanderer.shuffleOnTheSpot(500, enums.Direction.clockwise)
        time.sleep(0.5)

        print
        print "\tPress enter to continue"
        print
        raw_input()

        print "Gyrating counter clockwise"
        wanderer.shuffleOnTheSpot(500, enums.Direction.counterClockwise)
        time.sleep(0.5)

        print
        print "\tPress enter to continue"
        print
        raw_input()
Esempio n. 10
0
    backSwitch = Walter.getSensorData(SensorType.touch, 2)

    if frontSwitch ==1 and backSwitch ==0:

        print "Obstacle in front - moving backwards"    
        Walter.setLEDValue(1, 0) #self.setLEDValue(position, value)
        Walter.setLEDValue(2, 1) #self.setLEDValue(position, value)
        lastMove = "back"

    elif backSwitch ==1 and frontSwitch ==1:

        print "Can't move!"    

    elif frontSwitch ==0 and backSwitch ==1:

        print "Obstacle behind - moving forwards"    
        Walter.setLEDValue(1, 1) #self.setLEDValue(position, value)
        Walter.setLEDValue(2, 0) #self.setLEDValue(position, value)
        lastMove = "forward"

    else:
        print "Exploring"
        Walter.setLEDValue(1, 1) #self.setLEDValue(position, value)
        Walter.setLEDValue(2, 1) #self.setLEDValue(position, value)


    if lastMove == "forward":
            Walter.moveForwards(100)
    else:
        Walter.moveBackwards(100)
Esempio n. 11
0
from tortoise import Tortoise
from enums import Direction, SensorType, ActuatorType

Elmer = Tortoise()

while True:

    proxSensor = Elmer.getSensorData(SensorType.proximity, 1)
    proxSensor2 = Elmer.getSensorData(SensorType.proximity, 2)

    if proxSensor == 1 and proxSensor2 == 0:

        print "Obstacle detected in front"
        Elmer.setLEDValue(1, 1)  #self.setLEDValue(position, value)
        Elmer.setLEDValue(2, 0)  #self.setLEDValue(position, value)
        Elmer.moveBackwards(150)

    elif proxSensor == 1 and proxSensor2 == 1:

        print "Obstacles detected in front and behind!"
        Elmer.setLEDValue(1, 1)  #self.setLEDValue(position, value)
        Elmer.setLEDValue(2, 1)  #self.setLEDValue(position, value)

    elif proxSensor == 0 and proxSensor2 == 1:

        print "Obstacle detected behind"
        Elmer.setLEDValue(1, 0)  #self.setLEDValue(position, value)
        Elmer.setLEDValue(2, 1)  #self.setLEDValue(position, value)
        Elmer.moveForwards(150)

    else:
Esempio n. 12
0
from tortoise import Tortoise
from enums import Direction, SensorType, ActuatorType

Name = Tortoise()

lastFrontSwitch = 0
lastBackSwitch = 0

while True:
    currentFrontSwitch = Name.getSensorData(SensorType.touch, 3)
    currentBackSwitch = Name.getSensorData(SensorType.touch, 1)

    forwards = abs(lastBackSwitch - currentBackSwitch)
    backwards = abs(lastFrontSwitch - currentFrontSwitch)

    if forwards == 1 and backwards == 0:
        lastFrontSwitch = currentFrontSwitch
        print "Moving forwards"
        Name.moveForwards(5)

    if backwards == 1 and forwards == 0:
        lastbackSwitch = currentBackSwitch
        print "Moving backwards"
        Name.moveBackwards(5)
    else:
        print "No switches on"