Skip to content

Commit

Permalink
Imported bsServer in all modified files; Removed shared.get('xyz') fr…
Browse files Browse the repository at this point in the history
…om all modified files; Added getState(xyz) in all modifed files; In short replaced memcache with bsServer in all files.
  • Loading branch information
ultrainstinct30 committed May 5, 2019
1 parent f27c347 commit a389e4b
Show file tree
Hide file tree
Showing 15 changed files with 194 additions and 58 deletions.
19 changes: 13 additions & 6 deletions run_goalie.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,17 @@
from krssg_ssl_msgs.msg import BeliefState
from multiprocessing import Process
from kubs import kubs
form krssg_ssl_msgs.srv import bsServer
from math import atan2,pi
from utils.functions import *

from tactics import Goalie

pub = rospy.Publisher('/grsim_data',gr_Commands,queue_size=1000)

import memcache
shared = memcache.Client(['127.0.0.1:11211'],debug=False)
# _Goalie_.main()
flag = True
kub = kubs.kubs(0,pub)
kub = kubs.kubs(0,None,pub)
def function(id_,state):
# global flag
# print(kub.kubs_id)
Expand All @@ -44,9 +43,17 @@ def function(id_,state):


while True:
state = shared.get('state')
state = None
rospy.wait_for_service('bsServer',)
getState = rospy.ServiceProxy('bsServer',bsServer)
try:
state = getState(state)
except rospy.ServiceException, e:
print e
if state:
kub.update_state(state)
function(KUB_ID,state)
kub.update_state(state.stateB)
function(KUB_ID,state.stateB)
# break
rospy.spin()


4 changes: 4 additions & 0 deletions tactics/CoPass.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
from utils.geometry import *
import memcache
shared = memcache.Client(['127.0.0.1:11211'],debug=False)
from krssg_ssl_msgs.srv import bsServer

rospy.wait_for_service('bsServer',)
getState = rospy.ServiceProxy('bsServer',bsServer)


# import skills.pivot_kick
Expand Down
85 changes: 76 additions & 9 deletions tactics/Goalie.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@
import os
import rospy
shared = memcache.Client(['127.0.0.1:11211'],debug=False)
from krssg_ssl_msgs.srv import bsServer


rospy.wait_for_service('bsServer',)
getState = rospy.ServiceProxy('bsServer',bsServer)

class Goalie(behavior.Behavior):

MIN_VEL = 10.0
Expand Down Expand Up @@ -64,19 +68,40 @@ def add_kub(self,kub):
self.kub = kub

def peace_out(self):
state = shared.get('state')
# state = shared.get('state')
state = None
try:
state = getState(state)
except rospy.ServiceException, e:
print e
if state:
state = state.stateB
if state.ballPos.x > 0:
return True
return False

def _peace_to_clear(self):
state = shared.get('state')
# state = shared.get('state')
state = None
try:
state = getState(state)
except rospy.ServiceException, e:
print e
if state:
state = state.stateB
# print state.ballPos.x , -HALF_FIELD_MAXX + OUR_GOAL_MAXX,state.ballPos.x < -HALF_FIELD_MAXX + OUR_GOAL_MAXX
return state.ballPos.x < -HALF_FIELD_MAXX + 2*OUR_GOAL_MAXX
pass

def _peace_to_protect(self):
state = shared.get('state')
# state = shared.get('state')
state = None
try:
state = getState(state)
except rospy.ServiceException, e:
print e
if state:
state = state.stateB
# return False
return (state.ballVel.x < -self.MIN_VEL or state.ballPos.x<=0) and \
not (state.ballPos.x < -HALF_FIELD_MAXX + 2*OUR_GOAL_MAXX)
Expand All @@ -86,14 +111,28 @@ def _peace_to_protect(self):
# return state.ballVel.x >= 0 and state.ballPos.x>=0

def _protect_to_clear(self):
state = shared.get('state')
# state = shared.get('state')
state = None
try:
state = getState(state)
except rospy.ServiceException, e:
print e
if state:
state = state.stateB
return state.ballPos.x < -HALF_FIELD_MAXX + 2*OUR_GOAL_MAXX and state.ballVel.x < 0 and abs(state.ballPos.y) < OUR_GOAL_MAXY

