Skip to content

Commit a6b75d2

Browse files
committed
Comunicação atualizada
1 parent ee2e68e commit a6b75d2

6 files changed

+12
-8
lines changed

scripts/Communication.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ def send_message(self, msg):
1414
self.ser.write(msg.tostring())
1515

1616
def sendCommand(self, robotId, cmdId, value):
17-
print (robotId, cmdId, value)
17+
print ('\0', robotId, cmdId, value)
18+
self.ser.write('\0')
1819
self.ser.write(robotId)
1920
self.ser.write(cmdId)
2021
self.ser.write(value)
@@ -78,6 +79,7 @@ def stop(self, rid):
7879
#self.sendCommand(rid, 'l', chr(128))
7980
#self.sendCommand(rid, 'r', chr(128))
8081
self.sendCommand(rid, 's', chr(128))
82+
self.sendCommand(rid, 's', chr(128))
8183

8284
class Message:
8385
def __init__(self):

scripts/Communication.pyc

32 Bytes
Binary file not shown.

scripts/Goalkeeper.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def controle(self, world):
8686
xfront , yfront = pd.get_front() #unidade das coordenadas eh cm
8787
xback , yback = pd.get_back() #unidade das coordenadas eh cm
8888
pd_x , pd_y = pd.getx() , pd.gety() #unidade das coordenadas eh cm
89-
xb, yb = world.get_ball().getxy()
89+
#xb, yb = world.get_ball().getxy()
9090
xb, yb = self.defende(world) # coordenadas que o goleiro deve ficar
9191

9292
'''if(math.sqrt((xb - pd_x)/100, (yb - pd_y)/100) < 0.05 or start):

scripts/Goalkeeper.pyc

-41 Bytes
Binary file not shown.

scripts/PlayerDefesa.py

+8-6
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,9 @@ def chuta(self, world):
121121
return a,b
122122
123123
return xb, yb
124-
124+
'''
125+
#Testar ||
126+
# \/
125127
if self.gety() > world.FIELD_BOTTOM - distancia_pra_sair_da_parede and (theta_robo > 30 and theta_robo < 150):
126128
b = world.FIELD_BOTTOM - 15
127129
a = self.getx()
@@ -138,7 +140,7 @@ def chuta(self, world):
138140
a = world.FIELD_LEFT + 15
139141
b = self.gety()
140142
return a,b
141-
'''
143+
142144
#Codigo para sair da parede!! : FIM
143145

144146

@@ -192,11 +194,11 @@ def controle(self, world):
192194
xfront , yfront = pd.get_front() #unidade das coordenadas eh cm
193195
xback , yback = pd.get_back() #unidade das coordenadas eh cm
194196
pd_x , pd_y = pd.getx() , pd.gety() #unidade das coordenadas eh cm
195-
#xb, yb = world.get_ball().getxy() #unidade das coordenadas eh cm // usada para ver se o zagueiro vai direto para a bola
196-
xb, yb = self.chuta(world) #Retorna a posicao que o defensor deve ir
197+
xb, yb = world.get_ball().getxy() #unidade das coordenadas eh cm // usada para ver se o zagueiro vai direto para a bola
198+
#xb, yb = self.chuta(world) #Retorna a posicao que o defensor deve ir
197199

198200
theta_jog = self.get_theta()
199-
theta_ball = math.atan2(yb,xb) # unidade rad
201+
theta_ball = math.atan2(yb,xb) # unidade rad
200202
theta_gol = math.atan2(236,515)
201203

202204

@@ -230,7 +232,7 @@ def controle(self, world):
230232
vmax = max(abs(y[0][0]), abs(y[1][0])) # paga a maior velocidade
231233

232234
#como a velocidade foi parametrizada pela maior, K eh a maior velocidade que a roda pode assumir
233-
K = 150
235+
K = 100
234236
vr, vl = y[0][0]*K/vmax, y[1][0]*K/vmax #mudei a constante para 255 antes era 100
235237

236238
return int(vr), int(vl)

scripts/PlayerDefesa.pyc

417 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)