diff --git a/rps/robotarium.py b/rps/robotarium.py index 1526553..866563c 100644 --- a/rps/robotarium.py +++ b/rps/robotarium.py @@ -8,8 +8,8 @@ class Robotarium(RobotariumABC): - def __init__(self, number_of_agents=10, show_figure=True, save_data=True, update_time=1): - super().__init__(number_of_agents, show_figure, save_data) + def __init__(self, number_of_agents=10, show_figure=True, initial_conditions = None, save_data=True, update_time=1): + super().__init__(number_of_agents, show_figure, initial_conditions, save_data) #Initialize some rendering variables self.previous_render_time = time.time() @@ -63,7 +63,7 @@ def step(self): self.left_wheel_patches[i].center = self.poses[:2, i]+self.robot_size*np.array((np.cos(self.poses[2, i]-math.pi/2), np.sin(self.poses[2, i]-math.pi/2)))+\ 0.04*np.array((-np.sin(self.poses[2, i]+math.pi/2), np.cos(self.poses[2, i]+math.pi/2))) self.left_wheel_patches[i].orientation = self.poses[2,i] + math.pi/4 - + self.right_led_patches[i].center = self.poses[:2, i]+0.75*self.robot_size*np.array((np.cos(self.poses[2,i]), np.sin(self.poses[2,i])))-\ 0.04*np.array((-np.sin(self.poses[2, i]), np.cos(self.poses[2, i]))) self.left_led_patches[i].center = self.poses[:2, i]+0.75*self.robot_size*np.array((np.cos(self.poses[2,i]), np.sin(self.poses[2,i])))-\ @@ -72,4 +72,3 @@ def step(self): self.figure.canvas.draw_idle() self.figure.canvas.flush_events() self.previous_render_time = t - diff --git a/rps/robotarium_abc.py b/rps/robotarium_abc.py index f303404..994c992 100644 --- a/rps/robotarium_abc.py +++ b/rps/robotarium_abc.py @@ -11,7 +11,7 @@ class RobotariumABC(ABC): - def __init__(self, number_of_agents=10, show_figure=True, save_data=True): + def __init__(self, number_of_agents=10, show_figure=True, initial_conditions = None, save_data=True): self.number_of_agents = number_of_agents self.show_figure = show_figure @@ -31,7 +31,16 @@ def __init__(self, number_of_agents=10, show_figure=True, save_data=True): self.time_step = 0.033 self.velocities = np.zeros((2, number_of_agents)) - self.poses = misc.generate_initial_conditions(self.number_of_agents, spacing=0.2, width=2.5, height=1.5) + + if initial_conditions is not None: + if initial_conditions.shape == (3,self.number_of_agents): + self.poses = initial_conditions + else : + raise Exception('Initial conditions entered are not acceptable by the Robotarium Simulator') + else: + self.poses = misc.generate_initial_conditions(self.number_of_agents, spacing=0.2, width=2.5, height=1.5) + + self.saved_poses = [] self.saved_velocities = [] self.left_led_commands = []