def positionall():
    t1=time.time()
    vision = psl.SSLVisionClient('224.5.23.2', 10020)
    vision.connect()
    tcontrol = psl.SSLgrSimClient('127.0.0.1', 20011)
    tcontrol.connect()
    L=[]
    while len(L)!=5:
        data=vision.receive()
        if len(data.detection.robots_yellow) != 0 :
            for r in data.detection.robots_yellow:
                if r.robot_id==0:
                    dy0=data
                    if 'y0' not in L:
                        L.append('y0')
                else :
                    dy1=data
                    if 'y1' not in L:
                        L.append('y1')
        elif len(data.detection.robots_blue)!=0:
            for r in data.detection.robots_blue:
                if r.robot_id==1:
                    db1=data
                    if 'b1' not in L:
                        L.append('b1')
                else :
                    db0=data
                    if 'b0' not in L:
                        L.append('b0')
        if len(data.detection.balls)!=0:
            dball=data
            if 'ball' not in L:
                L.append('ball')
    t2=time.time()
    Pos=dict()
    Pos[('b',0)]=db0
    Pos[('b',1)]=db1
    Pos[('y',0)]=dy0
    Pos[('y',1)]=dy1    
    Pos['ball']=dball
    return Pos
def stop(i,team):
    tcontrol = psl.SSLgrSimClient('127.0.0.1', 20011)
    tcontrol.connect()
    packet_b0 = psl.grSim_pb2.grSim_Packet()
    commands_b0 = packet_b0.commands
    commands_b0.timestamp = time.time()
    if team=='y':
        commands_b0.isteamyellow = True
    else :
        commands_b0.isteamyellow = False
    robot_commands_b0 = commands_b0.robot_commands.add()
    robot_commands_b0.id = i
    robot_commands_b0.kickspeedx = 0.
    robot_commands_b0.kickspeedz = 0.
    robot_commands_b0.veltangent = 0.
    robot_commands_b0.velnormal  = 0.
    robot_commands_b0.velangular = 0. # Ask for rotation
    robot_commands_b0.spinner = False
    robot_commands_b0.wheelsspeed = False
    tcontrol.send(packet_b0)
    tcontrol.close()
Ejemplo n.º 3
0
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.patches as patches
import matplotlib.lines as lines
import potentiel as pt

from psl_package import paris_saclay_league as psl
import cmath as c
import time
import numpy as np

import ia_v3 as ia

#Connexion au simulateur
vision = psl.SSLVisionClient(ip='224.5.23.2', port=10020)
vision.connect()
grSim = psl.SSLgrSimClient('127.0.0.1', 20011)
grSim.connect()

#%% Paramètres

#TERRAIN
longueur = 1350
largeur = 1000
xmin = -longueur
xmax = longueur
ymin = -largeur
ymax = largeur

##ROBOT
r_robot = 115
K_max = 0.8  #facteur prop vitesse
Ejemplo n.º 4
0
    except:
        communication = None
        print('Pas de carte communication détectée')

    #%% Connexion à la vision

    vision = psl.SSLVisionClient(ip='224.5.23.2', port=10006)
    vision.connect3()

    #%% Connexion simulateur

    simulateur = False

    if simulateur:
        grSim = psl.SSLgrSimClient('192.168.1.11', 20011)
        grSim.connect()
        sim = grSim
        print('Connexion au simulateur OK')
    else:
        print('Sans grSim')
        sim = None

#%%Création match
    '''parametre disp :
        -1 : aucun affichage
         0 : affichage dans la console des changements de postes
         1 : affichage dans un plot des status des robots
         2 : affichage dans un plot du terrain avec les robots et leur status'''

    match_test = match.Match('test', vision, sim, communication, disp=2)
                    if 'b0' not in L:
                        L.append('b0')
        if len(data.detection.balls)!=0:
            dball=data
            if 'ball' not in L:
                L.append('ball')
    t2=time.time()
    Pos=dict()
    Pos[('b',0)]=db0
    Pos[('b',1)]=db1
    Pos[('y',0)]=dy0
    Pos[('y',1)]=dy1    
    Pos['ball']=dball
    return Pos

tcontrol = psl.SSLgrSimClient('127.0.0.1', 20011)
tcontrol.connect()

class ball():
    def __init__(self):
        pos=positionall()
        for r in pos['ball'].detection.balls:
            ball.x=r.x
            ball.y=r.y
            
class robot():
    def __init__(self,i,team):
        self.id=i
        self.team=team
        self.packet=psl.grSim_pb2.grSim_Packet()
        self.commands_b0 = self.packet.commands