Skip to content

Commit

Permalink
chore(eagerx): bump version eagerx to 0.1.10 (#244)
Browse files Browse the repository at this point in the history
Co-authored-by: Jelle Luijkx <j.d.luijkx@tudelft.nl>
  • Loading branch information
jelledouwe and jelledouwe authored Mar 29, 2022
1 parent 3a08d24 commit a7bd1d1
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 16 deletions.
16 changes: 9 additions & 7 deletions projects/control/eagerx/demos/demo_classifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# limitations under the License.

import argparse
import os

# EAGERx imports
from eagerx import Object, Bridge, Node, initialize, log
Expand All @@ -34,14 +35,15 @@ def example_classifier(name, eps, eval_eps, device, render=False):
"GymObject",
"pendulum",
sensors=["image", "observation", "reward", "done"],
gym_env_id="Pendulum-v0",
gym_rate=20,
gym_always_render=True,
env_id="Pendulum-v0",
rate=20,
always_render=True,
render_shape=[28, 28],
)

# Define PID controller & classifier
classifier = Node.make("Classifier", "classifier", rate=20, cam_rate=20, data="../data/with_actions.h5")
dir_path = os.path.dirname(os.path.realpath(__file__))
classifier = Node.make("Classifier", "classifier", rate=20, cam_rate=20, data=dir_path + "/../data/with_actions.h5")
pid = Node.make("PidController", "pid", rate=20, gains=[8, 1, 0], y_range=[-4, 4])

# Define graph (agnostic) & connect nodes
Expand All @@ -63,9 +65,9 @@ def example_classifier(name, eps, eval_eps, device, render=False):
bridge = Bridge.make("GymBridge", rate=20)

# Initialize Environment (agnostic graph + bridge)
env = eagerx_gym.EagerGym(name=name, rate=20, graph=graph, bridge=bridge)
env = eagerx_gym.EagerxGym(name=name, rate=20, graph=graph, bridge=bridge)
if render:
env.render(mode='human')
env.render(mode="human")

# Initialize and train stable-baselines model
model = sb.SAC("MlpPolicy", env, verbose=1, device=device)
Expand All @@ -87,7 +89,7 @@ def example_classifier(name, eps, eval_eps, device, render=False):
parser.add_argument("--name", help="Name of the environment", type=str, default="example")
parser.add_argument("--eps", help="Number of training episodes", type=int, default=200)
parser.add_argument("--eval_eps", help="Number of evaluation episodes", type=int, default=20)
parser.add_argument("--render", help="Toggle rendering", action='store_true')
parser.add_argument("--render", help="Toggle rendering", action="store_true")

args = parser.parse_args()

Expand Down
8 changes: 4 additions & 4 deletions projects/control/eagerx/demos/demo_full_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def example_full_state(name, eps, eval_eps, device, render=False):
sensors = ["observation", "reward", "done"]
if render:
sensors.append("image")
pendulum = Object.make("GymObject", "pendulum", sensors=sensors, gym_env_id="Pendulum-v0", gym_rate=20)
pendulum = Object.make("GymObject", "pendulum", sensors=sensors, env_id="Pendulum-v0", rate=20)

# Define graph (agnostic) & connect nodes
graph = Graph.create(objects=[pendulum])
Expand All @@ -48,9 +48,9 @@ def example_full_state(name, eps, eval_eps, device, render=False):
bridge = Bridge.make("GymBridge", rate=20)

# Initialize Environment (agnostic graph + bridge)
env = eagerx_gym.EagerGym(name=name, rate=20, graph=graph, bridge=bridge)
env = eagerx_gym.EagerxGym(name=name, rate=20, graph=graph, bridge=bridge)
if render:
env.render(mode='human')
env.render(mode="human")

# Initialize and train stable-baselines model
model = sb.SAC("MlpPolicy", env, verbose=1, device=device)
Expand All @@ -71,7 +71,7 @@ def example_full_state(name, eps, eval_eps, device, render=False):
parser.add_argument("--name", help="Name of the environment", type=str, default="example")
parser.add_argument("--eps", help="Number of training episodes", type=int, default=200)
parser.add_argument("--eval_eps", help="Number of evaluation episodes", type=int, default=20)
parser.add_argument("--render", help="Toggle rendering", action='store_true')
parser.add_argument("--render", help="Toggle rendering", action="store_true")

args = parser.parse_args()

Expand Down
8 changes: 4 additions & 4 deletions projects/control/eagerx/demos/demo_pid.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def example_pid_only(name, eps, eval_eps, device, render=False):
sensors = ["observation", "reward", "done"]
if render:
sensors.append("image")
pendulum = Object.make("GymObject", "pendulum", sensors=sensors, gym_env_id="Pendulum-v0", gym_rate=20)
pendulum = Object.make("GymObject", "pendulum", sensors=sensors, env_id="Pendulum-v0", rate=20)

# Define PID controller & classifier
pid = Node.make("PidController", "pid", rate=20, gains=[8, 1, 0], y_range=[-4, 4])
Expand All @@ -54,9 +54,9 @@ def example_pid_only(name, eps, eval_eps, device, render=False):
bridge = Bridge.make("GymBridge", rate=20)

# Initialize Environment (agnostic graph + bridge)
env = eagerx_gym.EagerGym(name=name, rate=20, graph=graph, bridge=bridge)
env = eagerx_gym.EagerxGym(name=name, rate=20, graph=graph, bridge=bridge)
if render:
env.render(mode='human')
env.render(mode="human")

# Initialize and train stable-baselines model
model = sb.SAC("MlpPolicy", env, verbose=1, device=device)
Expand All @@ -77,7 +77,7 @@ def example_pid_only(name, eps, eval_eps, device, render=False):
parser.add_argument("--name", help="Name of the environment", type=str, default="example")
parser.add_argument("--eps", help="Number of training episodes", type=int, default=200)
parser.add_argument("--eval_eps", help="Number of evaluation episodes", type=int, default=20)
parser.add_argument("--render", help="Toggle rendering", action='store_true')
parser.add_argument("--render", help="Toggle rendering", action="store_true")

args = parser.parse_args()

Expand Down
2 changes: 1 addition & 1 deletion projects/control/eagerx/dependencies.ini
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[runtime]
python=eagerx-examples==0.1.3
python=eagerx-examples==0.1.5

0 comments on commit a7bd1d1

Please sign in to comment.