Example #1
0
def main():
	control = RoboControl(DEBUG=True)
	network = RoboNetwork('192.168.1.2', 29281, 20, 5, DEBUG=True)
	
	controller_connected = False
	robot_connected = False
	
	controller_connected = control.connect()
	if controller_connected:
		print("Controller connected!")
		print("Starting controller program")
		control.start()
	else:
		print("No controller connected")
	
	#while not robot_connected:
	if not robot_connected:
		robot_connected = network.connect()
		if robot_connected:
			print("Robot connected")
		else:
			print("No robot detected, timeout")
		
	while (not control.exit):
		#if network.connected and len(control.commands) > 0:
		if len(control.commands) > 0:
			command = control.commands.popleft()
			print(command)
			if network.connected:
				network.conn.send(command[0])
				network.conn.send(command[1])
	network.exit = True
Example #2
0
	def __init__(self):
		super(RobotApp, self).__init__()
		
		# Setup ui from precompiled file
		self.setupUi(self)
		
		# Connect signals to buttons
		self.connect_buttons()
		
		# Initiate controlling applications
		self.control = RoboControl(DEBUG=True)
		#self.network = RoboNetwork('192.168.1.2', 29281, 16, '192.168.1.3', 29282, 15, DEBUG=True)
		
		# Run controlling applications
		self.control.start()
		#self.network.start()
		
		# UDP Variables
		self.UDP_TARGET_IP = '10.0.1.3'
		self.UDP_TARGET_PORT = 5500
		
		# Create UDP socket
		self.udp_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) # UDP


		# Set state flags
		self.controller_connected = False
		self.network_connected = True
		
		# Overall state
		self.state = States.DISCONNECTED
		self.controllerConnect.setEnabled(False)
		self.controllerDisconnect.setEnabled(False)
		self.recordPath.setEnabled(False)
		
		# Queue data
		self.filename = None
		self.queues_data = []
		self.queue = []
		
		# Start main thread
		self.mainThread = MainThread(self)
		self.mainThread.start()