Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions rps/robotarium.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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])))-\
Expand All @@ -72,4 +72,3 @@ def step(self):
self.figure.canvas.draw_idle()
self.figure.canvas.flush_events()
self.previous_render_time = t

13 changes: 11 additions & 2 deletions rps/robotarium_abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 = []
Expand Down