def generate_frame(self, environment): frame_blue = common_pb2.Frame() frame_yellow = common_pb2.Frame() frame_blue.CopyFrom(environment.frame) frame_yellow.CopyFrom(environment.frame) frame_yellow.ball.x *= -1 for robot in frame_yellow.robots_yellow: robot.x *= -1 robot.orientation = math.pi - robot.orientation for robot in frame_yellow.robots_blue: robot.x *= -1 robot.orientation = math.pi - robot.orientation return frame_yellow, frame_blue
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
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)