Пример #1
0
                fast=False, width=800, ymin=0, ymax=100, x=300, y=300)
y_position = gcurve(color=color.blue)
set_y_position = gcurve(color=color.red)
platform.pos = vector(0, 0, 0)

# Create modbus client
client = ModbusClient()

# Running visualization
while client.isConnected():
    # Refresh rate
    rate(10)
    t += 0.1

    # Read modbus addresses for data
    response = client.readInt(address=12288, size=20)
    x_pos = response[addresses['Ball X']]
    y_pos = response[addresses['Ball Y']]
    set_x_pos = response[addresses['Setpoint X']]
    set_y_pos = response[addresses['Setpoint Y']]
    roll = client.readFloat(address=addresses['Pitch'], size=2)
    pitch = client.readFloat(address=addresses['Roll'], size=2)

    # Convert to radians
    pitch = translate(pitch, 0, 100, -8, 8)
    roll = translate(roll, 0, 100, -8, 8)
    pitch = pitch * pi / 180
    roll = roll * pi / 180

    # Graphing values
    x_position.plot((t, constrain(x_pos, 0, 100)))
Пример #2
0
    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))
                        print("reading from: " + str(addresses['alf1']) +
                              ", " + str(read1))
                        print("reading from: " + str(addresses['alf2']) +
                              ", " + str(read2))

                        alex.sendInt(address=addresses['1'], value=69)
                        alex.sendInt(address=addresses['2'], value=2)
                        alex.sendInt(address=addresses['3'], value=2)
                        alex.sendInt(address=addresses['4'], value=state[3])
                        alex.sendInt(address=addresses['5'], value=1)
                        alex.sendInt(address=addresses['6'], value=state[5])
Пример #3
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.")
                        time.sleep(0)
                        PLS.sendInt(address=32221, value=1)
    print("Objects created.")
    print("Client connecting...")
    while client.isConnected():
        try:
            """This is used for testing when I cannot use our
            robot for testing when I am away from the LAB"""
            string = str(input("enter below\n"))
            print(string)
            """Just a test lmao"""
            if string == "lmao":
                print("epiclmao")

            if string == "test123":
                while 1:
                    test = client.readInt(address=31000, size=1)
                    print(test)
                    if str(test) == "[1]":
                        print("HEI KEVIN")
                        break

            if string == "spam":
                while 1:
                    client.sendInt(address=32000, value=1)

            if string == "win":
                win = game.getWinCombo()
                print(win)
            """WORKS"""
            if string == "pls":
                while 1: