Go2Py_SIM/examples/mujoco_test.ipynb

72 lines
1.4 KiB
Plaintext
Raw Normal View History

{
"cells": [
{
"cell_type": "code",
2024-03-16 10:43:58 +08:00
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from Go2Py.sim.mujoco import Go2Sim\n",
"import numpy as np"
]
},
{
"cell_type": "code",
2024-03-16 10:43:58 +08:00
"execution_count": null,
"metadata": {},
2024-03-16 10:43:58 +08:00
"outputs": [],
"source": [
2024-03-16 10:39:10 +08:00
"robot = Go2Sim()\n",
2024-03-16 10:43:58 +08:00
"robot.standUp()"
]
},
{
"cell_type": "code",
2024-03-16 10:43:58 +08:00
"execution_count": null,
2024-03-16 10:39:10 +08:00
"metadata": {},
2024-03-16 10:43:58 +08:00
"outputs": [],
2024-03-16 10:39:10 +08:00
"source": [
"import mujoco\n",
"import time\n",
"q,dq = robot.getJointStates()\n",
2024-03-16 12:27:06 +08:00
"robot.standUp()\n",
2024-03-16 10:39:10 +08:00
"for i in range(100000):\n",
" q,dq = robot.getJointStates()\n",
2024-03-16 10:41:55 +08:00
" tau = 20*np.eye(12)@(robot.q0 - q).reshape(12,1)\n",
2024-03-16 10:39:10 +08:00
" robot.setCommands(np.zeros(12), np.zeros(12), np.zeros(12), np.zeros(12), tau)\n",
2024-03-16 10:43:58 +08:00
" robot.step()"
2024-03-16 10:39:10 +08:00
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
2024-03-16 12:27:06 +08:00
"source": [
"robot.getFootContact(), robot.getIMU()"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "b1-env",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.18"
}
},
"nbformat": 4,
"nbformat_minor": 2
}