# Dictionary holding Modbus addresses addresses = { 'Ball X': 12288, 'Ball Y': 12290, 'Joystick X': 12292, '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
'listen': 201, 'sendingchoice': 32218 } 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
floor = box(pos=vector(0, -8.75, 0), size=vector(100, 1, 100), color=color.white) leg_1 = cylinder(pos=vector(20, -Z0 - 0.4, 20), axis=vector(0, 8.75, 0), radius=1, color=color.green) leg_2 = cylinder(pos=vector(-20, -Z0 - 0.4, 20), axis=vector(0, 8.75, 0), radius=1, color=color.green) leg_3 = cylinder(pos=vector(0, -Z0 - 0.4, -20), axis=vector(0, 8.75, 0), radius=1, color=color.green) x_graph = graph(title="Ballmovement in X direction", xtitle='Time[s]', ytitle='X[%]', fast=False, width=800, ymin=0, ymax=100, x=0, y=0) x_position = gcurve(color=color.blue) set_x_position = gcurve(color=color.red) y_graph = graph(title="Ballmovement in Y direction", xtitle='Time[s]', ytitle='Y[%]', 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)
'8': 32208, '9': 32209, '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)
Website: https://github.com/magnusoy/Balancing-Platform """ # Importing packages import cv2 from video_processing import ObjectDetection from modbus_communication import ModbusClient from joystick import Joystick # Main loop if __name__ == '__main__': cap = cv2.VideoCapture(1) cap.set(propId=3, value=640) cap.set(propId=4, value=480) client = ModbusClient() js = Joystick() objectDetection = ObjectDetection(cap, watch=True) # Sends data over Modbus client for as long the connection is established while client.isConnected(): ball_coordinates = objectDetection.getCoordinates() js_coordinates = js.getEvents() client.sendInt(value=ball_coordinates[0], address=12288) client.sendInt(value=ball_coordinates[1], address=12290) client.sendInt(value=js_coordinates[0], address=12292) client.sendInt(value=js_coordinates[1], address=12294) # Break loop with ESC-key key = cv2.waitKey(5) & 0xFF if key == 27:
""" from modbus_communication import ModbusClient from gamechecker import GameChecker import random import cv2 import time array = [1, 2, 3, 4, 5, 6, 7, 8, 9] numbers = ['1', '2', '3', '4', '5', '6', '7', '8', '9'] drawboard = ['2', '5', '6', '10', '11'] # 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:
# Dictionary holding Modbus IP addresses ipaddresses = {'UR3.1': '158.38.140.249', 'PLS': '158.38.140.63'} # Reset the gamestate for each cycle game_state = ["-", "-", "-", "-", "-", "-", "-", "-", "-"] # Create a list of all possible win combinations """ 1 2 3 4 5 6 7 8 """ win_combinations = [[0, 1, 2], [3, 4, 5], [6, 7, 8], [6, 3, 0], [7, 4, 1], [8, 5, 2], [6, 4, 2], [8, 4, 0]] # Main loop if __name__ == '__main__': # Creating the client and camera capture. client = ModbusClient(ip='158.38.140.250') PLS = ModbusClient(ip='158.38.140.63') cap = cv2.VideoCapture(1) # TODO - SCALE DOWN THE CAPTURE game = GameChecker(capture=cap, watch=False) 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"""
'UR3.1': '158.38.140.250' } # Reset the gamestate for each cycle game_state = ["-", "-", "-", "-", "-", "-", "-", "-", "-"] # Create a list of all possible win combinations """ 1 2 3 4 5 6 7 8 """ win_combinations = [[0, 1, 2], [3, 4, 5], [6, 7, 8], [6, 3, 0], [7, 4, 1], [8, 5, 2], [6, 4, 2], [8, 4, 0]] # Main loop if __name__ == '__main__': # Creating the client and camera capture. client = ModbusClient(ip='158.38.140.249') #cap = cv2.VideoCapture(1) # TODO - SCALE DOWN THE CAPTURE #game = GameChecker(capture=cap, watch=True) print("Objects created.") print("Client connecting...") while client.isConnected(): """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")