def main():
"""
Demonstrates how to use the action primitives to pick and place an object in an empty scene.
It loads Rs_int with a robot, and the robot picks and places a bottle of cologne.
"""
# Load the config
config_filename = os.path.join(og.example_config_path, "tiago_primitives.yaml")
config = yaml.load(open(config_filename, "r"), Loader=yaml.FullLoader)
# Update it to create a custom environment and run some actions
config["scene"]["scene_model"] = "Rs_int"
config["scene"]["load_object_categories"] = ["floors", "ceilings", "walls", "coffee_table"]
config["objects"] = [
{
"type": "DatasetObject",
"name": "cologne",
"category": "bottle_of_cologne",
"model": "lyipur",
"position": [-0.3, -0.8, 0.5],
"orientation": [0, 0, 0, 1],
},
{
"type": "DatasetObject",
"name": "table",
"category": "breakfast_table",
"model": "rjgmmy",
"scale": [0.3, 0.3, 0.3],
"position": [-0.7, 0.5, 0.2],
"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)
# Grasp of cologne
grasp_obj = scene.object_registry("name", "cologne")
print("Executing controller")
execute_controller(controller.apply_ref(StarterSemanticActionPrimitiveSet.GRASP, grasp_obj), env)
print("Finished executing grasp")
# Place cologne on another table
print("Executing controller")
table = scene.object_registry("name", "table")
execute_controller(controller.apply_ref(StarterSemanticActionPrimitiveSet.PLACE_ON_TOP, table), env)
print("Finished executing place")