Go2Py_SIM/examples/00-robot-interface.ipynb

112 lines
2.2 KiB
Plaintext
Raw Normal View History

{
"cells": [
2024-05-05 08:09:01 +08:00
{
"cell_type": "markdown",
"metadata": {},
"source": [
2024-05-05 09:14:41 +08:00
"# Lowlevel Control"
2024-05-05 08:09:01 +08:00
]
},
{
"cell_type": "code",
2024-03-18 11:36:53 +08:00
"execution_count": null,
"metadata": {},
2024-03-16 10:43:58 +08:00
"outputs": [],
"source": [
"from Go2Py.robot.interface import GO2Real\n",
2024-05-05 09:14:41 +08:00
"import time\n",
"robot = GO2Real(mode='lowlevel')"
]
},
{
"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": [
2024-05-05 09:14:41 +08:00
"robot.getJointStates()"
2024-05-05 08:09:01 +08:00
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
2024-05-05 09:14:41 +08:00
"import numpy as np\n",
"import time\n",
"for i in range(1000000):\n",
" q = np.zeros(12) \n",
" dq = np.zeros(12)\n",
" kp = np.ones(12)*0.0\n",
" kd = np.ones(12)*0.0\n",
" tau = np.zeros(12)\n",
" tau[0] = 0.0\n",
" robot.setCommands(q, dq, kp, kd, tau)\n",
" time.sleep(0.01) "
2024-05-05 08:09:01 +08:00
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
2024-05-05 09:14:41 +08:00
"# Highlevel Control"
2024-03-16 10:39:10 +08:00
]
},
{
"cell_type": "code",
2024-05-05 12:11:18 +08:00
"execution_count": 2,
2024-03-16 10:39:10 +08:00
"metadata": {},
2024-05-05 12:11:18 +08:00
"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"
]
}
],
2024-03-16 12:27:06 +08:00
"source": [
"from Go2Py.robot.interface import GO2Real\n",
2024-05-05 08:09:01 +08:00
"import time\n",
2024-05-05 09:14:41 +08:00
"robot = GO2Real(mode='highlevel')"
]
2024-05-05 12:11:18 +08:00
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"import time\n",
"for i in range(200):\n",
" robot.setCommandsHigh(0,0,0.2)\n",
" time.sleep(0.01) "
]
}
],
"metadata": {
"kernelspec": {
2024-05-05 09:14:41 +08:00
"display_name": "Python 3",
"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.10.12"
}
},
"nbformat": 4,
2024-05-05 09:14:41 +08:00
"nbformat_minor": 4
}