'''

	Modified: 21.06.2015 by Mehmet Efe Tiryaki (m.efetiryaki@gmail.com)
	Created : 19.06.2015 by Cemre Goc (cemregoc@aol.com)


'''

#!/usr/bin/env python

from without.srv import *
from without.msg import *
import rospy
import random
import numpy
import sys
import cv2
import time



class playerClient():
	"""
	This code initializes player nodes, let them chose their robot and
	collect their sensor data from the Hub node.
	"""

	def __init__(self):
		rospy.wait_for_service('PlayerControlService')
		playerControlService = rospy.ServiceProxy('PlayerControlService', PlayerControl)

		self.CMD = 'Init'
		self.myPlayer = Player()
		self.myPlayer.ID = 'ceroloy'
		self.myPlayer.Sticker = 3
		self.myVelocity = Vector4()
		HubRequest = PlayerControlRequest(self.CMD,self.myPlayer)
		HubResponse = playerControlService(HubRequest)
		#print HubResponse.Status
		while HubResponse.Status ==10:
			self.CMD = 'Start?'
			HubRequest = PlayerControlRequest(self.CMD,self.myPlayer)
			HubResponse =playerControlService(HubRequest)
			time.sleep(0.5)
		while HubResponse.Status == 0:
			self.CMD = 'Sensor'
			HubRequest = PlayerControlRequest(self.CMD,self.myPlayer)
			HubResponse = playerControlService(HubRequest)
			distance=HubResponse.yourPlayer.sensors[0].data[0]
			left=HubResponse.yourPlayer.sensors[1].data[0]
			if distance<150:
				if left>150:
					self.myVelocity.x=0
					self.myVelocity.y=0
					self.myVelocity.z=1
				else:
					self.myVelocity.x=0
					self.myVelocity.y=0
					self.myVelocity.z=-1
			else :
				self.myVelocity.x=1
				self.myVelocity.y=0
				self.myVelocity.z=0	
	
			time.sleep(0.05)			
			self.CMD = 'Control'
			self.myPlayer.controlCommand = self.myVelocity
			#print(self.myPlayer.controlCommand)
			HubRequest = PlayerControlRequest(self.CMD,self.myPlayer)
			HubResponse = playerControlService(HubRequest)



if __name__ == '__main__':
	user1 = playerClient()


feba3bf4f71ff9dc50acc3eec441ffbe60dd8be1
<mask token>


class playerClient:
    <mask token>

    def __init__(self):
        rospy.wait_for_service('PlayerControlService')
        playerControlService = rospy.ServiceProxy('PlayerControlService',
            PlayerControl)
        self.CMD = 'Init'
        self.myPlayer = Player()
        self.myPlayer.ID = 'ceroloy'
        self.myPlayer.Sticker = 3
        self.myVelocity = Vector4()
        HubRequest = PlayerControlRequest(self.CMD, self.myPlayer)
        HubResponse = playerControlService(HubRequest)
        while HubResponse.Status == 10:
            self.CMD = 'Start?'
            HubRequest = PlayerControlRequest(self.CMD, self.myPlayer)
            HubResponse = playerControlService(HubRequest)
            time.sleep(0.5)
        while HubResponse.Status == 0:
            self.CMD = 'Sensor'
            HubRequest = PlayerControlRequest(self.CMD, self.myPlayer)
            HubResponse = playerControlService(HubRequest)
            distance = HubResponse.yourPlayer.sensors[0].data[0]
            left = HubResponse.yourPlayer.sensors[1].data[0]
            if distance < 150:
                if left > 150:
                    self.myVelocity.x = 0
                    self.myVelocity.y = 0
                    self.myVelocity.z = 1
                else:
                    self.myVelocity.x = 0
                    self.myVelocity.y = 0
                    self.myVelocity.z = -1
            else:
                self.myVelocity.x = 1
                self.myVelocity.y = 0
                self.myVelocity.z = 0
            time.sleep(0.05)
            self.CMD = 'Control'
            self.myPlayer.controlCommand = self.myVelocity
            HubRequest = PlayerControlRequest(self.CMD, self.myPlayer)
            HubResponse = playerControlService(HubRequest)


