-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GNN-dynamic models + GNN-dynamic-planner
- Loading branch information
Showing
19 changed files
with
285 additions
and
28 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,195 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": { | ||
"pycharm": { | ||
"name": "#%% md\n" | ||
} | ||
}, | ||
"source": [ | ||
"> [GNN-Dynamic](https://arxiv.org/abs/2210.08408) - it plans a trajectory by prioritizing the edge to explore based on a Graph Neural Network heuristic function in a dynamic environment." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"metadata": { | ||
"pycharm": { | ||
"name": "#%%\n" | ||
} | ||
}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"/Users/ruipeng/Desktop/lemp\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"cd .." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"metadata": { | ||
"collapsed": false, | ||
"jupyter": { | ||
"outputs_hidden": false | ||
}, | ||
"pycharm": { | ||
"name": "#%%\n" | ||
} | ||
}, | ||
"outputs": [ | ||
{ | ||
"name": "stderr", | ||
"output_type": "stream", | ||
"text": [ | ||
"pybullet build time: Mar 16 2022 13:26:26\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"from environment.dynamic.simple2arm_env import Simple2ArmEnv\n", | ||
"from objects.dynamic_object import DynamicObject\n", | ||
"from robot.abstract_robot import DynamicRobotFactory\n", | ||
"from objects.trajectory import WaypointLinearTrajectory\n", | ||
"from robot.simple2arm_robot import Simple2ArmRobot\n", | ||
"from planner.sipp_planner import SippPlanner\n", | ||
"from utils.utils import seed_everything\n", | ||
"\n", | ||
"import numpy as np" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"outputs": [], | ||
"source": [ | ||
"waypoints = np.linspace(0, np.pi/4, 40).tolist()\n", | ||
"waypoints = [np.array([p,p]) for p in waypoints]\n", | ||
"traj = WaypointLinearTrajectory(waypoints=waypoints)\n", | ||
"robot = Simple2ArmRobot(base_position=(1, 1, 0), base_orientation=(0, 0, 0, 1))\n", | ||
"objs = DynamicObject(item=robot, trajectory=traj)\n", | ||
"\n", | ||
"env = Simple2ArmEnv(objects=[objs])\n", | ||
"num_samples = 1000\n", | ||
"max_num_samples = 2000" | ||
], | ||
"metadata": { | ||
"collapsed": false, | ||
"pycharm": { | ||
"name": "#%%\n" | ||
} | ||
} | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"outputs": [], | ||
"source": [ | ||
"# visualize environment\n", | ||
"%matplotlib inline\n", | ||
"import matplotlib.pyplot as plt\n", | ||
"env.load()\n", | ||
"plt.imshow(env.render())\n", | ||
"plt.show()" | ||
], | ||
"metadata": { | ||
"collapsed": false, | ||
"pycharm": { | ||
"name": "#%%\n" | ||
} | ||
} | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"outputs": [], | ||
"source": [ | ||
"from planner.learned.GNN_dynamic_planner import GNNDynamicPlanner" | ||
], | ||
"metadata": { | ||
"collapsed": false, | ||
"pycharm": { | ||
"name": "#%%\n" | ||
} | ||
} | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"outputs": [], | ||
"source": [ | ||
"weights_path = ['data/weights/dynamic/2arms/weights_gnn.pt','data/weights/dynamic/2arms/weights_head.pt']" | ||
], | ||
"metadata": { | ||
"collapsed": false, | ||
"pycharm": { | ||
"name": "#%%\n" | ||
} | ||
} | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"outputs": [], | ||
"source": [ | ||
"start, goal = np.array([0.] * 2), np.array([np.pi*7/8, 0])\n", | ||
"# start, goal = np.array([0.] * 2), np.array([0, 0])\n", | ||
"seed_everything(42)\n", | ||
"model_args = dict(config_size=env.robot.config_dim, embed_size=32, obs_size=9)\n", | ||
"planner = GNNDynamicPlanner(num_samples=num_samples, max_num_samples=max_num_samples, model_args=model_args, use_bctc=False, stop_when_success=True)\n", | ||
"# load trained weights\n", | ||
"planner.load_model(weights_path)\n", | ||
"result = planner.plan(env, start, goal, timeout=('time', 1000))\n", | ||
"if result.solution:\n", | ||
" print('success', result)\n", | ||
"else:\n", | ||
" print('fail')" | ||
], | ||
"metadata": { | ||
"collapsed": false, | ||
"pycharm": { | ||
"name": "#%%\n" | ||
} | ||
} | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"pycharm": { | ||
"name": "#%%\n" | ||
} | ||
}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "PyCharm (GNN-Dynamic)", | ||
"language": "python", | ||
"name": "pycharm-e8cae0ef" | ||
}, | ||
"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.7" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 4 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.