You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"""This function checks to see if the vector from self.prev_pos to self.pos collides with any walls. If it does, then you've nothing to worry about. If it does, then you need to bounce off the wall and update the velocity and position accordingly. This is done in the handle_wall_collisions() function.
425
425
TODO strictly wall collisions are only considered in 2D but this function should be extended to 1D too, for completeness."""
426
-
proposed_step=np.array([self.prev_pos, self.pos])
427
-
wall_check=self.Environment.check_wall_collisions(proposed_step) #returns (None, None) for 1D Envs
428
-
walls=wall_check[0] # shape=(N_walls,2,2)
429
-
wall_collisions=wall_check[1] # shape=(N_walls,)
430
-
431
-
# If no wall collsions it is safe to move to the next position so do nothing
432
-
if (wall_collisionsisNone) or (Truenotinwall_collisions): return
# TODO strictly in the event of a collision the position should be updated away from the wall starting from the collision point (and only for the remaining fraction of dt), not the prev position. Small detail but worth fixing.
440
-
self.pos=self.prev_pos+self.velocity*self.dt
441
-
return
426
+
whileTrue: # keep checking until no wall collisions
427
+
proposed_step=np.array([self.prev_pos, self.pos])
428
+
wall_check=self.Environment.check_wall_collisions(proposed_step) #returns (None, None) for 1D Envs
429
+
walls=wall_check[0] # shape=(N_walls,2,2)
430
+
wall_collisions=wall_check[1] # shape=(N_walls,)
431
+
432
+
# If no wall collsions it is safe to move to the next position so do nothing
433
+
if (wall_collisionsisNone) or (Truenotinwall_collisions): return
# TODO strictly in the event of a collision the position should be updated away from the wall starting from the collision point (and only for the remaining fraction of dt), not the prev position. Small detail but worth fixing.
"""This function takes self.prev_pos and self.pos and uses them to update self.measured_velocity. Then it takes self.prev_measured_velocity and self.measured_velocity and calculates self.measured_rotational_velocity. These "measured" velocities are typically the same as self.velocity and self.rotational_velocity but not always. The reason for this is that when the Agent is near a wall it is possible for the dynamical updates to adjust its position without adjusting its velocity (e.g. conveyor belt drift), in which case the absolute velocities of the agent (which are the one we want to save into the history dataframe) may be subtely different from the velocity used in the motion updates thinks it has (self.velocity) and which it will use for dynamical updates on subsequent steps.
0 commit comments