def __init__(self, *args, **kwargs): super(ZonePasserMasterCyclic, self).__init__(*args, **kwargs) self.idash = IDash(0.005) self.activezones = [] self.receivingzones = [] self.activeplayer = None self.receivingplayer = None self.zones = {(1, 1): 1, (1, -1): 2, (-1, 1): 3, (-1, -1): 4} self.zonesigns = [(1, 1), (1, -1), (-1, 1), (-1, -1)] self.zone_centers = np.array( [[CENTER_X, CENTER_X, -CENTER_X, -CENTER_X], [CENTER_Y, -CENTER_Y, CENTER_Y, -CENTER_Y]]) self.zone_corners = np.array( [[CORNER_X, CORNER_X, -CORNER_X, -CORNER_X], [CORNER_Y, -CORNER_Y, CORNER_Y, -CORNER_Y]]) # TODO: remove me since we're not allowed to set the ball pose # start ball at zone 4 - 1 (0 indexed) ball_start = self.zone_centers[:, 3] ball_start[ 1] -= 0.05 # move closer to players center, but further distance q from player # self.ballEngine.setBallPose(ball_start) self.ballEngine.update() # FIXME: Hardcoded is good for drill, not good for game! self.zone_pass_plan = [4, 2, 1, 3, 4, 2] # the locations between the 5 passes self.activebot_idx_plan = [ 0, 1, 2, 0, 1, 2 ] # which robot should take the active zone during the zone pass plan?
def __init__(self, color, number): # parameter init self.bot_name = '%s%d' % (color, number) self.bot_nameStriker = 'Red1' # run startup methods self.initializeVrepClient() self.initializeVrepApi() # self.killer = GracefulKiller() self.idash = IDash(framerate=0.05)
def robotCode(self): self.path = np.array([[0.2, 0.2, -0.2, -0.2], [0.4, -0.4, -0.4, 0.4], [15, 15, 15, 15]]) # dash = IDash(framerate=0.1) # plt.plot(self.path[0,:], self.path[1,:]) # dash.add(plt) #k=0.0345 # ball model: d(t) = vmot*k*(1-exp(-t/T)) goal = (0.0, 0.0) self.path, status = passPath(self.getRobotConf(self.bot), self.ballEngine.getBallPose(), goal, kick=True) print self.path dash = IDash(framerate=0.1) dash.add(lambda: plt.plot(-self.path[1, :], self.path[0, :], 'b-*') and plt.xlim([-0.7, 0.7]) and plt.ylim([-0.7, 0.7])) dash.plotframe() print 'estimated time path' print calculatePathTime(self.path) t = self.ballEngine.getSimTime() # time in seconds # while (self.ballEngine.getSimTime()-t)<10: #End program after 30sec cc = 1 while cc: robotConf = self.getRobotConf(self.bot) cc = self.followPath(robotConf, status, rb=0.05) self.ballEngine.update() nextBallPos = self.ballEngine.getNextRestPos() # robotConf = self.getRobotConf(self.bot) # ballPos = self.ballEngine.getBallPose() # (x, y) # vRobot = v2Pos(robotConf, ballPos) self.setMotorVelocities(0, 0) print 'real time path' print(self.ballEngine.getSimTime() - t)
def __init__(self, color, number, clientID=None, ip='127.0.0.1', port=19998): # ip='127.0.0.1', '172.29.34.63' """ color: i.e. 'Blue' number: i.e. 1 clientID: Default None; if provided as parameter, `vrep.simxStart` was called outside this class """ # parameter init self.ip = ip self.port = port self.color = color self.bot_name = '%s%d' % (color, number) self.bot_nameStriker = 'Red1' self.vm = self.v = 0 self.tv = self.tvm = 0 # run startup methods if clientID is not None: # Use existing clientID (multi robot case) self.clientID = clientID self.multirobots = True print( "ClientID obtained as parameter! (Probably doing Multirobots...)" ) else: # Make connection to VREP client (single robot case) self.initializeVrepClient() self.multirobots = False self.initializeVrepApi() #self.killer = GracefulKiller() self.idash = IDash(framerate=0.05) self.ballEngine = BallEngine(self.clientID)
def __init__(self, *args, **kwargs): super(Master, self).__init__(*args, **kwargs) self.color = None self.idash = IDash(framerate=0.005)
def __init__(self): self.initialize_vrep_client() self.initilize_vrep_api() self.define_constants() self.killer = GracefulKiller() self.idash = IDash(framerate=0.05)
def __init__(self, *args, **kwargs): super(MyRobotRunner, self).__init__(*args, **kwargs) self.idash = IDash(0.005)
import matplotlib.pyplot as plt import numpy as np import sys import time from load import mnist from scipy.spatial.distance import cdist from idash import IDash from sklearn.metrics import accuracy_score dash = IDash(framerate=0.01) def idx1D_to_idx2D(idx, shape): n_rows, n_cols = shape ith_row = idx / n_cols # integer division jth_col = idx % n_cols return (ith_row, jth_col) def test_idx1D_to_idx2D(): assert idx1D_to_idx2D(0, (3, 3)) == (0, 0) assert idx1D_to_idx2D(1, (3, 3)) == (0, 1) assert idx1D_to_idx2D(7, (3, 3)) == (2, 1) # test_idx1D_to_idx2D() def time_varying_sigma(n, sigma_0, tau):