Пример #1
0
    'Joystick Y': 12294
}

# Main loop
if __name__ == '__main__':
    cap = cv2.VideoCapture(1)
    cap.set(propId=3, value=640)
    cap.set(propId=4, value=480)

    # Creating objects
    client = ModbusClient()
    js = Joystick()
    ballTracking = BallTracking(capture=cap, watch=True, color='dark-green')

    # Sends data over Modbus client for as long the connection is established
    while client.isConnected():
        ball_coordinates = ballTracking.getCoordinates()
        js_coordinates = js.getEvents()
        client.sendInt(value=ball_coordinates[0], address=addresses['Ball X'])
        client.sendInt(value=ball_coordinates[1], address=addresses['Ball Y'])
        client.sendInt(value=js_coordinates[0],
                       address=addresses['Joystick X'])
        client.sendInt(value=js_coordinates[1],
                       address=addresses['Joystick Y'])

        # Break loop with ESC-key
        key = cv2.waitKey(5) & 0xFF
        if key == 27:
            ballTracking.stop()
            break
Пример #2
0
    'alex': 32217,
    'listen': 201,
    'sendingchoice': 32218,
    'alf0': 0,
    'alf1': 1,
    'alf2': 2
}

state = [1, 2, 1, 2, 1, 2, 1, 2, 1]

if __name__ == '__main__':
    while 1:
        # SPAM ALEXANDER
        alex = ModbusClient(ip='158.38.140.63')

        while alex.isConnected():
            try:
                test = input("type\n")
                if str(test) == "1":
                    print("We in boiss")
                    # notify that we send shit
                    alex.sendInt(address=addresses['alex'], value=1)
                    loop = 1
                    for i in range(loop):
                        print("looped " + str(i) + " times...")
                        alex.sendInt(address=addresses['alex'], value=1)
                        read0 = alex.readInt(address=addresses['alf0'], size=1)
                        read1 = alex.readInt(address=addresses['alf1'], size=1)
                        read2 = alex.readInt(address=addresses['alf2'], size=1)
                        print("reading from: " + str(addresses['alf0']) +
                              ", " + str(read0))
Пример #3
0
}
numbers = ['1', '2', '3', '4', '5', '6', '7', '8', '9']
#numbers = [0]

drawboard = ['2', '5', '6', '10', '11']

# Main loop
if __name__ == '__main__':
    # Creating objects
    cap = cv2.VideoCapture(1)
    game = GameChecker(capture=cap, watch=False)
    while 1:

        PLS = ModbusClient(ip='158.38.140.63')

        while PLS.isConnected():
            try:
                # Listens for when we want to start the program
                start = PLS.readInt(address=207, size=1)
                start = PLS.readInt(address=207, size=1)
                print(str(start))

                while str(start) == "[1]":
                    # Give system time to respond
                    time.sleep(0)

                    clean = game.cleanBoard()

                    # If the board is not clean, send request to wash
                    if not clean:
                        print("Wash please.")
Пример #4
0
# Main loop
if __name__ == '__main__':
    UR31 = ModbusClient(ip='158.38.140.249')
    UR32 = ModbusClient(ip='158.38.140.250')
    cap = cv2.VideoCapture(1)

    game = GameChecker(capture=cap, watch=True)

    players = [UR31, UR32]
    playerstest = ["player1", "player2"]

    startplayer = random.randint(0, 1)  # Decides who starts
    turn = startplayer

    while UR31.isConnected() and UR32.isConnected():
        clean = game.cleanBoard()

        if not clean:
            UR32.sendInt(address=143, value=0)
            time.sleep(1)
            UR32.sendInt(address=143, value=69)
            time.sleep(1)
            UR32.wait_feedback()
        else:
            print("Machine idle and board clean...")

        # making sure our robot is 'reset'
        UR31.sendInt(address=141, value=0)
        time.sleep(1)
        print("Drawing board.")