forked from robocin/rSoccer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
define simple action and observation space
- Loading branch information
1 parent
a99b190
commit 97bf70f
Showing
12 changed files
with
71 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
.DS_Store | ||
grsim_ssl/__pycache__/* | ||
*.pyc | ||
gym_ssl.egg-info/ | ||
pb/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,66 @@ | ||
import gym | ||
import math | ||
import numpy as np | ||
|
||
from gym_ssl.grsim_ssl.grSimClient import grSimClient | ||
|
||
|
||
class GrSimSSLEnv(gym.Env): | ||
""" | ||
Using cartpole env description as base example for our documentation | ||
Description: | ||
A pole is attached by an un-actuated joint to a cart, which moves along | ||
a frictionless track. The pendulum starts upright, and the goal is to | ||
prevent it from falling over by increasing and reducing the cart's | ||
velocity. | ||
Source: | ||
This environment corresponds to the version of the cart-pole problem | ||
described by Barto, Sutton, and Anderson | ||
Observation: | ||
Type: Box(3) | ||
Num Observation Min Max | ||
0 id 0 Blue Team Robot X -Inf Inf | ||
1 id 0 Blue Team Robot Y -Inf Inf | ||
2 id 0 Blue Team Robot Angle -3.1416 3.1416 | ||
Actions: | ||
Type: Box(3) | ||
Num Action Min Max | ||
0 id 0 Blue Team Robot Vx -1 1 | ||
1 id 0 Blue Team Robot Vy -1 1 | ||
2 id 0 Blue Team Robot Omega -1 1 | ||
Note: The amount the velocity that is reduced or increased is not | ||
fixed; it depends on the angle the pole is pointing. This is because | ||
the center of gravity of the pole increases the amount of energy needed | ||
to move the cart underneath it | ||
Reward: | ||
Reward is 1 for every step taken, including the termination step | ||
Starting State: | ||
All observations are assigned a uniform random value in [-0.05..0.05] | ||
Episode Termination: | ||
Pole Angle is more than 12 degrees. | ||
Cart Position is more than 2.4 (center of the cart reaches the edge of | ||
the display). | ||
Episode length is greater than 200. | ||
Solved Requirements: | ||
Considered solved when the average return is greater than or equal to | ||
195.0 over 100 consecutive trials. | ||
""" | ||
|
||
def __init__(self): | ||
self.client = grSimClient() | ||
|
||
self.action_space = gym.spaces.Box(low=-1, high=1, shape=(3,), dtype=np.float32) | ||
# Observation Space thresholds | ||
obsSpaceThresholds = np.array([np.finfo(np.float32).max, | ||
np.finfo(np.float32).max, | ||
math.pi], dtype=np.float32) | ||
self.observation_space = gym.spaces.Box(low=-obsSpaceThresholds, high=obsSpaceThresholds) | ||
|
||
print('Environment initialized') | ||
|
||
def step(self): | ||
print('step sucessful!') | ||
return self.observation_space.sample() | ||
def reset(self): | ||
print('Environment reset') |
Binary file not shown.
Binary file not shown.
Binary file removed
BIN
-3.56 KB
gym_ssl/grsim_ssl/pb/__pycache__/grSim_Replacement_pb2.cpython-38.pyc
Binary file not shown.
Binary file removed
BIN
-4.96 KB
gym_ssl/grsim_ssl/pb/__pycache__/messages_robocup_ssl_detection_pb2.cpython-38.pyc
Binary file not shown.
Binary file removed
BIN
-7.9 KB
gym_ssl/grsim_ssl/pb/__pycache__/messages_robocup_ssl_geometry_pb2.cpython-38.pyc
Binary file not shown.
Binary file removed
BIN
-2.32 KB
gym_ssl/grsim_ssl/pb/__pycache__/messages_robocup_ssl_wrapper_pb2.cpython-38.pyc
Binary file not shown.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import gym | ||
import gym_ssl | ||
|
||
env = gym.make('grSimSSL-v0') | ||
env.step() | ||
env.reset() | ||
print(env.action_space.sample()) | ||
print(env.observation_space.sample()) |