-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #650 from StanfordVL/fix-primitives-2
Fix primitives for navigate, grasp and place
- Loading branch information
Showing
7 changed files
with
129 additions
and
136 deletions.
There are no files selected for viewing
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
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,64 @@ | ||
import os | ||
import yaml | ||
import numpy as np | ||
|
||
import omnigibson as og | ||
from omnigibson.macros import gm | ||
from omnigibson.action_primitives.starter_semantic_action_primitives import StarterSemanticActionPrimitives, StarterSemanticActionPrimitiveSet | ||
|
||
# Don't use GPU dynamics and use flatcache for performance boost | ||
# gm.USE_GPU_DYNAMICS = True | ||
# gm.ENABLE_FLATCACHE = True | ||
|
||
def execute_controller(ctrl_gen, env): | ||
for action in ctrl_gen: | ||
env.step(action) | ||
|
||
def main(): | ||
""" | ||
Demonstrates how to use the action primitives to pick and place an object in a crowded scene. | ||
It loads Rs_int with a Fetch robot, and the robot picks and places an apple. | ||
""" | ||
# Load the config | ||
config_filename = os.path.join(og.example_config_path, "fetch_primitives.yaml") | ||
config = yaml.load(open(config_filename, "r"), Loader=yaml.FullLoader) | ||
|
||
# Update it to run a grocery shopping task | ||
config["scene"]["scene_model"] = "Rs_int" | ||
config["scene"]["not_load_object_categories"] = ["ceilings"] | ||
config["objects"] = [ | ||
{ | ||
"type": "DatasetObject", | ||
"name": "apple", | ||
"category": "apple", | ||
"model": "agveuv", | ||
"position": [-0.3, -1.1, 0.5], | ||
"orientation": [0, 0, 0, 1] | ||
}, | ||
] | ||
|
||
# Load the environment | ||
env = og.Environment(configs=config) | ||
scene = env.scene | ||
robot = env.robots[0] | ||
|
||
# Allow user to move camera more easily | ||
og.sim.enable_viewer_camera_teleoperation() | ||
|
||
controller = StarterSemanticActionPrimitives(env, enable_head_tracking=False) | ||
cabinet = scene.object_registry("name", "bottom_cabinet_slgzfc_0") | ||
apple = scene.object_registry("name", "apple") | ||
|
||
# Grasp apple | ||
print("Executing controller") | ||
execute_controller(controller.apply_ref(StarterSemanticActionPrimitiveSet.GRASP, apple), env) | ||
print("Finished executing grasp") | ||
|
||
# Place on cabinet | ||
print("Executing controller") | ||
execute_controller(controller.apply_ref(StarterSemanticActionPrimitiveSet.PLACE_ON_TOP, cabinet), env) | ||
print("Finished executing place") | ||
|
||
if __name__ == "__main__": | ||
main() |
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
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.