# note that execute_running() gets called BEFORE any of the execute_SUBSTATE methods gets called

def execute_peace(self):
print("Sab moh maya hain")
state = shared.get('state')
# state = shared.get('state')
state = None
try:
state = getState(state)
except rospy.ServiceException, e:
print e
if state:
state = state.stateB
if abs(state.ballPos.y) < OUR_GOAL_MAXY:
expected_y = state.ballPos.y
else:
Expand Down Expand Up @@ -121,7 +160,14 @@ def execute_peace(self):
def execute_clear(self):
print("Clear kar raha hoon")
target = Vector2D(4000,0)
state = shared.get('state')
# state = shared.get('state')
state = None
try:
state = getState(state)
except rospy.ServiceException, e:
print e
if state:
state = state.stateB
self.gtB = GoToBall.GoToBall(BOT_BALL_THRESH)
self.gtB.add_kub(self.kub)
self.gtB.add_theta(theta=normalize_angle(atan2(target.y - state.ballPos.y,target.x - state.ballPos.x)))
Expand All @@ -136,7 +182,14 @@ def execute_clear(self):

def execute_protect(self):
# pass
state = shared.get('state')
# state = shared.get('state')
state = None
try:
state = getState(state)
except rospy.ServiceException, e:
print e
if state:
state = state.stateB
print("main rakshak hoon")
#expected_y = goalie_expected_y(state, self.kub.kubs_id)
if state.ballVel.x < -10:
Expand Down Expand Up @@ -187,7 +240,14 @@ def on_enter_peace(self):
# self.theta = normalize_angle(angle_diff(self.kub.state.homePos[self.kub.kubs_id], self.kub.state.ballPos))
# _turnAround_.init(self.kub, self.theta )

state = shared.get('state')
# state = shared.get('state')
state = None
try:
state = getState(state)
except rospy.ServiceException, e:
print e
if state:
state = state.stateB
if abs(state.ballPos.y) < OUR_GOAL_MAXY:
expected_y = state.ballPos.y
else:
Expand All @@ -204,7 +264,14 @@ def on_enter_peace(self):
def on_enter_clear(self):
pass
def on_enter_protect(self):
state = shared.get('state')
# state = shared.get('state')
state = None
try:
state = getState(state)
except rospy.ServiceException, e:
print e
if state:
state = state.stateB
#expected_y = goalie_expected_y(state, self.kub.kubs_id)
if abs(state.ballVel.x) < 10:
if abs(state.ballPos.y) < OUR_GOAL_MAXY:
Expand Down
13 changes: 10 additions & 3 deletions test_GoToPoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
from krssg_ssl_msgs.msg import gr_Robot_Command
from krssg_ssl_msgs.msg import point_SF
from utils.config import *
import memcache
shared = memcache.Client(['127.0.0.1:11211'], debug = False)
from krssg_ssl_msgs.srv import bsServer
import sys

BOT_ID = int(sys.argv[1])
Expand All @@ -22,7 +21,15 @@
REPLANNED = 0
homePos = None
awayPos = None
BState = shared.get('state')
state = None
rospy.wait_for_service('bsServer',)
getState = rospy.ServiceProxy('bsServer',bsServer)
try:
state = getState(state)
except rospy.ServiceException, e:
print e
if state:
BState = state.stateB
kub = kubs.kubs(BOT_ID, BState, pub)

def reset():
Expand Down
14 changes: 10 additions & 4 deletions test_Kick.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@
from role import GoToBall, GoToPoint, KickToPoint
from multiprocessing import Process
from kubs import kubs
from krssg_ssl_msgs.srv import bsServer
from math import atan2,pi
from utils.functions import *
pub = rospy.Publisher('/grsim_data',gr_Commands,queue_size=1000)


import memcache
shared = memcache.Client(['127.0.0.1:11211'],debug=False)



