def __init__(self, x, y): self.pose = m2d.Pose2D() self.pose.translation = m2d.Vector2(x, y) self.pose.rotation = math.radians(0) self.ball_position = m2d.Vector2(100.0, 0.0) self.obstacle_list = ([]) # is in global coordinates
def __init__(self): self.pose = m2d.Pose2D() self.pose.translation = m2d.Vector2(0, 0) self.pose.rotation = math.radians(0) self.ball_position = m2d.Vector2(2500.0, -450.0) # relative to robot self.rotation_vel = 60 # degrees per sec self.walking_vel = 200 # degrees per sec
def __init__(self): self.pose = m2d.Pose2D() self.pose.translation = m2d.Vector2(-4000, -2000) self.pose.rotation = math.radians(0) self.rotation_vel = 60 # degrees per sec self.walking_vel = 200 # mm per sec self.ball_position = m2d.Vector2(100.0, 0.0) self.obstacle_list = ([]) # is in global coordinates
def __init__(self): self.pose = m2d.Pose2D() self.pose.translation = m2d.Vector2(-4000, -700) self.pose.rotation = math.radians(-40) self.ball_position = m2d.Vector2(100.0, 0.0) self.obstacle_list = ([]) # is in global coordinates self.next_action = 0
def __init__(self): self.pose = m2d.Pose2D() self.pose.translation = m2d.Vector2(-2900, -2200) self.pose.rotation = math.radians(45) self.ball_position = m2d.Vector2(100.0, 0.0) self.obstacle_list = ([]) # is in global coordinates self.own_robots = [m2d.Vector2(-2250, -1000)] self.opp_robots = [m2d.Vector2(-1800, -1000)]
def __init__(self, x=1000, y=100): self.pose = m2d.Pose2D() self.pose.translation = m2d.Vector2(x, y) self.pose.rotation = math.radians(0) self.rotation_vel = 60 # degrees per sec self.walking_vel = 200 # mm per sec self.ball_position = m2d.Vector2(0.0, 0.0) # Possible options: normal, influence_01, generated self.potential_field_function = "normal" self.opp_robots = ([]) # is in global coordinates self.own_robots = ([]) # is in global coordinates
def __init__(self): self.pose = m2d.Pose2D() self.pose.translation = m2d.Vector2(-2900, -2200) self.pose.rotation = math.radians(55) self.ball_position = m2d.Vector2(100.0, 0.0) self.obstacle_list = ([]) # is in global coordinates self.potential_field_function = "influence_01" self.own_robots = [m2d.Vector2(-2000, -1000)] self.opp_robots = [] # m2d.Vector2(-1800, -1000) self.actions = [no_action, kick_short, sidekick_left, sidekick_right ] # possible actions the robot can perform
def main(): num_random_pos = 20 random_x = [randint(int(-field.x_length / 2 + 25), int(field.x_length / 2 - 25)) for p in range(num_random_pos)] random_y = [randint(int(-field.y_length / 2 + 25), int(field.y_length / 2 - 25)) for p in range(num_random_pos)] random_r = np.random.randint(360, size=num_random_pos) random_r = np.radians(random_r) # record the experiment header experiment = { 'kind': 'random', 'actions': actions, 'frames': [] } positions = [m2d.Pose2D(m2d.Vector2(x, y), r) for (x, y, r) in zip(random_x, random_y, random_r)] counter = mp.Value('i', 0) pool = mp.Pool(initializer=init, initargs=(counter, ), processes=4) runner = pool.map_async(make_run, positions) #wait until done # NOTE: this has to be done this way, so the programm can be interrupted by keyboard # http://xcodest.me/interrupt-the-python-multiprocessing-pool-in-graceful-way.html while not runner.ready(): try: experiment['frames'] = runner.get(1) # a very long timeout except mp.TimeoutError as ex: pass pool.close() # make sure not to overwrite anything file_idx = 0 while True: output_file = 'data/simulation_{0}.pickle'.format(file_idx) if os.path.exists(output_file): file_idx += 1 else: pickle.dump(experiment, open(output_file, "wb")) break
import math import numpy as np from matplotlib import pyplot as plt from tools import field_info as field from naoth import math2d as m2d from tools import potential_field as pf from tools import tools from state import State if __name__ == "__main__": state = State() state.opp_robots.append( m2d.Pose2D(m2d.Vector2(2000, 1000), math.radians(0))) state.own_robots.append( m2d.Pose2D(m2d.Vector2(-2000, 1000), math.radians(0))) plt.clf() x_val = np.arange(-field.x_field_length / 2, field.x_field_length / 2, 10) y_val = np.arange(-field.y_field_length / 2, field.y_field_length / 2, 10) potentials = np.zeros((len(y_val), len(x_val))) # There is probably a better implementation for this step_x = 0 step_y = 0 for x in x_val: for y in y_val: # potentials[step_y][step_x] = pf.evaluate_single_pos(m2d.Vector2(x, y)) potentials[step_y][step_x] = pf.evaluate_single_pos_with_robots( m2d.Vector2(x, y), state.opp_robots, state.own_robots) step_y += 1