-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,160 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "initial_id", | ||
"metadata": { | ||
"collapsed": true | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"" | ||
] | ||
}, | ||
{ | ||
"metadata": { | ||
"ExecuteTime": { | ||
"end_time": "2024-07-26T20:27:26.357513Z", | ||
"start_time": "2024-07-26T20:27:26.339991Z" | ||
} | ||
}, | ||
"cell_type": "code", | ||
"source": [ | ||
"import mujoco\n", | ||
"import mediapy as media\n", | ||
"from IPython.display import clear_output\n", | ||
"import matplotlib.pyplot as plt\n", | ||
"\n", | ||
"chaotic_pendulum = \"\"\"\n", | ||
"<mujoco>\n", | ||
" <option timestep=\".001\">\n", | ||
" <flag energy=\"enable\" contact=\"disable\"/>\n", | ||
" </option>\n", | ||
"\n", | ||
" <default>\n", | ||
" <joint type=\"hinge\" axis=\"0 -1 0\"/>\n", | ||
" <geom type=\"capsule\" size=\".02\"/>\n", | ||
" </default>\n", | ||
"\n", | ||
" <worldbody>\n", | ||
" <light pos=\"0 -.4 1\"/>\n", | ||
" <camera name=\"fixed\" pos=\"0 -1 0\" xyaxes=\"1 0 0 0 0 1\"/>\n", | ||
" <body name=\"0\" pos=\"0 0 .2\">\n", | ||
" <joint name=\"root\"/>\n", | ||
" <geom fromto=\"-.2 0 0 .2 0 0\" rgba=\"1 1 0 1\"/>\n", | ||
" <geom fromto=\"0 0 0 0 0 -.25\" rgba=\"1 1 0 1\"/>\n", | ||
" <body name=\"1\" pos=\"-.2 0 0\">\n", | ||
" <joint/>\n", | ||
" <geom fromto=\"0 0 0 0 0 -.2\" rgba=\"1 0 0 1\"/>\n", | ||
" </body>\n", | ||
" <body name=\"2\" pos=\".2 0 0\">\n", | ||
" <joint/>\n", | ||
" <geom fromto=\"0 0 0 0 0 -.2\" rgba=\"0 1 0 1\"/>\n", | ||
" </body>\n", | ||
" <body name=\"3\" pos=\"0 0 -.25\">\n", | ||
" <joint/>\n", | ||
" <geom fromto=\"0 0 0 0 0 -.2\" rgba=\"0 0 1 1\"/>\n", | ||
" </body>\n", | ||
" </body>\n", | ||
" </worldbody>\n", | ||
"</mujoco>\n", | ||
"\"\"\"\n", | ||
"model = mujoco.MjModel.from_xml_string(chaotic_pendulum)\n", | ||
"data = mujoco.MjData(model)\n", | ||
"height = 480\n", | ||
"width = 640\n", | ||
"\n", | ||
"with mujoco.Renderer(model, height, width) as renderer:\n", | ||
" mujoco.mj_forward(model, data)\n", | ||
" renderer.update_scene(data, camera=\"fixed\")\n", | ||
"\n", | ||
" media.show_image(renderer.render())\n", | ||
" " | ||
], | ||
"id": "d2325b549cd7d10e", | ||
"outputs": [ | ||
{ | ||
"ename": "ModuleNotFoundError", | ||
"evalue": "No module named 'mujoco'", | ||
"output_type": "error", | ||
"traceback": [ | ||
"\u001B[0;31m---------------------------------------------------------------------------\u001B[0m", | ||
"\u001B[0;31mModuleNotFoundError\u001B[0m Traceback (most recent call last)", | ||
"Cell \u001B[0;32mIn[3], line 1\u001B[0m\n\u001B[0;32m----> 1\u001B[0m \u001B[38;5;28;01mimport\u001B[39;00m \u001B[38;5;21;01mmujoco\u001B[39;00m\n\u001B[1;32m 2\u001B[0m \u001B[38;5;28;01mimport\u001B[39;00m \u001B[38;5;21;01mmediapy\u001B[39;00m \u001B[38;5;28;01mas\u001B[39;00m \u001B[38;5;21;01mmedia\u001B[39;00m\n\u001B[1;32m 3\u001B[0m \u001B[38;5;28;01mfrom\u001B[39;00m \u001B[38;5;21;01mIPython\u001B[39;00m\u001B[38;5;21;01m.\u001B[39;00m\u001B[38;5;21;01mdisplay\u001B[39;00m \u001B[38;5;28;01mimport\u001B[39;00m clear_output\n", | ||
"\u001B[0;31mModuleNotFoundError\u001B[0m: No module named 'mujoco'" | ||
] | ||
} | ||
], | ||
"execution_count": 3 | ||
}, | ||
{ | ||
"metadata": { | ||
"ExecuteTime": { | ||
"end_time": "2024-07-26T20:27:27.341789Z", | ||
"start_time": "2024-07-26T20:27:27.340199Z" | ||
} | ||
}, | ||
"cell_type": "code", | ||
"source": "", | ||
"id": "a1e4e0175c70e866", | ||
"outputs": [], | ||
"execution_count": 3 | ||
}, | ||
{ | ||
"metadata": { | ||
"ExecuteTime": { | ||
"end_time": "2024-07-26T20:27:27.943871Z", | ||
"start_time": "2024-07-26T20:27:27.942200Z" | ||
} | ||
}, | ||
"cell_type": "code", | ||
"source": "", | ||
"id": "48cd10deb5af0b86", | ||
"outputs": [], | ||
"execution_count": 3 | ||
}, | ||
{ | ||
"metadata": { | ||
"ExecuteTime": { | ||
"end_time": "2024-07-26T20:27:28.142440Z", | ||
"start_time": "2024-07-26T20:27:28.138875Z" | ||
} | ||
}, | ||
"cell_type": "code", | ||
"source": "", | ||
"id": "1f98341c9c2caf8b", | ||
"outputs": [], | ||
"execution_count": 3 | ||
}, | ||
{ | ||
"metadata": {}, | ||
"cell_type": "code", | ||
"outputs": [], | ||
"execution_count": null, | ||
"source": "", | ||
"id": "c7736f9160249cc" | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 2 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython2", | ||
"version": "2.7.6" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |