Skip to content

Commit

Permalink
Merge pull request #27 from eager-dev/fix/process_comments
Browse files Browse the repository at this point in the history
Fix/process comments
  • Loading branch information
jelledouwe authored May 10, 2022
2 parents 70f9060 + 70f790d commit ab836c4
Show file tree
Hide file tree
Showing 13 changed files with 809 additions and 641 deletions.
4 changes: 3 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ The following tutorials are currently available:
- `Tutorial 6: More Informative Rendering <https://colab.research.google.com/github/eager-dev/eagerx_tutorials/blob/master/tutorials/pendulum/6_rendering.ipynb>`_
- `Tutorial 7: Reset Routines <https://colab.research.google.com/github/eager-dev/eagerx_tutorials/blob/master/tutorials/pendulum/7_reset_routine.ipynb>`_

A page with the exercises only is available `here <https://araffin.github.io/tools-for-robotic-rl-icra2022/notebooks/eagerx_exercises.html>`_.

How to run the tutorials locally?
=================================

Expand Down Expand Up @@ -89,5 +91,5 @@ If you are using EAGERx for your scientific publications, please cite:
}
Acknowledgements
=================
================
EAGERx is funded by the `OpenDR <https://opendr.eu/>`_ Horizon 2020 project.
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@
import numpy as np


class Layover(eagerx.Node):
class Overlay(eagerx.Node):
@staticmethod
@register.spec("Layover", eagerx.Node)
@register.spec("Overlay", eagerx.Node)
def spec(
spec,
name: str,
rate: float,
process: int = eagerx.process.ENVIRONMENT,
color: str = "cyan",
):
"""Layover spec"""
"""Overlay spec"""
# Fills spec with defaults parameters
spec.initialize(Layover)
spec.initialize(Overlay)