Expand Down Expand Up @@ -45,10 +44,17 @@ def function(id_,state):
# rospy.Subscriber('/belief_state', BeliefState, BS_callback, queue_size=1000)

while True:
state=shared.get('state')
state=None
rospy.wait_for_service('bsServer',)
getState = rospy.ServiceProxy('bsServer',bsServer)
try:
state = getState(state)
except rospy.ServiceException, e:
print e
if state:
function(1,state)
function(1,state.stateB)
# break
rospy.spin()



Expand Down
13 changes: 10 additions & 3 deletions test_KickToP.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
from krssg_ssl_msgs.msg import point_SF
from utils.math_functions import *
from utils.config import *
import memcache
shared = memcache.Client(['127.0.0.1:11211'], debug = False)
from krssg_ssl_msgs.srv import bsServer
import sys

BOT_ID = int(sys.argv[1])
Expand All @@ -24,7 +23,15 @@
REPLANNED = 0
homePos = None
awayPos = None
BState = shared.get('state')
state = None
rospy.wait_for_service('bsServer',)
getState = rospy.ServiceProxy('bsServer',bsServer)
try:
state = getState(state)
except rospy.ServiceException, e:
print e
if state:
BState = state.stateB
kub = kubs.kubs(BOT_ID, BState, pub)
st = None
tnow = None
Expand Down
7 changes: 2 additions & 5 deletions test_allign.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
pub = rospy.Publisher('/grsim_data',gr_Commands,queue_size=1000)


import memcache
shared = memcache.Client(['127.0.0.1:11211'],debug=False)



Expand Down Expand Up @@ -50,17 +48,16 @@ def function(id_,state):

while True:
state = None
# state=shared.get('state')
rospy.wait_for_service('bsServer',)
getState = rospy.ServiceProxy('bsServer',bsServer)
try:
state = getState(state)
except rospy.ServiceException, e:
print("chutiya")
#state=shared.get('state')
print("chutiya")
if state:
function(1,state.stateB)
# break
rospy.spin()



Expand Down
3 changes: 0 additions & 3 deletions test_fsm.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
from krssg_ssl_msgs.msg import point_SF
from utils.config import *
from utils.geometry import *
import memcache
shared = memcache.Client(['127.0.0.1:11211'], debug = False)
import sys

BOT_ID = int(sys.argv[1])
Expand All @@ -29,7 +27,6 @@
def BS_callback(BState):
global pub,BOT_ID,state,kub,start_time, curr_pt
global points
# BState = shared.get('state')

if not state:
print("__________________________________")
Expand Down
15 changes: 10 additions & 5 deletions test_point.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@
from role import GoToBall, GoToPoint, pass_receive
from multiprocessing import Process
from kubs import kubs
from krssg_ssl_msgs.srv import bsServer
from math import atan2,pi
from utils.functions import *
pub = rospy.Publisher('/grsim_data',gr_Commands,queue_size=1000)


import memcache
shared = memcache.Client(['127.0.0.1:11211'],debug=False)



Expand Down Expand Up @@ -44,11 +43,17 @@ def function(id_,state):
# rospy.Subscriber('/belief_state', BeliefState, BS_callback, queue_size=1000)

while True:
state=shared.get('state')
state=None
rospy.wait_for_service('bsServer',)
getState = rospy.ServiceProxy('bsServer',bsServer)
try:
state = getState(state)
except rospy.ServiceException, e:
print e
if state:
function(1,state)
function(1,state.stateB)
# break

rospy.spin()



3 changes: 0 additions & 3 deletions test_role.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
pub = rospy.Publisher('/grsim_data',gr_Commands,queue_size=1000)


import memcache
shared = memcache.Client(['127.0.0.1:11211'],debug=True)



Expand Down Expand Up @@ -46,7 +44,6 @@ def function(id_,state):

while True:
state = None
#state=shared.get('state')
rospy.wait_for_service('bsServer',)
getState = rospy.ServiceProxy('bsServer',bsServer)
try:
Expand Down
Loading

0 comments on commit a389e4b

Please sign in to comment.