def set_arguments(self, what_to_call, frame=common_pb2.Frame(), foulinfo=messages_pb2.FoulInfo()): self.frame = frame self.foulinfo = foulinfo self.what_to_call = what_to_call self.start()
def call_SetLaterRobots(self, frame=common_pb2.Frame(), foulInfo=messages_pb2.FoulInfo()): environment = self.create_environment(frame, foulInfo) try: response = self.stub.SetLaterRobots(environment) except: response = messages_pb2.Robots() return response
def call_RunStrategy(self, frame=common_pb2.Frame(), foulInfo=messages_pb2.FoulInfo()): environment = self.create_environment(frame, foulInfo) try: response = self.stub.RunStrategy(environment) except: response = messages_pb2.Command() return response
def __init__(self, ip, port, isYellow, firasimclient): super().__init__() self.teamClient = TeamClient(ip, port) self.converter = Converter() self.firasimclient = firasimclient self.isYellow = isYellow self.teamName = '' self.frame = common_pb2.Frame() self.foulinfo = messages_pb2.FoulInfo() self.what_to_call = WhatToCallEnum.Nothing
def generate_foulinfo(self): foulinfo_yellow = messages_pb2.FoulInfo() foulinfo_yellow.type = self.gamestate.state foulinfo_yellow.phase = self.gamestate.phase if foulinfo_yellow.type == messages_pb2.FoulInfo.FoulType.FreeBallLeftTop: foulinfo_yellow.type = messages_pb2.FoulInfo.FoulType.FreeBallRightTop elif foulinfo_yellow.type == messages_pb2.FoulInfo.FoulType.FreeBallRightTop: foulinfo_yellow.type = messages_pb2.FoulInfo.FoulType.FreeBallLeftTop elif foulinfo_yellow.type == messages_pb2.FoulInfo.FoulType.FreeBallLeftBot: foulinfo_yellow.type = messages_pb2.FoulInfo.FoulType.FreeBallRightBot elif foulinfo_yellow.type == messages_pb2.FoulInfo.FoulType.FreeBallRightBot: foulinfo_yellow.type = messages_pb2.FoulInfo.FoulType.FreeBallLeftBot foulinfo_blue = messages_pb2.FoulInfo() foulinfo_blue.CopyFrom(foulinfo_yellow) if self.gamestate.actor == ActorEnum.Yellow: foulinfo_blue.actor = messages_pb2.Side.Opponent foulinfo_yellow.actor = messages_pb2.Side.Self else: foulinfo_yellow.actor = messages_pb2.Side.Opponent foulinfo_blue.actor = messages_pb2.Side.Self return foulinfo_yellow, foulinfo_blue
except: response = common_pb2.Ball() return response def call_SetFormerRobots(self, frame=common_pb2.Frame(), foulInfo=messages_pb2.FoulInfo()): environment = self.create_environment(frame, foulInfo) try: response = self.stub.SetFormerRobots(environment) except: response = messages_pb2.Robots() return response def call_SetLaterRobots(self, frame=common_pb2.Frame(), foulInfo=messages_pb2.FoulInfo()): environment = self.create_environment(frame, foulInfo) try: response = self.stub.SetLaterRobots(environment) except: response = messages_pb2.Robots() return response if __name__ == "__main__": teamClient = TeamClient('127.0.0.1', 50052) frame = common_pb2.Frame() foulInfo = messages_pb2.FoulInfo() while True: teamClient.call_RunStrategy(frame, foulInfo)