コード例 #1
0
    def sendCommands(self, data, id):

        packet = grSim_Packet_pb2.grSim_Packet()
        now_time = (time.mktime(datetime.now().timetuple()))
        packet.commands.timestamp = now_time

        if self.friend_color == "yellow":
            packet.commands.isteamyellow = True
        else:
            packet.commands.isteamyellow = False

        commands = packet.commands.robot_commands.add()
        commands.id = id
        commands.kickspeedx = data.kick_speed_x
        commands.kickspeedz = data.kick_speed_z
        if math.isnan(data.vel_surge)  \
            or math.isnan(data.vel_sway)  \
            or math.isnan(data.omega):
            commands.veltangent = 0
            commands.velnormal = 0
            commands.velangular = 0
        else:
            commands.veltangent = data.vel_surge
            commands.velnormal = data.vel_sway
            commands.velangular = data.omega

        if data.dribble_power > 0:
            commands.spinner = True
        else:
            commands.spinner = False

        commands.wheelsspeed = False

        message = packet.SerializeToString()
        self.sock.sendto(message, (self.host, self.port))
コード例 #2
0
def sendCommand(commands):
  command = grSim_Packet_pb2.grSim_Packet()
  now_time  = (time.mktime(datetime.now().timetuple()))
  command.commands.timestamp   = now_time

  if  friend_color == 'yellow':
    command.commands.isteamyellow= True
  else:
    command.commands.isteamyellow= False

  robo_commands = command.commands.robot_commands.add()
  robo_commands.id          = 0
  robo_commands.kickspeedx  = commands.kick_speed_x
  robo_commands.kickspeedz  = commands.kick_speed_z
  robo_commands.veltangent  = commands.vel_surge
  robo_commands.velnormal   = -commands.vel_sway
  robo_commands.velangular  = commands.omega

  if commands.dribble_power > 0 :
      robo_commands.spinner     = True
  else:
      robo_commands.spinner = False

  robo_commands.wheelsspeed = False

  message   = command.SerializeToString()
  sock.sendto(message, (host, port))
コード例 #3
0
 def send_value(self, msg):
     for msg in msg.send:
         self.recieve_info = msg
         self.move_deg = self.recieve_info.move_degree
         packet = grSim_Packet_pb2.grSim_Packet()
         packet.commands.timestamp = 0
         packet.commands.isteamyellow = False
         packet_command = packet.commands.robot_commands.add()
         packet_command.id = self.recieve_info.robot_id
         packet_command.veltangent = math.cos(
             self.recieve_info.move_degree
         ) * 1.6 * self.recieve_info.distance
         packet_command.velnormal = math.sin(
             self.recieve_info.move_degree
         ) * 1.6 * self.recieve_info.distance
         packet_command.velangular = self.recieve_info.direction * 4
         packet_command.kickspeedx = self.recieve_info.kickspeedx
         packet_command.kickspeedz = 0
         packet_command.spinner = self.recieve_info.spinner
         packet_command.wheelsspeed = False
         #print(self.recieve_info.stop)
         if self.recieve_info.stop == True:
             #print(self.recieve_info.stop)
             packet_command.veltangent = 0
             packet_command.velnormal = 0
         message = packet.SerializeToString()
         self.sock.sendto(message, (self.host, self.port))
コード例 #4
0
 def reset_ball(self):
     package = sim_pkg.grSim_Packet()
     replacement = package.replacement
     ball_rep = replacement.ball
     ball_rep.x = np.random.randint(-600, 600) / 100.0
     ball_rep.y = np.random.randint(-450, 450) / 100.0
     ball_rep.vx = 0.0
     ball_rep.vy = 0.0
     self.socket.sendto(package.SerializeToString(), self.address)
コード例 #5
0
    def reset_bot(self, robot_num):
        package = sim_pkg.grSim_Packet()
        replacement = package.replacement
        bot_rep = replacement.robots.add()

        bot_rep.x = np.random.randint(-600, 600) / 100.0
        bot_rep.y = np.random.randint(-450, 450) / 100.0
        bot_rep.dir = np.pi * np.random.randint(-180, 180) / 180.0
        bot_rep.id = robot_num
        bot_rep.yellowteam = False

        self.socket.sendto(package.SerializeToString(), self.address)
コード例 #6
0
    def send_action(self, robot_num=0, vx=0, vy=0, w=0):
        package = sim_pkg.grSim_Packet()
        commands = package.commands

        commands.timestamp = 0
        commands.isteamyellow = False
        command = commands.robot_commands.add()
        command.id = robot_num
        command.kickspeedx = 0
        command.kickspeedz = 0
        command.veltangent = vx
        command.velnormal = vy
        command.velangular = w
        command.spinner = 0
        command.wheelsspeed = False

        self.socket.sendto(package.SerializeToString(), self.address)
コード例 #7
0
    def reset(self, robot_num):
        package = sim_pkg.grSim_Packet()
        replacement = package.replacement
        #ball_rep = replacement.ball
        bot_rep = replacement.robots.add()

        #ball_rep.x = 100.0
        #ball_rep.y = 0.0
        #ball_rep.vx = 0.0
        #ball_rep.vy = 0.0

        bot_rep.x = 0.0
        bot_rep.y = 0.0
        bot_rep.dir = 0.0
        bot_rep.id = robot_num
        bot_rep.yellowteam = False

        self.socket.sendto(package.SerializeToString(), self.address)
コード例 #8
0
    def reset(self):
        package = sim_pkg.grSim_Packet()
        replacement = package.replacement
        bot_rep = replacement.robots.add()
        bot_rep.x = np.random.randint(-200, 200) / 100.0
        bot_rep.y = np.random.randint(-200, 200) / 100.0
        bot_rep.dir = 0.0
        bot_rep.id = ME
        bot_rep.yellowteam = False

        bot_rep = replacement.robots.add()
        bot_rep.x = np.random.randint(-300, 300) / 100.0
        bot_rep.y = np.random.randint(-300, 300) / 100.0
        bot_rep.dir = 0.0
        bot_rep.id = ENEMY
        bot_rep.yellowteam = True

        bot_rep = replacement.robots.add()
        bot_rep.x = np.random.randint(-300, 300) / 100.0
        bot_rep.y = np.random.randint(-300, 300) / 100.0
        bot_rep.dir = 0.0
        bot_rep.id = ENEMY2
        bot_rep.yellowteam = True

        bot_rep = replacement.robots.add()
        bot_rep.x = np.random.randint(-300, 300) / 100.0
        bot_rep.y = np.random.randint(-300, 300) / 100.0
        bot_rep.dir = 0.0
        bot_rep.id = ENEMY3
        bot_rep.yellowteam = True

        ball_rep = replacement.ball
        ball_rep.x = 0
        ball_rep.y = 0
        ball_rep.vx = 0.0
        ball_rep.vy = 0.0

        self.socket.sendto(package.SerializeToString(), self.address)