Skip to content

Commit

Permalink
fix: Add condition within PositionDroneEnv to truncate sim if any val…
Browse files Browse the repository at this point in the history
…ue is nan
  • Loading branch information
iwishiwasaneagle committed Mar 2, 2023
1 parent 2e90952 commit 024387b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/jdrones/envs/position.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ def __init__(
@property
def action_space(self) -> ActType:
bounds = np.array([[0, 10], [0, 10], [1, 10]])

return spaces.Box(low=bounds[:, 0], high=bounds[:, 1])

def reset(
Expand Down Expand Up @@ -64,10 +63,12 @@ def step(

e = self.env.controllers["lqr"].e
dist = np.linalg.norm(np.concatenate([e.pos, e.rpy]))
if np.any(np.isnan(dist)):
trunc = True

if dist < 0.01:
term = True
info["error"] = dist
break

states = States(observations)
return states, self.get_reward(states), term, trunc, info
Expand Down

0 comments on commit 024387b

Please sign in to comment.