Skip to content

Commit

Permalink
Fix test (#525)
Browse files Browse the repository at this point in the history
* fix env

* format
  • Loading branch information
QuanyiLi committed Aug 22, 2021
1 parent ad1d3ec commit 321b67c
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions pgdrive/policy/env_input_policy.py
@@ -1,4 +1,5 @@
from pgdrive.policy.base_policy import BasePolicy
from pgdrive.utils.math_utils import clip


class EnvInputPolicy(BasePolicy):
Expand All @@ -14,10 +15,15 @@ def __init__(self):
) # for discrete actions space

def act(self, agent_id):
# clip to -1, 1
action = [
clip(self.engine.external_actions[agent_id][i], -1.0, 1.0)
for i in range(len(self.engine.external_actions[agent_id]))
]
if not self.discrete_action:
return self.engine.external_actions[agent_id]
return action
else:
return self.convert_to_continuous_action(self.engine.external_actions[agent_id])
return self.convert_to_continuous_action(action)

def convert_to_continuous_action(self, action):
steering = action[0] * self.steering_unit - 1.0
Expand Down

0 comments on commit 321b67c

Please sign in to comment.