Skip to content

Commit

Permalink
Merge pull request #42 from jerryz123/teleop_fix
Browse files Browse the repository at this point in the history
Fixed tele-op agent actions and state generation
  • Loading branch information
mdlaskey committed Apr 3, 2018
2 parents 23c9519 + ba9fdc2 commit 1be0bfc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 3 additions & 1 deletion gym_urbandriving/agents/tele_op/keyboard_agent.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import pygame
from gym_urbandriving.agents import Agent
from gym_urbandriving.actions import SteeringAction
import numpy as np

class KeyboardAgent(Agent):
"""
Expand Down Expand Up @@ -43,4 +45,4 @@ def eval_policy(self, state):
steer = 1
elif keys[pygame.K_RIGHT]:
steer = -1
return np.array([steer, acc])
return SteeringAction(steer, acc)
12 changes: 5 additions & 7 deletions gym_urbandriving/state/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,16 +122,14 @@ def create_agents(self):
self.bg_agents['controlled_cars'].append(agent)

def is_in_collision(self,car):

for obj in self.static_objects:
if car.collides(obj):
return True

return True
for key in self.dynamic_objects.keys():
for i,obj in enumerate(self.dynamic_objects[key]):
if car.collides(obj):
return True

for i,obj in six.iteritems(self.dynamic_objects[key]):
if car.collides(obj):
return True
return False


Expand Down

0 comments on commit 1be0bfc

Please sign in to comment.