Go2Py_SIM/examples/04-lowlevel-control-fsm.ipynb

124 lines
2.3 KiB
Plaintext
Raw Normal View History

{
"cells": [
2024-05-05 08:09:01 +08:00
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Test in Simulation"
]
},
{
"cell_type": "code",
2024-03-18 11:36:53 +08:00
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from Go2Py.sim.mujoco import Go2Sim\n",
2024-05-05 08:09:01 +08:00
"from Go2Py.robot.fsm import FSM\n",
"from Go2Py.robot.remote import KeyboardRemote\n",
"from Go2Py.robot.safety import SafetyHypervisor"
]
},
{
"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": [
2024-03-16 10:39:10 +08:00
"robot = Go2Sim()\n",
2024-05-05 08:09:01 +08:00
"remote = KeyboardRemote()\n",
"safety_hypervisor = SafetyHypervisor(robot)"
]
},
{
"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 08:09:01 +08:00
"robot.sitDownReset()\n",
"fsm = FSM(robot, remote, safety_hypervisor)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"fsm.close()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Test on Real Robot"
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": [
2024-05-05 08:09:01 +08:00
"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": null,
"metadata": {},
"outputs": [],
"source": [
2024-05-05 08:09:01 +08:00
"robot = GO2Real(mode='lowlevel')\n",
"remote = KeyboardRemote()\n",
"safety_hypervisor = SafetyHypervisor(robot)"
2024-03-16 12:27:06 +08:00
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
2024-05-05 08:09:01 +08:00
"fsm = FSM(robot, remote, safety)"
]
},
{
"cell_type": "code",
2024-03-18 11:36:53 +08:00
"execution_count": null,
"metadata": {},
2024-03-18 11:36:53 +08:00
"outputs": [],
"source": [
2024-05-05 08:09:01 +08:00
"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",
2024-05-05 08:09:01 +08:00
"version": "3.8.18"
}
},
"nbformat": 4,
"nbformat_minor": 2
}