{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Test in Simulation" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "from Go2Py.sim.mujoco import Go2Sim\n", "from Go2Py.robot.fsm import FSM\n", "from Go2Py.robot.remote import KeyboardRemote\n", "from Go2Py.robot.safety import SafetyHypervisor" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "robot = Go2Sim()\n", "remote = KeyboardRemote()\n", "safety_hypervisor = SafetyHypervisor(robot)" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "robot.sitDownReset()\n", "fsm = FSM(robot, remote, safety_hypervisor)" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "fsm.close()\n", "robot.close()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Test on Real Robot" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "pygame 2.5.2 (SDL 2.28.2, Python 3.8.18)\n", "Hello from the pygame community. https://www.pygame.org/contribute.html\n" ] } ], "source": [ "from Go2Py.robot.interface.dds import GO2Real\n", "import time\n", "from Go2Py.robot.fsm import FSM\n", "from Go2Py.robot.remote import KeyboardRemote\n", "from Go2Py.robot.safety import SafetyHypervisor" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'q': array([-0.0441218 , 1.2594384 , -2.81978369, 0.05720162, 1.2381835 ,\n", " -2.77803254, -0.34687191, 1.26960623, -2.80896306, 0.28916293,\n", " 1.28592575, -2.83088923]),\n", " 'dq': array([ 0.03875524, -0.04650629, 0.00202201, 0.0155021 , -0.04263076,\n", " -0.0323522 , -0.00775105, -0.04650629, 0.00404402, -0.05813286,\n", " 0.03100419, -0.03841824]),\n", " 'ddq': array([0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]),\n", " 'tau_est': array([-0.07421485, 0.07421485, -0.23707521, -0.17316797, -0.04947656,\n", " 0.28449023, 0. , 0.02473828, -0.09483008, 0.04947656,\n", " -0.04947656, 0.09483008]),\n", " 'temperature': array([35., 31., 30., 33., 30., 30., 37., 31., 30., 37., 31., 30.])}" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "robot = GO2Real(mode='lowlevel')\n", "time.sleep(1)\n", "robot.getJointStates()" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "remote = KeyboardRemote()\n", "safety_hypervisor = SafetyHypervisor(robot)" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [], "source": [ "fsm = FSM(robot, remote, safety_hypervisor)" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "fsm.close()" ] } ], "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.8.18" } }, "nbformat": 4, "nbformat_minor": 2 }