<mask token>

<mask token>


class playerClient:
    """
	This code initializes player nodes, let them chose their robot and
	collect their sensor data from the Hub node.
	"""

    def __init__(self):
        rospy.wait_for_service('PlayerControlService')
        playerControlService = rospy.ServiceProxy('PlayerControlService',
            PlayerControl)
        self.CMD = 'Init'
        self.myPlayer = Player()
        self.myPlayer.ID = 'ceroloy'
        self.myPlayer.Sticker = 3
        self.myVelocity = Vector4()
        HubRequest = PlayerControlRequest(self.CMD, self.myPlayer)
        HubResponse = playerControlService(HubRequest)
        while HubResponse.Status == 10:
            self.CMD = 'Start?'
            HubRequest = PlayerControlRequest(self.CMD, self.myPlayer)
            HubResponse = playerControlService(HubRequest)
            time.sleep(0.5)
        while HubResponse.Status == 0:
            self.CMD = 'Sensor'
            HubRequest = PlayerControlRequest(self.CMD, self.myPlayer)
            HubResponse = playerControlService(HubRequest)
            distance = HubResponse.yourPlayer.sensors[0].data[0]
            left = HubResponse.yourPlayer.sensors[1].data[0]
            if distance < 150:
                if left > 150:
                    self.myVelocity.x = 0
                    self.myVelocity.y = 0
                    self.myVelocity.z = 1
                else:
                    self.myVelocity.x = 0
                    self.myVelocity.y = 0
                    self.myVelocity.z = -1
            else:
                self.myVelocity.x = 1
                self.myVelocity.y = 0
                self.myVelocity.z = 0
            time.sleep(0.05)
            self.CMD = 'Control'
            self.myPlayer.controlCommand = self.myVelocity
            HubRequest = PlayerControlRequest(self.CMD, self.myPlayer)
            HubResponse = playerControlService(HubRequest)


<mask token>

<mask token>


class playerClient:
    """
	This code initializes player nodes, let them chose their robot and
	collect their sensor data from the Hub node.
	"""

    def __init__(self):
        rospy.wait_for_service('PlayerControlService')
        playerControlService = rospy.ServiceProxy('PlayerControlService',
            PlayerControl)
        self.CMD = 'Init'
        self.myPlayer = Player()
        self.myPlayer.ID = 'ceroloy'
        self.myPlayer.Sticker = 3
        self.myVelocity = Vector4()
        HubRequest = PlayerControlRequest(self.CMD, self.myPlayer)
        HubResponse = playerControlService(HubRequest)
        while HubResponse.Status == 10:
            self.CMD = 'Start?'
            HubRequest = PlayerControlRequest(self.CMD, self.myPlayer)
            HubResponse = playerControlService(HubRequest)
            time.sleep(0.5)
        while HubResponse.Status == 0:
            self.CMD = 'Sensor'
            HubRequest = PlayerControlRequest(self.CMD, self.myPlayer)
            HubResponse = playerControlService(HubRequest)
            distance = HubResponse.yourPlayer.sensors[0].data[0]
            left = HubResponse.yourPlayer.sensors[1].data[0]
            if distance < 150:
                if left > 150:
                    self.myVelocity.x = 0
                    self.myVelocity.y = 0
                    self.myVelocity.z = 1
                else:
                    self.myVelocity.x = 0
                    self.myVelocity.y = 0
                    self.myVelocity.z = -1
            else:
                self.myVelocity.x = 1
                self.myVelocity.y = 0
                self.myVelocity.z = 0
            time.sleep(0.05)
            self.CMD = 'Control'
            self.myPlayer.controlCommand = self.myVelocity
            HubRequest = PlayerControlRequest(self.CMD, self.myPlayer)
            HubResponse = playerControlService(HubRequest)


if __name__ == '__main__':
    user1 = playerClient()

<mask token>
from without.srv import *
from without.msg import *
import rospy
import random
import numpy
import sys
import cv2
import time


