{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "from Go2Py.sim.mujoco import Go2Sim\n", "import numpy as np" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "ename": "AttributeError", "evalue": "'Go2Sim' object has no attribute 'resetStanding'", "output_type": "error", "traceback": [ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", "\u001b[0;31mAttributeError\u001b[0m Traceback (most recent call last)", "Cell \u001b[0;32mIn[2], line 2\u001b[0m\n\u001b[1;32m 1\u001b[0m robot \u001b[38;5;241m=\u001b[39m Go2Sim()\n\u001b[0;32m----> 2\u001b[0m \u001b[43mrobot\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mresetStanding\u001b[49m()\n", "\u001b[0;31mAttributeError\u001b[0m: 'Go2Sim' object has no attribute 'resetStanding'" ] } ], "source": [ "robot = Go2Sim()\n", "robot.resetStanding()" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "ename": "NameError", "evalue": "name 'env' is not defined", "output_type": "error", "traceback": [ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", "\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)", "Cell \u001b[0;32mIn[3], line 7\u001b[0m\n\u001b[1;32m 5\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m i \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mrange\u001b[39m(\u001b[38;5;241m100000\u001b[39m):\n\u001b[1;32m 6\u001b[0m q,dq \u001b[38;5;241m=\u001b[39m robot\u001b[38;5;241m.\u001b[39mgetJointStates()\n\u001b[0;32m----> 7\u001b[0m tau \u001b[38;5;241m=\u001b[39m \u001b[38;5;241m20\u001b[39m\u001b[38;5;241m*\u001b[39mnp\u001b[38;5;241m.\u001b[39meye(\u001b[38;5;241m12\u001b[39m)\u001b[38;5;241m@\u001b[39m(\u001b[43menv\u001b[49m\u001b[38;5;241m.\u001b[39mq0 \u001b[38;5;241m-\u001b[39m q)\u001b[38;5;241m.\u001b[39mreshape(\u001b[38;5;241m12\u001b[39m,\u001b[38;5;241m1\u001b[39m)\n\u001b[1;32m 8\u001b[0m robot\u001b[38;5;241m.\u001b[39msetCommands(np\u001b[38;5;241m.\u001b[39mzeros(\u001b[38;5;241m12\u001b[39m), np\u001b[38;5;241m.\u001b[39mzeros(\u001b[38;5;241m12\u001b[39m), np\u001b[38;5;241m.\u001b[39mzeros(\u001b[38;5;241m12\u001b[39m), np\u001b[38;5;241m.\u001b[39mzeros(\u001b[38;5;241m12\u001b[39m), tau)\n\u001b[1;32m 9\u001b[0m env\u001b[38;5;241m.\u001b[39mstep()\n", "\u001b[0;31mNameError\u001b[0m: name 'env' is not defined" ] } ], "source": [ "import mujoco\n", "import time\n", "q,dq = robot.getJointStates()\n", "robot.sitDown()\n", "for i in range(100000):\n", " q,dq = robot.getJointStates()\n", " tau = 20*np.eye(12)@(robot.q0 - q).reshape(12,1)\n", " robot.setCommands(np.zeros(12), np.zeros(12), np.zeros(12), np.zeros(12), tau)\n", " env.step()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "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 }