diff --git a/examples/PD_controller.ipynb b/examples/PD_controller.ipynb index 7cf54591e..55a0874e1 100644 --- a/examples/PD_controller.ipynb +++ b/examples/PD_controller.ipynb @@ -15,17 +15,29 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 1, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "\u001b[34mjaxsim[51171]\u001b[0m \u001b[1;30mINFO\u001b[0m Running on [CpuDevice(id=0)]\n" + ] + } + ], "source": [ + "from IPython.display import clear_output\n", + "\n", "%pip install --upgrade -q \"jax[cuda12_pip]\" -f https://storage.googleapis.com/jax-releases/jax_cuda_releases.html\n", - "%pip install -q -e git+https://github.com/ami-iit/jaxsim@new_api#egg=jaxsim\n", + "%pip install -q git+https://github.com/ami-iit/jaxsim\n", + "clear_output()\n", "\n", "import jax\n", "import jax.numpy as jnp\n", "from jaxsim import logging\n", "\n", + "logging.set_logging_level(logging.LoggingLevel.INFO)\n", "logging.info(f\"Running on {jax.devices()}\")" ] }, @@ -38,13 +50,19 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 7, "metadata": {}, "outputs": [], "source": [ - "model_urdf_path = (\n", - " \"https://raw.githubusercontent.com/flferretti/jaxsim/examples/assets/cartpole.urdf\"\n", - ")" + "import requests\n", + "\n", + "url = \"https://raw.githubusercontent.com/flferretti/jaxsim/example/notebook/examples/assets/cartpole.urdf\"\n", + "\n", + "response = requests.get(url)\n", + "if response.status_code == 200:\n", + " model_urdf_path = response.text\n", + "else:\n", + " logging.error(\"Failed to fetch data\")" ] }, { @@ -56,20 +74,29 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 8, "metadata": {}, "outputs": [], "source": [ - "from jaxsim.high_level import Model" + "from jaxsim.high_level.model import Model" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 10, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "\u001b[34mjaxsim[51171]\u001b[0m \u001b[1;30mINFO\u001b[0m Combining the pose of base link 'rail' with the pose of joint 'world_to_rail'\n", + "\u001b[34mjaxsim[51171]\u001b[0m \u001b[1;30mINFO\u001b[0m The kinematic graph doesn't need to be reduced\n" + ] + } + ], "source": [ - "model = Model.build_from_model_description(model_description=urdf_path)" + "model = Model.build_from_model_description(model_description=model_urdf_path, is_urdf=True)" ] }, { @@ -81,9 +108,35 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 13, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "You can open the visualizer by visiting the following URL:\n", + "http://127.0.0.1:7002/static/\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "\u001b[34mmeshcat_viz[51171]\u001b[0m \u001b[1;30mWARNING\u001b[0m \u001b[33mFailed to find parent element 'world_to_rail' of frame 'world'\u001b[0m\n" + ] + }, + { + "data": { + "text/plain": [ + "'Cartpole'" + ] + }, + "execution_count": 13, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "try:\n", " from meshcat_viz.world import MeshcatWorld\n", @@ -95,10 +148,10 @@ "world.open()\n", "\n", "from IPython.display import IFrame\n", - "IFrame(src=\"https://127.0.0.1:7010/static/\", width='100%', height='500px')\n", + "IFrame(src=world.web_url, width='100%', height='500px')\n", "\n", "world.insert_model(\n", - " model_description=model_urdf_path, model_name=\"Cartpole\"\n", + " model_description=model_urdf_path, model_name=\"Cartpole\", is_urdf=True\n", ")" ] },