# Adjust default params
spec.config.update(
Expand Down
6 changes: 3 additions & 3 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 9 additions & 9 deletions tests/test_gymbridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,17 @@ def test_gymbridge():
graph.connect(source=pendulum.sensors.theta, observation="angle", window=1)
graph.connect(source=pendulum.sensors.dtheta, observation="angular_velocity", window=1)

# Create layover node
import eagerx_tutorials.pendulum.layover # noqa:
layover = eagerx.Node.make("Layover", "layover", rate)
layover.inputs.u.space_converter = pendulum.actuators.u.space_converter
graph.add(layover)
# Create overlay node
import eagerx_tutorials.pendulum.overlay # noqa:
overlay = eagerx.Node.make("Overlay", "overlay", rate)
overlay.inputs.u.space_converter = pendulum.actuators.u.space_converter
graph.add(overlay)

# Render image
graph.connect(source=pendulum.sensors.image, target=layover.inputs.base_image)
graph.connect(source=reset.outputs.u, target=layover.inputs.u)
graph.connect(source=pendulum.sensors.theta, target=layover.inputs.theta)
graph.render(source=layover.outputs.image, rate=rate)
graph.connect(source=pendulum.sensors.image, target=overlay.inputs.base_image)
graph.connect(source=reset.outputs.u, target=overlay.inputs.u)
graph.connect(source=pendulum.sensors.theta, target=overlay.inputs.theta)
graph.render(source=overlay.outputs.image, rate=rate)

# Make OdeBridge
bridge = eagerx.Bridge.make("OdeBridge", rate=rate)
Expand Down
170 changes: 84 additions & 86 deletions tutorials/pendulum/1_environment_creation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,17 @@
"\n",
"with $\\theta$ the angle w.r.t. upright position, $\\dot{\\theta}$ the angular velocity, $u$ the input voltage, $J$ the inertia, $m$ the mass, $g$ the gravitational constant, $l$ the length of the pendulum, $b$ the motor viscous friction constant, $K$ the motor constant and $R$ the electric resistance.\n",
"\n",
"<img src=\"./figures/pendulum.GIF\" width=\"480\" />"
]
},
{
"cell_type": "markdown",
"id": "74487e37-a1bc-4640-a9da-6f6cf27b4519",
"metadata": {},
"source": [
"<img src=\"./figures/pendulum.GIF\" width=\"480\" />\n",
"\n",
"\n",
"## Activate GPU (Colab only)\n",
"\n",
"When in Colab, you'll need to enable GPUs for the notebook:\n",
"\n",
"- Navigate to Edit→Notebook Settings\n",
"- select GPU from the Hardware Accelerator drop-down\n",
"\n",
"\n",
"## Notebook Setup\n",
"\n",
"In order to be able to run the code, we need to install the *eagerx_tutorials* package and ROS."
Expand Down Expand Up @@ -71,13 +74,7 @@
"# Setup interactive notebook\n",
"# Required in interactive notebooks only.\n",
"from eagerx_tutorials import helper\n",
"helper.setup_notebook()\n",
"env = None\n",
"\n",
"# Allows reloading of registered entites from changed files\n",
"# Required in interactive notebooks only.\n",
"%reload_ext autoreload\n",
"%autoreload 1"
"helper.setup_notebook()"
]
},
{
Expand Down Expand Up @@ -109,8 +106,8 @@
"name": "stdout",
"output_type": "stream",
"text": [
"... logging to /home/jelle/.ros/log/8a5aba50-cab1-11ec-9a64-612c3b44983f/roslaunch-jelle-Alienware-m15-R4-18483.log\n",
"\u001b[1mstarted roslaunch server http://145.94.217.36:45875/\u001b[0m\n",
"... logging to /home/jelle/.ros/log/91331988-d071-11ec-8414-1f5d9a0d084b/roslaunch-jelle-Alienware-m15-R4-7957.log\n",
"\u001b[1mstarted roslaunch server http://145.94.219.156:41309/\u001b[0m\n",
"ros_comm version 1.15.14\n",
"\n",
"\n",
Expand All @@ -124,17 +121,17 @@
"NODES\n",
"\n",
"auto-starting new master\n",
"\u001b[1mprocess[master]: started with pid [18537]\u001b[0m\n",
"\u001b[1mprocess[master]: started with pid [8025]\u001b[0m\n",
"\u001b[1mROS_MASTER_URI=http://localhost:11311\u001b[0m\n",
"\u001b[1msetting /run_id to 8a5aba50-cab1-11ec-9a64-612c3b44983f\u001b[0m\n",
"\u001b[1mprocess[rosout-1]: started with pid [18562]\u001b[0m\n",
"\u001b[1msetting /run_id to 91331988-d071-11ec-8414-1f5d9a0d084b\u001b[0m\n",
"\u001b[1mprocess[rosout-1]: started with pid [8052]\u001b[0m\n",
"started core service [/rosout]\n"
]
},
{
"data": {
"text/plain": [
"<roslaunch.parent.ROSLaunchParent at 0x7f97dbce6610>"
"<roslaunch.parent.ROSLaunchParent at 0x7f432935b040>"
]
},
"execution_count": 2,
Expand Down Expand Up @@ -422,112 +419,113 @@
"name": "stdout",
"output_type": "stream",
"text": [
"[INFO] [1651562443.303998]: Node \"/PendulumEnv/env/supervisor\" initialized.\n",
"[INFO] [1651562443.448747]: Node \"/PendulumEnv/bridge\" initialized.\n",
"[INFO] [1651562443.646331]: Node \"/PendulumEnv/environment\" initialized.\n",
"[INFO] [1651562443.721903]: Node \"/PendulumEnv/env/render\" initialized.\n",
"[INFO] [1651562443.826245]: Node \"/PendulumEnv/pendulum/theta\" initialized.\n",
"[INFO] [1651562443.850971]: Node \"/PendulumEnv/pendulum/dtheta\" initialized.\n",
"[INFO] [1651562443.890103]: START RENDERING!\n",
"Using cpu device\n",
"[INFO] [1652194674.650959]: Node \"/PendulumEnv/env/supervisor\" initialized.\n",
"[INFO] [1652194674.800871]: Node \"/PendulumEnv/bridge\" initialized.\n",
"[INFO] [1652194675.006478]: Node \"/PendulumEnv/environment\" initialized.\n",
"[INFO] [1652194675.100023]: Node \"/PendulumEnv/pendulum/theta\" initialized.\n",
"[INFO] [1652194675.171504]: Waiting for nodes \"['env/render']\" to be initialized.\n",
"[INFO] [1652194675.176602]: Node \"/PendulumEnv/pendulum/dtheta\" initialized.\n",
"Using cuda device\n",
"Wrapping the env with a `Monitor` wrapper\n",
"Wrapping the env in a DummyVecEnv.\n",
"[INFO] [1651562443.916023]: Adding object \"pendulum\" of type \"Pendulum\" to the simulator.\n",
"[INFO] [1651562443.930199]: Node \"/PendulumEnv/pendulum/x\" initialized.\n",
"[INFO] [1651562443.941389]: [pendulum/image] START RENDERING!\n",
"[INFO] [1651562443.947704]: Node \"/PendulumEnv/pendulum/image\" initialized.\n",
"[INFO] [1651562443.960112]: Node \"/PendulumEnv/pendulum/pendulum_actuator\" initialized.\n",
"[INFO] [1651562443.972254]: Node \"/PendulumEnv/pendulum/u\" initialized.\n",
"[INFO] [1651562444.023590]: Waiting for nodes \"['pendulum/image', 'pendulum/pendulum_actuator', 'pendulum/u']\" to be initialized.\n",
"[INFO] [1651562444.463799]: Nodes initialized.\n",
"[INFO] [1651562444.535006]: Pipelines initialized.\n",
"[INFO] [1652194675.278533]: Adding object \"pendulum\" of type \"Pendulum\" to the simulator.\n",
"[INFO] [1652194675.295990]: Node \"/PendulumEnv/pendulum/x\" initialized.\n",
"[INFO] [1652194675.312602]: [pendulum/image] START RENDERING!\n",
"[INFO] [1652194675.312833]: Node \"/PendulumEnv/pendulum/image\" initialized.\n",
"[INFO] [1652194675.328349]: Node \"/PendulumEnv/pendulum/pendulum_actuator\" initialized.\n",
"[INFO] [1652194675.342806]: Node \"/PendulumEnv/pendulum/u\" initialized.\n",
"[INFO] [1652194679.730279]: Nodes initialized.\n",
"[INFO] [1652194679.784066]: Pipelines initialized.\n",
"---------------------------------\n",
"| rollout/ | |\n",
"| ep_len_mean | 101 |\n",
"| ep_rew_mean | -948 |\n",
"| ep_rew_mean | -975 |\n",
"| time/ | |\n",
"| episodes | 4 |\n",
"| fps | 71 |\n",
"| time_elapsed | 5 |\n",
"| fps | 81 |\n",
"| time_elapsed | 4 |\n",
"| total_timesteps | 404 |\n",
"| train/ | |\n",
"| actor_loss | 17.8 |\n",
"| critic_loss | 10.2 |\n",
"| ent_coef | 0.916 |\n",
"| ent_coef_loss | -0.116 |\n",
"| actor_loss | 18.2 |\n",
"| critic_loss | 7.65 |\n",
"| ent_coef | 0.917 |\n",
"| ent_coef_loss | -0.113 |\n",
"| learning_rate | 0.0003 |\n",
"| n_updates | 303 |\n",
"---------------------------------\n",
"---------------------------------\n",
"| rollout/ | |\n",
"| ep_len_mean | 101 |\n",
"| ep_rew_mean | -915 |\n",
"| ep_rew_mean | -958 |\n",
"| time/ | |\n",
"| episodes | 8 |\n",
"| fps | 69 |\n",
"| time_elapsed | 11 |\n",
"| fps | 76 |\n",
"| time_elapsed | 10 |\n",
"| total_timesteps | 808 |\n",
"| train/ | |\n",
"| actor_loss | 31 |\n",
"| critic_loss | 9.61 |\n",
"| ent_coef | 0.832 |\n",
"| ent_coef_loss | -0.193 |\n",
"| actor_loss | 32.2 |\n",
"| critic_loss | 3.78 |\n",
"| ent_coef | 0.831 |\n",
"| ent_coef_loss | -0.221 |\n",
"| learning_rate | 0.0003 |\n",
"| n_updates | 707 |\n",
"---------------------------------\n",
"---------------------------------\n",
"| rollout/ | |\n",
"| ep_len_mean | 101 |\n",
"| ep_rew_mean | -907 |\n",
"| ep_rew_mean | -928 |\n",
"| time/ | |\n",
"| episodes | 12 |\n",
"| fps | 68 |\n",
"| time_elapsed | 17 |\n",
"| fps | 75 |\n",
"| time_elapsed | 16 |\n",
"| total_timesteps | 1212 |\n",
"| train/ | |\n",
"| actor_loss | 44.7 |\n",
"| critic_loss | 4.64 |\n",
"| ent_coef | 0.742 |\n",
"| ent_coef_loss | -0.385 |\n",
"| actor_loss | 46.2 |\n",
"| critic_loss | 3.51 |\n",
"| ent_coef | 0.74 |\n",
"| ent_coef_loss | -0.39 |\n",
"| learning_rate | 0.0003 |\n",
"| n_updates | 1111 |\n",
"---------------------------------\n",
"---------------------------------\n",
"| rollout/ | |\n",
"| ep_len_mean | 101 |\n",
"| ep_rew_mean | -889 |\n",
"| ep_rew_mean | -899 |\n",
"| time/ | |\n",
"| episodes | 16 |\n",
"| fps | 68 |\n",
"| time_elapsed | 23 |\n",
"| fps | 74 |\n",
"| time_elapsed | 21 |\n",
"| total_timesteps | 1616 |\n",
"| train/ | |\n",
"| actor_loss | 59.7 |\n",
"| critic_loss | 3.83 |\n",
"| ent_coef | 0.655 |\n",
"| ent_coef_loss | -0.481 |\n",
"| actor_loss | 61.2 |\n",
"| critic_loss | 5.8 |\n",
"| ent_coef | 0.657 |\n",
"| ent_coef_loss | -0.411 |\n",
"| learning_rate | 0.0003 |\n",
"| n_updates | 1515 |\n",
"---------------------------------\n",
"[INFO] [1651562470.290369]: [PendulumEnv][/PendulumEnv/bridge] Shutting down.\n",
"[INFO] [1651562470.291187]: [/PendulumEnv/bridge] Shutting down '/PendulumEnv/pendulum/x'.\n",
"[INFO] [1651562470.291922]: [/PendulumEnv/pendulum/x] Shutting down.\n",
"[INFO] [1651562470.341862]: [/PendulumEnv/bridge] Shutting down '/PendulumEnv/pendulum/image'.\n",
"[INFO] [1651562470.342609]: [/PendulumEnv/pendulum/image] Shutting down.\n",
"[INFO] [1651562470.343375]: [/PendulumEnv/bridge] Shutting down '/PendulumEnv/pendulum/pendulum_actuator'.\n",
"[INFO] [1651562470.343929]: [/PendulumEnv/pendulum/pendulum_actuator] Shutting down.\n",
"[INFO] [1651562470.344609]: [/PendulumEnv/bridge] Shutting down '/PendulumEnv/pendulum/u'.\n",
"[INFO] [1651562470.345255]: [/PendulumEnv/pendulum/u] Shutting down.\n",
"[INFO] [1651562470.345999]: [/PendulumEnv/bridge] Shutting down.\n",
"[INFO] [1651562470.347328]: [PendulumEnv][/PendulumEnv/env/render] Shutting down.\n",
"[INFO] [1651562470.347893]: [/PendulumEnv/env/render] Shutting down.\n",
"[INFO] [1651562470.350011]: [PendulumEnv][/PendulumEnv/pendulum/theta] Shutting down.\n",
"[INFO] [1651562470.350553]: [/PendulumEnv/pendulum/theta] Shutting down.\n",
"[INFO] [1651562470.351172]: [PendulumEnv][/PendulumEnv/pendulum/dtheta] Shutting down.\n",
"[INFO] [1651562470.351760]: [/PendulumEnv/pendulum/dtheta] Shutting down.\n",
"[INFO] [1651562470.352371]: [/PendulumEnv/env/supervisor] Shutting down.\n",
"[INFO] [1651562470.355477]: [/PendulumEnv/environment] Shutting down.\n",
"[INFO] [1651562470.357374]: Parameters under namespace \"/PendulumEnv\" deleted.\n"
"[INFO] [1652194703.616794]: [PendulumEnv] Send termination signal to '/PendulumEnv/env/render'.\n",
"[INFO] [1652194703.617589]: [PendulumEnv][/PendulumEnv/bridge] Shutting down.\n",
"[INFO] [1652194703.618204]: [/PendulumEnv/bridge] Shutting down '/PendulumEnv/pendulum/x'.\n",
"[INFO] [1652194703.619133]: [/PendulumEnv/pendulum/x] Shutting down.\n",
"[INFO] [1652194703.670342]: [/PendulumEnv/bridge] Shutting down '/PendulumEnv/pendulum/image'.\n",
"[INFO] [1652194703.670951]: [/PendulumEnv/pendulum/image] Shutting down.\n",
"[INFO] [1652194703.671552]: [/PendulumEnv/bridge] Shutting down '/PendulumEnv/pendulum/pendulum_actuator'.\n",
"[INFO] [1652194703.672078]: [/PendulumEnv/pendulum/pendulum_actuator] Shutting down.\n",
"[INFO] [1652194703.672690]: [/PendulumEnv/bridge] Shutting down '/PendulumEnv/pendulum/u'.\n",
"[INFO] [1652194703.673275]: [/PendulumEnv/pendulum/u] Shutting down.\n",
"[INFO] [1652194703.673898]: [/PendulumEnv/bridge] Shutting down.\n",
"[INFO] [1652194703.675176]: [PendulumEnv][/PendulumEnv/pendulum/theta] Shutting down.\n",
"[INFO] [1652194703.675735]: [/PendulumEnv/pendulum/theta] Shutting down.\n",
"[INFO] [1652194703.676324]: [PendulumEnv][/PendulumEnv/pendulum/dtheta] Shutting down.\n",
"[INFO] [1652194703.676883]: [/PendulumEnv/pendulum/dtheta] Shutting down.\n",
"[INFO] [1652194703.677540]: [/PendulumEnv/env/supervisor] Shutting down.\n",
"[INFO] [1652194703.680542]: [/PendulumEnv/environment] Shutting down.\n",
"[INFO] [1652194703.682569]: Parameters under namespace \"/PendulumEnv\" deleted.\n",
"[INFO] [1652194676.098388]: START RENDERING!\n",
"[INFO] [1652194676.113344]: Node \"/PendulumEnv/env/render\" initialized.\n",
"[INFO] [1652194703.617740]: [/PendulumEnv/env/render] Shutting down.\n",
"shutdown request: [/eagerx_core] Reason: new node registered with same name\n"
]
}
],
Expand Down Expand Up @@ -571,7 +569,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.13"
"version": "3.8.10"
}
},
"nbformat": 4,
Expand Down
Loading

0 comments on commit ab836c4

Please sign in to comment.