class playerClient:
    """
	This code initializes player nodes, let them chose their robot and
	collect their sensor data from the Hub node.
	"""

    def __init__(self):
        rospy.wait_for_service('PlayerControlService')
        playerControlService = rospy.ServiceProxy('PlayerControlService',
            PlayerControl)
        self.CMD = 'Init'
        self.myPlayer = Player()
        self.myPlayer.ID = 'ceroloy'
        self.myPlayer.Sticker = 3
        self.myVelocity = Vector4()
        HubRequest = PlayerControlRequest(self.CMD, self.myPlayer)
        HubResponse = playerControlService(HubRequest)
        while HubResponse.Status == 10:
            self.CMD = 'Start?'
            HubRequest = PlayerControlRequest(self.CMD, self.myPlayer)
            HubResponse = playerControlService(HubRequest)
            time.sleep(0.5)
        while HubResponse.Status == 0:
            self.CMD = 'Sensor'
            HubRequest = PlayerControlRequest(self.CMD, self.myPlayer)
            HubResponse = playerControlService(HubRequest)
            distance = HubResponse.yourPlayer.sensors[0].data[0]
            left = HubResponse.yourPlayer.sensors[1].data[0]
            if distance < 150:
                if left > 150:
                    self.myVelocity.x = 0
                    self.myVelocity.y = 0
                    self.myVelocity.z = 1
                else:
                    self.myVelocity.x = 0
                    self.myVelocity.y = 0
                    self.myVelocity.z = -1
            else:
                self.myVelocity.x = 1
                self.myVelocity.y = 0
                self.myVelocity.z = 0
            time.sleep(0.05)
            self.CMD = 'Control'
            self.myPlayer.controlCommand = self.myVelocity
            HubRequest = PlayerControlRequest(self.CMD, self.myPlayer)
            HubResponse = playerControlService(HubRequest)


if __name__ == '__main__':
    user1 = playerClient()

'''

	Modified: 21.06.2015 by Mehmet Efe Tiryaki (m.efetiryaki@gmail.com)
	Created : 19.06.2015 by Cemre Goc (cemregoc@aol.com)


'''

#!/usr/bin/env python

from without.srv import *
from without.msg import *
import rospy
import random
import numpy
import sys
import cv2
import time



class playerClient():
	"""
	This code initializes player nodes, let them chose their robot and
	collect their sensor data from the Hub node.
	"""

	def __init__(self):
		rospy.wait_for_service('PlayerControlService')
		playerControlService = rospy.ServiceProxy('PlayerControlService', PlayerControl)

		self.CMD = 'Init'
		self.myPlayer = Player()
		self.myPlayer.ID = 'ceroloy'
		self.myPlayer.Sticker = 3
		self.myVelocity = Vector4()
		HubRequest = PlayerControlRequest(self.CMD,self.myPlayer)
		HubResponse = playerControlService(HubRequest)
		#print HubResponse.Status
		while HubResponse.Status ==10:
			self.CMD = 'Start?'
			HubRequest = PlayerControlRequest(self.CMD,self.myPlayer)
			HubResponse =playerControlService(HubRequest)
			time.sleep(0.5)
		while HubResponse.Status == 0:
			self.CMD = 'Sensor'
			HubRequest = PlayerControlRequest(self.CMD,self.myPlayer)
			HubResponse = playerControlService(HubRequest)
			distance=HubResponse.yourPlayer.sensors[0].data[0]
			left=HubResponse.yourPlayer.sensors[1].data[0]
			if distance<150:
				if left>150:
					self.myVelocity.x=0
					self.myVelocity.y=0
					self.myVelocity.z=1
				else:
					self.myVelocity.x=0
					self.myVelocity.y=0
					self.myVelocity.z=-1
			else :
				self.myVelocity.x=1
				self.myVelocity.y=0
				self.myVelocity.z=0	
	
			time.sleep(0.05)			
			self.CMD = 'Control'
			self.myPlayer.controlCommand = self.myVelocity
			#print(self.myPlayer.controlCommand)
			HubRequest = PlayerControlRequest(self.CMD,self.myPlayer)
			HubResponse = playerControlService(HubRequest)



if __name__ == '__main__':
	user1 = playerClient()

