├── .coveragerc ├── .github ├── CODEOWNERS └── workflows │ └── predicators.yml ├── .gitignore ├── .isort.cfg ├── .predicators_pylintrc ├── .style.yapf ├── LICENSE.md ├── README.md ├── mypy.ini ├── predicators ├── __init__.py ├── approaches │ ├── __init__.py │ ├── active_sampler_learning_approach.py │ ├── base_approach.py │ ├── bilevel_planning_approach.py │ ├── bridge_policy_approach.py │ ├── documentation │ │ └── grammar_search_invention_approach.md │ ├── gnn_action_policy_approach.py │ ├── gnn_approach.py │ ├── gnn_metacontroller_approach.py │ ├── gnn_option_policy_approach.py │ ├── grammar_search_invention_approach.py │ ├── interactive_learning_approach.py │ ├── llm_base_renaming_approach.py │ ├── llm_bilevel_planning_approach.py │ ├── llm_open_loop_approach.py │ ├── llm_option_renaming_approach.py │ ├── llm_predicate_renaming_approach.py │ ├── llm_syntax_renaming_approach.py │ ├── maple_q_approach.py │ ├── noisy_button_wrapper_approach.py │ ├── nsrt_learning_approach.py │ ├── nsrt_metacontroller_approach.py │ ├── nsrt_rl_approach.py │ ├── online_nsrt_learning_approach.py │ ├── online_pg3_approach.py │ ├── oracle_approach.py │ ├── pg3_analogy_approach.py │ ├── pg3_approach.py │ ├── pg4_approach.py │ ├── random_actions_approach.py │ ├── random_options_approach.py │ ├── refinement_estimation_approach.py │ ├── sme_pg3_analogy_approach.py │ ├── vlm_open_loop_approach.py │ └── vlm_planning_prompts │ │ ├── few_shot.txt │ │ └── no_few_shot.txt ├── args.py ├── bridge_policies │ ├── __init__.py │ ├── base_bridge_policy.py │ ├── ldl_bridge_policy.py │ ├── learned_ldl_bridge_policy.py │ └── oracle_bridge_policy.py ├── cogman.py ├── competence_models.py ├── datasets │ ├── __init__.py │ ├── demo_only.py │ ├── demo_replay.py │ ├── generate_atom_trajs_with_vlm.py │ ├── ground_atom_data.py │ └── vlm_input_data_prompts │ │ ├── atom_labelling │ │ ├── double_check_prompt_prev_labels.txt │ │ ├── img_option_diffs.txt │ │ ├── img_option_diffs_label_history.txt │ │ ├── img_option_diffs_label_history_burger.txt │ │ ├── img_option_diffs_label_history_crops.txt │ │ ├── per_scene_cot.txt │ │ └── per_scene_naive.txt │ │ ├── atom_proposal │ │ ├── naive_each_step.txt │ │ ├── naive_whole_traj.txt │ │ ├── options_labels_whole_traj_diverse.txt │ │ └── options_labels_whole_traj_specific.txt │ │ └── vision_api │ │ ├── api_oo_state.txt │ │ ├── api_sym_predicate.txt │ │ └── prompt.outline ├── envs │ ├── __init__.py │ ├── assets │ │ ├── imgs │ │ │ ├── bottom_bun.png │ │ │ ├── cheese.png │ │ │ ├── cooked_patty.png │ │ │ ├── cut_lettuce.png │ │ │ ├── cutting_board.png │ │ │ ├── floorwood.png │ │ │ ├── grill.png │ │ │ ├── raw_patty.png │ │ │ ├── realistic_cooked_patty.png │ │ │ ├── realistic_cooked_patty_full.png │ │ │ ├── realistic_raw_patty.png │ │ │ ├── realistic_raw_patty_full.png │ │ │ ├── robot.png │ │ │ ├── robot_down.png │ │ │ ├── robot_left.png │ │ │ ├── robot_right.png │ │ │ ├── robot_up.png │ │ │ ├── sliced_tomato.png │ │ │ ├── top_bun.png │ │ │ ├── uncut_lettuce.png │ │ │ └── whole_tomato.png │ │ ├── pddl │ │ │ ├── blocks │ │ │ │ ├── domain.pddl │ │ │ │ ├── task1.pddl │ │ │ │ ├── task10.pddl │ │ │ │ ├── task11.pddl │ │ │ │ ├── task12.pddl │ │ │ │ ├── task13.pddl │ │ │ │ ├── task14.pddl │ │ │ │ ├── task15.pddl │ │ │ │ ├── task16.pddl │ │ │ │ ├── task17.pddl │ │ │ │ ├── task18.pddl │ │ │ │ ├── task19.pddl │ │ │ │ ├── task2.pddl │ │ │ │ ├── task20.pddl │ │ │ │ ├── task21.pddl │ │ │ │ ├── task22.pddl │ │ │ │ ├── task23.pddl │ │ │ │ ├── task24.pddl │ │ │ │ ├── task25.pddl │ │ │ │ ├── task26.pddl │ │ │ │ ├── task27.pddl │ │ │ │ ├── task28.pddl │ │ │ │ ├── task29.pddl │ │ │ │ ├── task3.pddl │ │ │ │ ├── task30.pddl │ │ │ │ ├── task31.pddl │ │ │ │ ├── task32.pddl │ │ │ │ ├── task33.pddl │ │ │ │ ├── task34.pddl │ │ │ │ ├── task35.pddl │ │ │ │ ├── task4.pddl │ │ │ │ ├── task5.pddl │ │ │ │ ├── task6.pddl │ │ │ │ ├── task7.pddl │ │ │ │ ├── task8.pddl │ │ │ │ └── task9.pddl │ │ │ ├── delivery │ │ │ │ └── domain.pddl │ │ │ ├── ferry │ │ │ │ └── domain.pddl │ │ │ ├── forest │ │ │ │ └── domain.pddl │ │ │ ├── gripper │ │ │ │ ├── domain.pddl │ │ │ │ └── prefixed_domain.pddl │ │ │ ├── miconic │ │ │ │ └── domain.pddl │ │ │ └── spannerlearning │ │ │ │ └── domain.pddl │ │ └── urdf │ │ │ ├── fetch_description │ │ │ ├── meshes │ │ │ │ ├── base_link.dae │ │ │ │ ├── base_link_collision.STL │ │ │ │ ├── base_link_uv.png │ │ │ │ ├── bellows_link.STL │ │ │ │ ├── bellows_link_collision.STL │ │ │ │ ├── elbow_flex_link.dae │ │ │ │ ├── elbow_flex_link_collision.STL │ │ │ │ ├── elbow_flex_uv.png │ │ │ │ ├── estop_link.STL │ │ │ │ ├── forearm_roll_link.dae │ │ │ │ ├── forearm_roll_link_collision.STL │ │ │ │ ├── forearm_roll_uv.png │ │ │ │ ├── gripper_link.STL │ │ │ │ ├── gripper_link.dae │ │ │ │ ├── gripper_uv.png │ │ │ │ ├── head_pan_link.dae │ │ │ │ ├── head_pan_link_collision.STL │ │ │ │ ├── head_pan_uv.png │ │ │ │ ├── head_tilt_link.dae │ │ │ │ ├── head_tilt_link_collision.STL │ │ │ │ ├── head_tilt_uv.png │ │ │ │ ├── l_gripper_finger_link.STL │ │ │ │ ├── l_wheel_link.STL │ │ │ │ ├── l_wheel_link_collision.STL │ │ │ │ ├── laser_link.STL │ │ │ │ ├── r_gripper_finger_link.STL │ │ │ │ ├── r_wheel_link.STL │ │ │ │ ├── r_wheel_link_collision.STL │ │ │ │ ├── shoulder_lift_link.dae │ │ │ │ ├── shoulder_lift_link_collision.STL │ │ │ │ ├── shoulder_lift_uv.png │ │ │ │ ├── shoulder_pan_link.dae │ │ │ │ ├── shoulder_pan_link_collision.STL │ │ │ │ ├── shoulder_pan_uv.png │ │ │ │ ├── torso_fixed_link.STL │ │ │ │ ├── torso_fixed_link.dae │ │ │ │ ├── torso_fixed_uv.png │ │ │ │ ├── torso_lift_link.dae │ │ │ │ ├── torso_lift_link_collision.STL │ │ │ │ ├── torso_lift_uv.png │ │ │ │ ├── upperarm_roll_link.dae │ │ │ │ ├── upperarm_roll_link_collision.STL │ │ │ │ ├── upperarm_roll_uv.png │ │ │ │ ├── wrist_flex_link.dae │ │ │ │ ├── wrist_flex_link_collision.STL │ │ │ │ ├── wrist_flex_uv.png │ │ │ │ ├── wrist_roll_link.dae │ │ │ │ ├── wrist_roll_link_collision.STL │ │ │ │ └── wrist_roll_uv.png │ │ │ └── robots │ │ │ │ └── fetch.urdf │ │ │ ├── franka_description │ │ │ ├── CMakeLists.txt │ │ │ ├── mainpage.dox │ │ │ ├── meshes │ │ │ │ ├── collision │ │ │ │ │ ├── finger.stl │ │ │ │ │ ├── hand.stl │ │ │ │ │ ├── link0.stl │ │ │ │ │ ├── link1.stl │ │ │ │ │ ├── link2.stl │ │ │ │ │ ├── link3.stl │ │ │ │ │ ├── link4.stl │ │ │ │ │ ├── link5.stl │ │ │ │ │ ├── link6.stl │ │ │ │ │ └── link7.stl │ │ │ │ └── visual │ │ │ │ │ ├── finger.dae │ │ │ │ │ ├── hand.dae │ │ │ │ │ ├── link0.dae │ │ │ │ │ ├── link1.dae │ │ │ │ │ ├── link2.dae │ │ │ │ │ ├── link3.dae │ │ │ │ │ ├── link4.dae │ │ │ │ │ ├── link5.dae │ │ │ │ │ ├── link6.dae │ │ │ │ │ └── link7.dae │ │ │ ├── package.xml │ │ │ ├── robots │ │ │ │ ├── hand.dae │ │ │ │ ├── hand.urdf │ │ │ │ ├── hand.urdf.xacro │ │ │ │ ├── hand.xacro │ │ │ │ ├── panda_arm.backup.dae │ │ │ │ ├── panda_arm.dae │ │ │ │ ├── panda_arm.urdf │ │ │ │ ├── panda_arm.urdf.xacro │ │ │ │ ├── panda_arm.xacro │ │ │ │ ├── panda_arm_hand.backup.dae │ │ │ │ ├── panda_arm_hand.dae │ │ │ │ ├── panda_arm_hand.urdf │ │ │ │ └── panda_arm_hand.urdf.xacro │ │ │ └── rosdoc.yaml │ │ │ ├── plane.obj │ │ │ ├── plane.urdf │ │ │ ├── table.obj │ │ │ ├── table.png │ │ │ └── table.urdf │ ├── ball_and_cup_sticky_table.py │ ├── base_env.py │ ├── blocks.py │ ├── burger.py │ ├── cluttered_table.py │ ├── coffee.py │ ├── cover.py │ ├── doors.py │ ├── exit_garage.py │ ├── grid_row.py │ ├── kitchen.py │ ├── narrow_passage.py │ ├── noisy_button.py │ ├── painting.py │ ├── pddl_env.py │ ├── pddl_procedural_generation.py │ ├── playroom.py │ ├── pybullet_blocks.py │ ├── pybullet_cover.py │ ├── pybullet_env.py │ ├── repeated_nextto.py │ ├── repeated_nextto_painting.py │ ├── sandwich.py │ ├── satellites.py │ ├── screws.py │ ├── sokoban.py │ ├── stick_button.py │ ├── sticky_table.py │ ├── tools.py │ ├── touch_point.py │ └── vlm_envs.py ├── execution_monitoring │ ├── __init__.py │ ├── base_execution_monitor.py │ ├── expected_atoms_monitor.py │ ├── mpc_execution_monitor.py │ └── trivial_execution_monitor.py ├── explorers │ ├── __init__.py │ ├── active_sampler_explorer.py │ ├── base_explorer.py │ ├── bilevel_planning_explorer.py │ ├── exploit_bilevel_planning_explorer.py │ ├── glib_explorer.py │ ├── greedy_lookahead_explorer.py │ ├── maple_q_explorer.py │ ├── no_explore_explorer.py │ ├── random_actions_explorer.py │ ├── random_nsrts_explorer.py │ └── random_options_explorer.py ├── gnn │ ├── __init__.py │ ├── gnn.py │ └── gnn_utils.py ├── ground_truth_models │ ├── __init__.py │ ├── ball_and_cup_sticky_table │ │ ├── __init__.py │ │ ├── nsrts.py │ │ └── options.py │ ├── blocks │ │ ├── __init__.py │ │ ├── nsrts.py │ │ └── options.py │ ├── burger │ │ ├── __init__.py │ │ ├── nsrts.py │ │ └── options.py │ ├── cluttered_table │ │ ├── __init__.py │ │ ├── nsrts.py │ │ └── options.py │ ├── coffee │ │ ├── __init__.py │ │ ├── nsrts.py │ │ └── options.py │ ├── cover │ │ ├── __init__.py │ │ ├── nsrts.py │ │ └── options.py │ ├── doors │ │ ├── __init__.py │ │ ├── nsrts.py │ │ └── options.py │ ├── exit_garage │ │ ├── __init__.py │ │ ├── nsrts.py │ │ └── options.py │ ├── grid_row │ │ ├── __init__.py │ │ ├── nsrts.py │ │ └── options.py │ ├── ice_tea_making │ │ ├── __init__.py │ │ ├── nsrts.py │ │ └── options.py │ ├── kitchen │ │ ├── __init__.py │ │ ├── nsrts.py │ │ └── options.py │ ├── narrow_passage │ │ ├── __init__.py │ │ ├── nsrts.py │ │ └── options.py │ ├── noisy_button │ │ ├── __init__.py │ │ ├── nsrts.py │ │ └── options.py │ ├── painting │ │ ├── __init__.py │ │ ├── ldl_bridge_policy.py │ │ ├── nsrts.py │ │ ├── options.py │ │ └── painting_bridge_policy.ldl │ ├── pddl_env │ │ ├── __init__.py │ │ ├── nsrts.py │ │ └── options.py │ ├── playroom │ │ ├── __init__.py │ │ ├── nsrts.py │ │ └── options.py │ ├── repeated_nextto │ │ ├── __init__.py │ │ ├── nsrts.py │ │ └── options.py │ ├── sandwich │ │ ├── __init__.py │ │ ├── nsrts.py │ │ └── options.py │ ├── satellites │ │ ├── __init__.py │ │ ├── nsrts.py │ │ └── options.py │ ├── screws │ │ ├── __init__.py │ │ ├── nsrts.py │ │ └── options.py │ ├── sokoban │ │ ├── __init__.py │ │ ├── nsrts.py │ │ └── options.py │ ├── stick_button │ │ ├── __init__.py │ │ ├── ldl_bridge_policy.py │ │ ├── nsrts.py │ │ ├── options.py │ │ └── stick_button_bridge_policy.ldl │ ├── sticky_table │ │ ├── __init__.py │ │ ├── nsrts.py │ │ └── options.py │ ├── tools │ │ ├── __init__.py │ │ ├── nsrts.py │ │ └── options.py │ ├── touch_open │ │ ├── __init__.py │ │ ├── nsrts.py │ │ └── options.py │ └── touch_point │ │ ├── __init__.py │ │ ├── nsrts.py │ │ └── options.py ├── main.py ├── ml_models.py ├── nsrt_learning │ ├── __init__.py │ ├── nsrt_learning_main.py │ ├── option_learning.py │ ├── sampler_learning.py │ ├── segmentation.py │ └── strips_learning │ │ ├── __init__.py │ │ ├── base_strips_learner.py │ │ ├── clustering_learner.py │ │ ├── gen_to_spec_learner.py │ │ ├── llm_op_learning_prompts │ │ └── naive_no_examples.txt │ │ ├── llm_strips_learner.py │ │ ├── oracle_clustering_learner.py │ │ ├── oracle_learner.py │ │ └── pnad_search_learner.py ├── option_model.py ├── perception │ ├── __init__.py │ ├── base_perceiver.py │ ├── kitchen_perceiver.py │ ├── sokoban_perceiver.py │ └── trivial_perceiver.py ├── planning.py ├── predicate_search_score_functions.py ├── pretrained_model_interface.py ├── pybullet_helpers │ ├── __init__.py │ ├── camera.py │ ├── controllers.py │ ├── geometry.py │ ├── ikfast │ │ ├── __init__.py │ │ ├── load.py │ │ └── utils.py │ ├── inverse_kinematics.py │ ├── joint.py │ ├── link.py │ ├── motion_planning.py │ └── robots │ │ ├── __init__.py │ │ ├── fetch.py │ │ ├── panda.py │ │ └── single_arm.py ├── refinement_estimators │ ├── __init__.py │ ├── base_refinement_estimator.py │ ├── cnn_refinement_estimator.py │ ├── gnn_refinement_estimator.py │ ├── oracle_refinement_estimator.py │ ├── per_skeleton_estimator.py │ └── tabular_refinement_estimator.py ├── settings.py ├── structs.py ├── teacher.py ├── third_party │ ├── fast_downward_translator │ │ ├── README.md │ │ ├── axiom_rules.py │ │ ├── build_model.py │ │ ├── constraints.py │ │ ├── fact_groups.py │ │ ├── graph.py │ │ ├── greedy_join.py │ │ ├── instantiate.py │ │ ├── invariant_finder.py │ │ ├── invariants.py │ │ ├── normalize.py │ │ ├── pddl │ │ │ ├── __init__.py │ │ │ ├── actions.py │ │ │ ├── axioms.py │ │ │ ├── conditions.py │ │ │ ├── effects.py │ │ │ ├── f_expression.py │ │ │ ├── functions.py │ │ │ ├── pddl_types.py │ │ │ ├── predicates.py │ │ │ └── tasks.py │ │ ├── pddl_parser │ │ │ ├── __init__.py │ │ │ ├── lisp_parser.py │ │ │ ├── parsing_functions.py │ │ │ └── pddl_file.py │ │ ├── pddl_to_prolog.py │ │ ├── sas_tasks.py │ │ ├── sccs.py │ │ ├── simplify.py │ │ ├── split_rules.py │ │ ├── timers.py │ │ ├── tools.py │ │ ├── translate.py │ │ └── variable_order.py │ └── ikfast │ │ ├── __init__.py │ │ ├── compile.py │ │ ├── ikfast.h │ │ └── panda_arm │ │ ├── __init__.py │ │ ├── compile.py │ │ ├── ikfast.h │ │ ├── ikfast_panda_arm.cpp │ │ └── setup.py ├── train_refinement_estimator.py └── utils.py ├── run_autoformat.sh ├── scripts ├── __init__.py ├── active_sampler_learning_analysis.py ├── analyze_results_directory.py ├── cluster_utils.py ├── configs │ ├── active_sampler_learning.yaml │ ├── backchaining_predicate_invention.yaml │ ├── cover_active_sampler_learning.yaml │ ├── example_basic.yaml │ ├── example_multiple_combinations.yaml │ ├── full_pipeline.yaml │ ├── interactive_learning.yaml │ ├── kitchen_active_learning.yaml │ ├── kitchen_oracle.yaml │ ├── llm_pddl.yaml │ ├── llm_pddl_ablations.yaml │ ├── nightly.yaml │ ├── online_rl_cover.yaml │ ├── pg3_offline.yaml │ ├── pg3_online.yaml │ ├── pg4.yaml │ ├── pred_invention_slowness.yaml │ ├── pred_invention_vlm.yaml │ ├── refinement_cost_learning.yaml │ └── refinement_cost_learning_test.yaml ├── eval_trajectory_to_lisdf.py ├── evaluate_interactive_approach_classifiers.py ├── evaluate_interactive_approach_entropy.py ├── find_unused_functions.py ├── grammar_search_analysis.py ├── launch_slack_bot.py ├── lisdf_plan_to_reset.py ├── lisdf_pybullet_visualizer.py ├── local │ ├── launch.py │ └── print_commands.py ├── openstack │ ├── README.md │ ├── __init__.py │ ├── download.py │ ├── kill_all.py │ └── launch.py ├── plotting │ ├── analyze_latent_variable_competence_models.py │ ├── analyze_skill_competence_models.py │ ├── create_active_sampler_learning_plots.py │ ├── create_bar_plots.py │ ├── create_classification_plots.py │ ├── create_ignore_effects_lineplots.py │ ├── create_interactive_predicate_learning_plots.py │ ├── create_latex_tables.py │ ├── create_num_demos_plots.py │ ├── create_option_learning_plots.py │ ├── create_per_task_histograms.py │ └── create_per_task_nodes_stripplot.py ├── realsense_helpers.py ├── run_blocks_perception.py ├── run_blocks_real.sh ├── run_checks.sh ├── skeleton_score_analysis.py └── supercloud │ ├── __init__.py │ ├── download.py │ ├── kill_all.py │ ├── launch.py │ ├── run_ignore_effects_experiments.sh │ ├── run_loft_experiments.sh │ ├── run_option_learning_experiments.sh │ ├── run_predicators_evalonly_experiments.sh │ ├── run_predicators_main_experiments.sh │ ├── run_predicators_num_demos_experiments.sh │ └── submit_supercloud_job.py ├── setup.py ├── supercloud.md └── tests ├── __init__.py ├── approaches ├── __init__.py ├── test_active_sampler_learning_approach.py ├── test_base_approach.py ├── test_bridge_policy_approach.py ├── test_gnn_action_policy_approach.py ├── test_gnn_metacontroller_approach.py ├── test_gnn_option_policy_approach.py ├── test_grammar_search_invention_approach.py ├── test_interactive_approach.py ├── test_llm_base_renaming_approach.py ├── test_llm_bilevel_planning_approach.py ├── test_llm_open_loop_approach.py ├── test_llm_option_renaming_approach.py ├── test_llm_predicate_renaming_approach.py ├── test_llm_syntax_renaming_approach.py ├── test_maple_q_approach.py ├── test_noisy_button_wrapper_approach.py ├── test_nsrt_learning_approach.py ├── test_nsrt_rl_approach.py ├── test_online_nsrt_learning_approach.py ├── test_online_pg3_approach.py ├── test_oracle_approach.py ├── test_pg3_analogy_approach.py ├── test_pg3_approach.py ├── test_pg4_approach.py ├── test_random_actions_approach.py ├── test_random_options_approach.py └── test_refinement_estimation_approach.py ├── bridge_policies ├── test_base_bridge_policy.py └── test_oracle_bridge_policy.py ├── conftest.py ├── datasets ├── mock_vlm_datasets │ ├── cover__demo+labelled_atoms__manual__1.txt │ ├── cover__vlm_demos__456__1 │ │ └── traj_0 │ │ │ ├── 0 │ │ │ ├── img.jpg │ │ │ └── state.p │ │ │ ├── 1 │ │ │ ├── img.jpg │ │ │ └── state.p │ │ │ ├── 2 │ │ │ ├── img.jpg │ │ │ └── state.p │ │ │ └── options_traj.txt │ ├── ice_tea_making__demo+labelled_atoms__manual__1.txt │ └── ice_tea_making__vlm_demos__456__1 │ │ └── traj_0 │ │ ├── 0 │ │ └── IMG_3779.jpg │ │ ├── 1 │ │ └── IMG_3780.jpg │ │ ├── 2 │ │ └── IMG_3781.jpg │ │ ├── 3 │ │ └── IMG_3782.jpg │ │ ├── 4 │ │ └── IMG_3783.jpg │ │ └── options_traj.txt ├── test_datasets.py └── test_vlm_predicate_img.jpg ├── envs ├── test_ball_and_cup_sticky_table_env.py ├── test_base_env.py ├── test_blocks.py ├── test_burger.py ├── test_cluttered_table.py ├── test_coffee.py ├── test_cover.py ├── test_doors_env.py ├── test_exit_garage.py ├── test_grid_row.py ├── test_narrow_passage.py ├── test_painting.py ├── test_pddl_env.py ├── test_pddl_procedural_generation.py ├── test_playroom.py ├── test_pybullet_blocks.py ├── test_pybullet_cover.py ├── test_repeated_nextto.py ├── test_repeated_nextto_painting.py ├── test_sandwich.py ├── test_satellites.py ├── test_screws.py ├── test_sokoban.py ├── test_stick_button.py ├── test_sticky_table.py ├── test_tools.py ├── test_touch_point.py └── test_vlm_envs.py ├── execution_monitoring └── test_execution_monitoring.py ├── explorers ├── test_active_sampler_explorer.py ├── test_base_explorer.py ├── test_exploit_bilevel_planning_explorer.py ├── test_glib_explorer.py ├── test_greedy_lookahead_explorer.py ├── test_no_explore_explorer.py ├── test_online_learning.py ├── test_random_actions_explorer.py ├── test_random_nsrts_explorer.py └── test_random_options_explorer.py ├── nsrt_learning ├── strips_learning │ ├── test_backchaining_based_learners.py │ ├── test_base_strips_learner.py │ ├── test_clustering_learner.py │ ├── test_llm_strips_learner.py │ └── test_oracle_learner.py ├── test_nsrt_learning_main.py ├── test_option_learning.py ├── test_sampler_learning.py └── test_segmentation.py ├── perception └── test_perception.py ├── pybullet_helpers ├── conftest.py ├── ikfast │ ├── test_load.py │ └── test_utils.py ├── robots │ └── test_panda.py ├── test_geometry.py ├── test_joint.py ├── test_link.py ├── test_motion_planning.py └── test_pybullet_robots.py ├── refinement_estimators ├── test_base_refinement_estimator.py ├── test_cnn_refinement_estimator.py ├── test_gnn_refinement_estimator.py ├── test_oracle_refinement_estimator.py └── test_tabular_refinement_estimator.py ├── test_args.py ├── test_cogman.py ├── test_competence_models.py ├── test_ground_truth_options.py ├── test_main.py ├── test_ml_models.py ├── test_option_model.py ├── test_planning.py ├── test_predicate_search_score_functions.py ├── test_pretrained_model_interface.py ├── test_settings.py ├── test_structs.py ├── test_teacher.py ├── test_train_refinement_estimator.py └── test_utils.py /.coveragerc: -------------------------------------------------------------------------------- 1 | [run] 2 | omit = 3 | predicators/third_party/** 4 | predicators/envs/kitchen.py 5 | predicators/perception/kitchen_perceiver.py 6 | predicators/ground_truth_models/kitchen/** 7 | # Currently disabled due to flakiness in the SME dependency. 8 | predicators/approaches/sme_pg3_analogy_approach.py 9 | 10 | [report] 11 | # Regexes for lines to exclude from consideration 12 | exclude_lines = 13 | # Have to re-enable the standard pragma 14 | # per https://coverage.readthedocs.io/en/latest/config.html#syntax 15 | pragma: no cover 16 | 17 | # Don't complain about abstract methods, they aren't run 18 | @abstractmethod 19 | @abc.abstractmethod 20 | 21 | # Don't complain about TYPE_CHECKING imports. 22 | if TYPE_CHECKING: 23 | 24 | # Don't complain about longrun tests. 25 | @longrun 26 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | # Default owners for all files. 2 | * @NishanthJKumar 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | __pycache__ 2 | *.pyc 3 | .DS_Store 4 | .vscode 5 | *.egg-info 6 | *.pkl 7 | *~ 8 | *.python-version 9 | *.csv 10 | *.zip 11 | *.so 12 | build 13 | dist 14 | pylint_recursive.py 15 | .coverage 16 | results 17 | eval_trajectories 18 | images 19 | videos 20 | logs* 21 | saved_approaches 22 | saved_datasets 23 | scripts/results 24 | pretrained_model_cache* 25 | tests/datasets/mock_vlm_datasets/cache/ 26 | machines.txt 27 | *_vision_data 28 | tests/_fake_trajs 29 | tests/_fake_results 30 | sas_plan 31 | downward/ 32 | Gymnasium-Robotics/ 33 | predicators/datasets/vlm_input_data_prompts/vision_api/prompt.txt 34 | predicators/datasets/vlm_input_data_prompts/vision_api/response.txt 35 | 36 | # Jetbrains IDEs 37 | .idea/ 38 | -------------------------------------------------------------------------------- /.isort.cfg: -------------------------------------------------------------------------------- 1 | [isort] 2 | multi_line_output = 2 3 | -------------------------------------------------------------------------------- /.style.yapf: -------------------------------------------------------------------------------- 1 | [style] 2 | based_on_style = pep8 3 | split_before_logical_operator = true 4 | column_limit = 79 5 | spaces_before_comment = 2 -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Rohan Chitnis and Tom Silver 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /predicators/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Learning-and-Intelligent-Systems/predicators/5bd3f5bd21cc01e171faf748edf53bcfd720f4d1/predicators/__init__.py -------------------------------------------------------------------------------- /predicators/approaches/llm_option_renaming_approach.py: -------------------------------------------------------------------------------- 1 | """Open-loop large language model (LLM) meta-controller approach with prompt 2 | modification where option names are replaced with random strings. 3 | 4 | Example command line: 5 | export OPENAI_API_KEY= 6 | python predicators/main.py --approach llm_option_renaming --seed 0 \ 7 | --strips_learner oracle \ 8 | --env pddl_blocks_procedural_tasks \ 9 | --num_train_tasks 3 \ 10 | --num_test_tasks 1 \ 11 | --debug 12 | """ 13 | import string 14 | from typing import Dict, List 15 | 16 | from predicators import utils 17 | from predicators.approaches.llm_base_renaming_approach import \ 18 | LLMBaseRenamingApproach 19 | 20 | 21 | class LLMOptionRenamingApproach(LLMBaseRenamingApproach): 22 | """LLMOptionRenamingApproach definition.""" 23 | 24 | @classmethod 25 | def get_name(cls) -> str: 26 | return "llm_option_renaming" 27 | 28 | @property 29 | def _renaming_prefixes(self) -> List[str]: 30 | # Options start with either a new line or a white space. 31 | return [" ", "\n"] 32 | 33 | @property 34 | def _renaming_suffixes(self) -> List[str]: 35 | # Option names end with a left parenthesis. 36 | return ["("] 37 | 38 | def _create_replacements(self) -> Dict[str, str]: 39 | return { 40 | o.name: utils.generate_random_string(len(o.name), 41 | list(string.ascii_lowercase), 42 | self._rng) 43 | for o in self._initial_options 44 | } 45 | -------------------------------------------------------------------------------- /predicators/approaches/llm_predicate_renaming_approach.py: -------------------------------------------------------------------------------- 1 | """Open-loop large language model (LLM) meta-controller approach with prompt 2 | modification where where predicate names are replaced with random strings. 3 | 4 | Example command line: 5 | export OPENAI_API_KEY= 6 | python predicators/main.py --approach llm_predicate_renaming --seed 0 \ 7 | --strips_learner oracle \ 8 | --env pddl_blocks_procedural_tasks \ 9 | --num_train_tasks 3 \ 10 | --num_test_tasks 1 \ 11 | --debug 12 | """ 13 | import string 14 | from typing import Dict, List 15 | 16 | from predicators import utils 17 | from predicators.approaches.llm_base_renaming_approach import \ 18 | LLMBaseRenamingApproach 19 | 20 | 21 | class LLMPredicateRenamingApproach(LLMBaseRenamingApproach): 22 | """LLMPredicateRenamingApproach definition.""" 23 | 24 | @classmethod 25 | def get_name(cls) -> str: 26 | return "llm_predicate_renaming" 27 | 28 | @property 29 | def _renaming_prefixes(self) -> List[str]: 30 | # Predicates start with either a new line or a white space. 31 | return [" ", "\n"] 32 | 33 | @property 34 | def _renaming_suffixes(self) -> List[str]: 35 | # Predicate names end with a left parenthesis. 36 | return ["("] 37 | 38 | def _create_replacements(self) -> Dict[str, str]: 39 | return { 40 | p.name: utils.generate_random_string(len(p.name), 41 | list(string.ascii_lowercase), 42 | self._rng) 43 | for p in self._get_current_predicates() 44 | } 45 | -------------------------------------------------------------------------------- /predicators/approaches/llm_syntax_renaming_approach.py: -------------------------------------------------------------------------------- 1 | """Open-loop large language model (LLM) meta-controller approach with prompt 2 | modification where certain PDDL syntax is replaced with random characters. 3 | 4 | Example command line: 5 | export OPENAI_API_KEY= 6 | python predicators/main.py --approach llm_syntax_renaming --seed 0 \ 7 | --strips_learner oracle \ 8 | --env pddl_blocks_procedural_tasks \ 9 | --num_train_tasks 3 \ 10 | --num_test_tasks 1 \ 11 | --debug 12 | """ 13 | from typing import Dict, List 14 | 15 | from predicators.approaches.llm_base_renaming_approach import \ 16 | LLMBaseRenamingApproach 17 | 18 | ORIGINAL_CHARS = ['(', ')', ':'] 19 | REPLACEMENT_CHARS = ['^', '$', '#', '!', '*'] 20 | 21 | 22 | class LLMSyntaxRenamingApproach(LLMBaseRenamingApproach): 23 | """LLMSyntaxRenamingApproach definition.""" 24 | 25 | @classmethod 26 | def get_name(cls) -> str: 27 | return "llm_syntax_renaming" 28 | 29 | @property 30 | def _renaming_prefixes(self) -> List[str]: 31 | # Since we're replacing single characters, we don't need to worry about 32 | # the possibility that one string is a substring of another. 33 | return [""] 34 | 35 | @property 36 | def _renaming_suffixes(self) -> List[str]: 37 | # Since we're replacing single characters, we don't need to worry about 38 | # the possibility that one string is a substring of another. 39 | return [""] 40 | 41 | def _create_replacements(self) -> Dict[str, str]: 42 | # Without replacement because if multiple original characters mapped 43 | # to the same replacement character, the inverse substitution would be 44 | # not well defined and the parsing of the option plan would fail. 45 | replacement_chars = self._rng.choice(REPLACEMENT_CHARS, 46 | size=len(ORIGINAL_CHARS), 47 | replace=False) 48 | return dict(zip(ORIGINAL_CHARS, replacement_chars)) 49 | -------------------------------------------------------------------------------- /predicators/approaches/noisy_button_wrapper_approach.py: -------------------------------------------------------------------------------- 1 | """An approach that "wraps" a base approach for the NoisyButtonEnv. The wrapper 2 | always executes a "find" action when receiving a state with unknown button 3 | position. Otherwise it passes control to the regular approach. The way to use 4 | this environment from the command-line is using the flag. 5 | 6 | --approach 'noisy_button_wrapper[base approach name]' 7 | 8 | e.g. 9 | 10 | --approach 'noisy_button_wrapper[oracle]' 11 | """ 12 | 13 | from typing import Callable, Optional 14 | 15 | import numpy as np 16 | 17 | from predicators.approaches import BaseApproachWrapper 18 | from predicators.structs import Action, State, Task 19 | 20 | 21 | class NoisyButtonWrapperApproach(BaseApproachWrapper): 22 | """Always "find" when the button position is unknown.""" 23 | 24 | @classmethod 25 | def get_name(cls) -> str: 26 | return "noisy_button_wrapper" 27 | 28 | @property 29 | def is_learning_based(self) -> bool: 30 | return self._base_approach.is_learning_based 31 | 32 | def _solve(self, task: Task, timeout: int) -> Callable[[State], Action]: 33 | 34 | # Maintain policy from the base approach. 35 | base_approach_policy: Optional[Callable[[State], Action]] = None 36 | 37 | def _policy(state: State) -> Action: 38 | nonlocal base_approach_policy 39 | # If the button state is unknown, execute find. 40 | button, = list(state) 41 | if state.get(button, "position_known") < 0.5: 42 | # Reset the base approach policy. 43 | base_approach_policy = None 44 | return Action(np.array([0.0, 1.0], dtype=np.float32)) 45 | # Check if we need to re-solve. 46 | if base_approach_policy is None: 47 | cur_task = Task(state, task.goal) 48 | base_approach_policy = self._base_approach.solve( 49 | cur_task, timeout) 50 | # Use the base policy. 51 | return base_approach_policy(state) 52 | 53 | return _policy 54 | -------------------------------------------------------------------------------- /predicators/approaches/random_actions_approach.py: -------------------------------------------------------------------------------- 1 | """An approach that just takes random low-level actions.""" 2 | 3 | from typing import Callable 4 | 5 | from predicators.approaches import BaseApproach 6 | from predicators.structs import Action, State, Task 7 | 8 | 9 | class RandomActionsApproach(BaseApproach): 10 | """Samples random low-level actions.""" 11 | 12 | @classmethod 13 | def get_name(cls) -> str: 14 | return "random_actions" 15 | 16 | @property 17 | def is_learning_based(self) -> bool: 18 | return False 19 | 20 | def _solve(self, task: Task, timeout: int) -> Callable[[State], Action]: 21 | 22 | def _policy(_: State) -> Action: 23 | return Action(self._action_space.sample()) 24 | 25 | return _policy 26 | -------------------------------------------------------------------------------- /predicators/approaches/random_options_approach.py: -------------------------------------------------------------------------------- 1 | """An approach that just executes random options.""" 2 | 3 | from typing import Callable 4 | 5 | from predicators import utils 6 | from predicators.approaches import ApproachFailure, BaseApproach 7 | from predicators.structs import Action, State, Task 8 | 9 | 10 | class RandomOptionsApproach(BaseApproach): 11 | """Samples random options (and random parameters for those options).""" 12 | 13 | @classmethod 14 | def get_name(cls) -> str: 15 | return "random_options" 16 | 17 | @property 18 | def is_learning_based(self) -> bool: 19 | return False 20 | 21 | def _solve(self, task: Task, timeout: int) -> Callable[[State], Action]: 22 | 23 | def fallback_policy(state: State) -> Action: 24 | del state # unused 25 | raise ApproachFailure("Random option sampling failed!") 26 | 27 | return utils.create_random_option_policy(self._initial_options, 28 | self._rng, fallback_policy) 29 | -------------------------------------------------------------------------------- /predicators/bridge_policies/__init__.py: -------------------------------------------------------------------------------- 1 | """Handle creation of bridge policies.""" 2 | 3 | from typing import Set 4 | 5 | from predicators import utils 6 | from predicators.bridge_policies.base_bridge_policy import BaseBridgePolicy, \ 7 | BridgePolicyDone 8 | from predicators.structs import NSRT, ParameterizedOption, Predicate, Type 9 | 10 | __all__ = ["BaseBridgePolicy", "BridgePolicyDone", "create_bridge_policy"] 11 | 12 | # Find the subclasses. 13 | utils.import_submodules(__path__, __name__) 14 | 15 | 16 | def create_bridge_policy(name: str, types: Set[Type], 17 | predicates: Set[Predicate], 18 | options: Set[ParameterizedOption], 19 | nsrts: Set[NSRT]) -> BaseBridgePolicy: 20 | """Create a bridge policy given its name.""" 21 | for cls in utils.get_all_subclasses(BaseBridgePolicy): 22 | if not cls.__abstractmethods__ and cls.get_name() == name: 23 | bridge_policy = cls(types, predicates, options, nsrts) 24 | break 25 | else: 26 | raise NotImplementedError(f"Unknown bridge policy: {name}") 27 | return bridge_policy 28 | -------------------------------------------------------------------------------- /predicators/bridge_policies/ldl_bridge_policy.py: -------------------------------------------------------------------------------- 1 | """A bridge policy that uses a lifted decision list with failure conditions.""" 2 | 3 | import abc 4 | import logging 5 | from typing import Callable, List, Set 6 | 7 | from predicators import utils 8 | from predicators.bridge_policies import BaseBridgePolicy, BridgePolicyDone 9 | from predicators.structs import NSRT, GroundAtom, LiftedDecisionList, \ 10 | ParameterizedOption, Predicate, State, Type, _Option 11 | 12 | 13 | class LDLBridgePolicy(BaseBridgePolicy): 14 | """A lifted decision list bridge policy with failure conditions.""" 15 | 16 | def __init__(self, types: Set[Type], predicates: Set[Predicate], 17 | options: Set[ParameterizedOption], nsrts: Set[NSRT]) -> None: 18 | super().__init__(types, predicates, options, nsrts) 19 | self._failure_predicates = utils.get_all_failure_predicates(options) 20 | 21 | @abc.abstractmethod 22 | def _get_current_ldl(self) -> LiftedDecisionList: 23 | """Return the current lifted decision list policy.""" 24 | 25 | def _bridge_policy(self, state: State, atoms: Set[GroundAtom], 26 | failed_options: List[_Option]) -> _Option: 27 | ldl = self._get_current_ldl() 28 | # Add failure atoms based on failed_options. 29 | atoms_with_failures = atoms | utils.get_failure_atoms(failed_options) 30 | objects = set(state) 31 | goal: Set[GroundAtom] = set() # task goal not used 32 | next_nsrt = utils.query_ldl(ldl, atoms_with_failures, objects, goal) 33 | if next_nsrt is None: 34 | raise BridgePolicyDone() 35 | return next_nsrt.sample_option(state, goal, self._rng) 36 | 37 | def get_option_policy(self) -> Callable[[State], _Option]: 38 | 39 | def _option_policy(state: State) -> _Option: 40 | atoms = utils.abstract(state, self._predicates) 41 | option = self._bridge_policy(state, atoms, self._failed_options) 42 | logging.debug(f"Using option {option.name}{option.objects} " 43 | "from bridge policy.") 44 | return option 45 | 46 | return _option_policy 47 | -------------------------------------------------------------------------------- /predicators/bridge_policies/oracle_bridge_policy.py: -------------------------------------------------------------------------------- 1 | """A hand-written LDL bridge policy.""" 2 | 3 | from typing import Set 4 | 5 | from predicators.bridge_policies.ldl_bridge_policy import LDLBridgePolicy 6 | from predicators.ground_truth_models import get_gt_ldl_bridge_policy 7 | from predicators.settings import CFG 8 | from predicators.structs import NSRT, LiftedDecisionList, \ 9 | ParameterizedOption, Predicate, Type 10 | 11 | 12 | class OracleBridgePolicy(LDLBridgePolicy): 13 | """A hand-written LDL bridge policy.""" 14 | 15 | def __init__(self, types: Set[Type], predicates: Set[Predicate], 16 | options: Set[ParameterizedOption], nsrts: Set[NSRT]) -> None: 17 | super().__init__(types, predicates, options, nsrts) 18 | all_predicates = predicates | self._failure_predicates 19 | self._oracle_ldl = get_gt_ldl_bridge_policy(CFG.env, self._types, 20 | all_predicates, 21 | self._options, self._nsrts) 22 | 23 | @classmethod 24 | def get_name(cls) -> str: 25 | return "oracle" 26 | 27 | @property 28 | def is_learning_based(self) -> bool: 29 | return False 30 | 31 | def _get_current_ldl(self) -> LiftedDecisionList: 32 | return self._oracle_ldl 33 | -------------------------------------------------------------------------------- /predicators/datasets/vlm_input_data_prompts/atom_labelling/double_check_prompt_prev_labels.txt: -------------------------------------------------------------------------------- 1 | Sometimes your reasoning about the value of a predicate at the current timestep uses an incorrect value of that predicate in the previous timestep. Below, I give you give you the values of the predicates at the previous timestep once again. Please check your reasoning and provide a corrected version of your previous answer, if it needs correcting. Regardless of whether or not it needs correctly, your reply should be formatted exactly the same as the previous answer. -------------------------------------------------------------------------------- /predicators/datasets/vlm_input_data_prompts/atom_labelling/img_option_diffs.txt: -------------------------------------------------------------------------------- 1 | You are a vision system for a robot. Your job is to output the values of the following predicates based on some information provided below. You will be provided with two images corresponding to the states before and after a particular skill is executed. You will also be provided with a list of predicates. Your job is to output the values of all the predicates in only the final scene. Pay careful attention to predicates that change between the two scenes, and list these separately at the end of your response. Note that in some scenes, there might be no changes. Output each predicate value as a bulleted list with each predicate and value on a different line. For each output value, provide an explanation as to why you labelled this predicate as having this particular value. Use the format: : . . 2 | 3 | Predicates to label in scenes: -------------------------------------------------------------------------------- /predicators/datasets/vlm_input_data_prompts/atom_labelling/img_option_diffs_label_history.txt: -------------------------------------------------------------------------------- 1 | You are a vision system for a robot. You are provided with two images corresponding to the states before and after a particular skill is executed. You are given a list of predicates below, and you are given the values of these predicates in the image before the skill is executed. Your job is to output the values of the following predicates in the image after the skill is executed. Pay careful attention to the visual changes between the two images to figure out which predicates change and which predicates do not change. For the predicates that change, list these separately at the end of your response. Note that in some scenes, there might be no changes. First, output a description of what changes you expect to happen based on the skill that was just run, explicitly noting the skill that was run. Second, output a description of what visual changes you see happen between the before and after images, looking specifically at the objects involved in the skill's arguments, noting what objects these are. Next, output each predicate value in the after image as a bulleted list with each predicate and value on a different line. For each predicate value, provide an explanation as to why you labelled this predicate as having this particular value. Use the format: : . . 2 | 3 | Your response should have three sections. Here is an outline of what your response should look like: 4 | [START OULTLINE] 5 | # Expected changes based on the executed skill 6 | [insert your analysis on the expected changes you will see based on the skill that was executed] 7 | 8 | # Visual changes observed between the images 9 | [insert your analysis on the visual changes observed between the images] 10 | 11 | # Predicate values in the after image 12 | [insert your bulleted list of `* : . `] 13 | [END OUTLINE] 14 | 15 | Predicates: -------------------------------------------------------------------------------- /predicators/datasets/vlm_input_data_prompts/atom_labelling/img_option_diffs_label_history_crops.txt: -------------------------------------------------------------------------------- 1 | You are a vision system for a robot provided with four images: a before image showing the state before a skill is executed, an after image showing the state after the skill is executed, and two cropped images highlighting objects relevant to the skill's arguments (the third image is a crop of the before image, and the fourth image is a crop of the after image). You are also given a list of predicates and their values in the before image. Your task is to output the values of these predicates in the after image. First, describe the expected visual changes based on the executed skill, explicitly noting the skill performed. Second, describe the visual changes you observe between the before and after images, focusing on the objects involved in the skill's arguments. Finally, list each predicate value in the after image in the format `: . `, and separately list the predicates that changed. If an object is not visible in the cropped images, check the uncropped images. If you still cannot locate the object involved in a specific predicate, retain the predicate’s value from the previous timestep. 2 | 3 | Predicates: -------------------------------------------------------------------------------- /predicators/datasets/vlm_input_data_prompts/atom_labelling/per_scene_cot.txt: -------------------------------------------------------------------------------- 1 | You are a vision system for a robot. Your job is to output the values of the following predicates based on the provided visual scene. For each predicate, output True, False, or Unknown if the relevant objects are not in the scene or the value of the predicate simply cannot be determined. Output each predicate value as a bulleted list with each predicate and value on a different line. For each output value, provide an explanation as to why you labelled this predicate as having this particular value.Use the format: : . . 2 | Predicates: -------------------------------------------------------------------------------- /predicators/datasets/vlm_input_data_prompts/atom_labelling/per_scene_naive.txt: -------------------------------------------------------------------------------- 1 | You are a vision system for a robot. Your job is to output the values of the following predicates based on the provided visual scene. For each predicate, output True, False, or Unknown if the relevant objects are not in the scene or the value of the predicate simply cannot be determined. Output each predicate value as a bulleted list (use '*' for the bullets) with each predicate and value on a different line. Use the format: `(, , ...): ` given the provided predicates and arguments exactly. Ensure there is a period ('.') after every list item. Do not output any text except the names and truth values of predicates. 2 | Predicates: -------------------------------------------------------------------------------- /predicators/datasets/vlm_input_data_prompts/atom_proposal/naive_each_step.txt: -------------------------------------------------------------------------------- 1 | You are a robotic vision system whose job is to output a structured set of predicates useful for running a task and motion planning system from the following scene. Please provide predicates in terms of the following objects: {objs}. For each predicate, output it in the following format: predicate_name(obj1, obj2, obj3...) (for instance is_sliced(apple), is_not_sliced(apple), etc.). Also, for each predicate you list, list its negation. List as many predicates as you can possibly think of, even if they're only tangentially relevant to what you see in the scene and even if they're false, given the following scene taken from a demonstration for the task.Do not list any other text other than the names and arguments of predicates. List each proposal as a bulleted list item on a separate line. -------------------------------------------------------------------------------- /predicators/datasets/vlm_input_data_prompts/atom_proposal/naive_whole_traj.txt: -------------------------------------------------------------------------------- 1 | You are a robotic vision system whose job is to output a structured set of predicates useful for describing the important concepts from the following demonstration. Please provide predicates in terms of the objects: {objs}. For each predicate, output it in the following format: predicate_name(obj1, obj2, obj3...) (for instance is_sliced(apple), is_not_sliced(apple), etc.). Also, for each predicate you list, list its negation. Generate as many predicates as you can possibly think of, even if they're only tangentially relevant to the task goal: 'make a cup of ice tea'Do not list any other text other than the names and arguments of predicates. List each proposal as a bulleted list item on a separate line. -------------------------------------------------------------------------------- /predicators/datasets/vlm_input_data_prompts/atom_proposal/options_labels_whole_traj_diverse.txt: -------------------------------------------------------------------------------- 1 | You are a robotic vision system whose job is to output a structured set of predicates useful for describing important concepts in the following demonstration of a task. You will be provided with a list of actions used during the task, as well as images of states before and after every action execution. Please provide predicates in terms of the following objects: {objs}. For each predicate, output it in the following format: predicate_name(obj1, obj2, obj3...). Start by generating predicates that change before and after each action. After this, generate any other predicates that perhaps do not change but are still important to describing the demonstration shown. For each predicate you generate, also generate some predicates that are synonyms and antonyms so that any predicate that is even tangentially relevant to the demonstrations is generated. -------------------------------------------------------------------------------- /predicators/datasets/vlm_input_data_prompts/atom_proposal/options_labels_whole_traj_specific.txt: -------------------------------------------------------------------------------- 1 | You are a robotic vision system whose job is to output a structured set of predicates useful for describing important concepts in the following demonstration of a task. You will be provided with a list of actions used during the task, as well as images of states before and after every action execution. Please provide predicates in terms of the following objects: {objs}. For each predicate, output it in the following format: predicate_name(obj1, obj2, obj3...). Start by generating predicates that change before and after each action. After this, generate any other predicates that perhaps do not change but are still important to decision-making for the task shown. Do your best to propose only predicates that are critical to decision-making: do not propose arbitrary or tangentially-relevant predicates. Your proposals will be used by an AI planning system to try to solve tasks similar to what you've been shown here. -------------------------------------------------------------------------------- /predicators/datasets/vlm_input_data_prompts/vision_api/api_sym_predicate.txt: -------------------------------------------------------------------------------- 1 | class Predicate: 2 | """A class representing a predicate (a lifted classifier over states) in 3 | the context of AI task planning. The function takes a state and a sequence 4 | of objects as input, and returns a boolean value indicating whether the 5 | property holds for those objects in that state. 6 | 7 | Attributes: 8 | ----------- 9 | name : str 10 | The name of the predicate. 11 | 12 | types : Sequence[Type] 13 | The types of the objects that the predicate applies to. This sequence 14 | should have the same length as the sequence of objects passed to the 15 | classifier. 16 | 17 | _classifier : Callable[[State, Sequence[Object]], bool] 18 | The classifier function for the predicate. This function takes a state 19 | and a sequence of objects as input, and returns a boolean value. The 20 | objects in the sequence should correspond one-to-one with the types in 21 | the 'types' attribute. The classifier should return True if the 22 | predicate holds for those objects in that state, and False otherwise. 23 | """ 24 | name: str 25 | types: Sequence[Type] 26 | _classifier: Callable[[State, Sequence[Object]], bool] 27 | -------------------------------------------------------------------------------- /predicators/datasets/vlm_input_data_prompts/vision_api/prompt.outline: -------------------------------------------------------------------------------- 1 | You are a robotic vision system whose job is to output a structured set of predicates useful for describing important concepts in the following demonstration of a task. You will be provided with a list of actions used during the task, as well as images of states before and after every action execution. 2 | Generating predicates that change before and after each action. After this, generate any other predicates that perhaps do not change but are still important to describing the demonstration shown. For each predicate you generate, also generate some predicates that are synonyms and antonyms so that any predicate that is even tangentially relevant to the demonstrations is generated. 3 | 4 | I will describe the API you should use for writing predicates and the environment the robot is in. 5 | # API for Defining Predicates 6 | Class definitions for `Predicate` and `State` are: 7 | [STRUCT_DEFINITION] 8 | 9 | # The Environment 10 | The environment includes the following object-type variables: 11 | [TYPES_IN_ENV] 12 | 13 | # The demo trajectory is 14 | [DEMO_TRAJECTORY] 15 | 16 | In your response, propose predicates in paragraphs as follows. For each proposal: 17 | - Identify which property from above does it correspond to. 18 | - Define predicate in a python block as follows: 19 | ```python 20 | def classifier(state: State, objects: Sequence[Object]) -> bool: 21 | # Implement the boolean classifier function here 22 | ... 23 | 24 | name: str = ... # Define the predicate name here 25 | param_types: Sequence[Type] = ... # A list of object-type variables for the predicate, using the ones defined in the environment 26 | = Predicate(name, param_types, _holds) 27 | ``` -------------------------------------------------------------------------------- /predicators/envs/__init__.py: -------------------------------------------------------------------------------- 1 | """Handle creation of environments.""" 2 | 3 | import logging 4 | 5 | from predicators import utils 6 | from predicators.envs.base_env import BaseEnv 7 | 8 | __all__ = ["BaseEnv"] 9 | _MOST_RECENT_ENV_INSTANCE = {} 10 | 11 | # Find the subclasses. 12 | utils.import_submodules(__path__, __name__) 13 | 14 | 15 | def create_new_env(name: str, 16 | do_cache: bool = True, 17 | use_gui: bool = True) -> BaseEnv: 18 | """Create a new instance of an environment from its name. 19 | 20 | If do_cache is True, then cache this env instance so that it can 21 | later be loaded using get_or_create_env(). 22 | """ 23 | for cls in utils.get_all_subclasses(BaseEnv): 24 | if not cls.__abstractmethods__ and cls.get_name() == name: 25 | env = cls(use_gui) 26 | break 27 | else: 28 | raise NotImplementedError(f"Unknown env: {name}") 29 | if do_cache: 30 | _MOST_RECENT_ENV_INSTANCE[name] = env 31 | return env 32 | 33 | 34 | def get_or_create_env(name: str) -> BaseEnv: 35 | """Get the most recent cached env instance. If one does not exist in the 36 | cache, create it using create_new_env(). 37 | 38 | If you use this function, you should NOT be doing anything that 39 | relies on the environment's internal state (i.e., you should not 40 | call reset() or step()). 41 | 42 | Also note that the GUI is always turned off for environments that are 43 | newly created by this function. If you want to use the GUI, you should 44 | create the environment explicitly through create_new_env(). 45 | """ 46 | if name not in _MOST_RECENT_ENV_INSTANCE: 47 | logging.warning( 48 | "WARNING: you called get_or_create_env, but I couldn't " 49 | f"find {name} in the cache. Making a new instance.") 50 | create_new_env(name, do_cache=True, use_gui=False) 51 | return _MOST_RECENT_ENV_INSTANCE[name] 52 | -------------------------------------------------------------------------------- /predicators/envs/assets/imgs/bottom_bun.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Learning-and-Intelligent-Systems/predicators/5bd3f5bd21cc01e171faf748edf53bcfd720f4d1/predicators/envs/assets/imgs/bottom_bun.png -------------------------------------------------------------------------------- /predicators/envs/assets/imgs/cheese.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Learning-and-Intelligent-Systems/predicators/5bd3f5bd21cc01e171faf748edf53bcfd720f4d1/predicators/envs/assets/imgs/cheese.png -------------------------------------------------------------------------------- /predicators/envs/assets/imgs/cooked_patty.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Learning-and-Intelligent-Systems/predicators/5bd3f5bd21cc01e171faf748edf53bcfd720f4d1/predicators/envs/assets/imgs/cooked_patty.png -------------------------------------------------------------------------------- /predicators/envs/assets/imgs/cut_lettuce.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Learning-and-Intelligent-Systems/predicators/5bd3f5bd21cc01e171faf748edf53bcfd720f4d1/predicators/envs/assets/imgs/cut_lettuce.png -------------------------------------------------------------------------------- /predicators/envs/assets/imgs/cutting_board.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Learning-and-Intelligent-Systems/predicators/5bd3f5bd21cc01e171faf748edf53bcfd720f4d1/predicators/envs/assets/imgs/cutting_board.png -------------------------------------------------------------------------------- /predicators/envs/assets/imgs/floorwood.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Learning-and-Intelligent-Systems/predicators/5bd3f5bd21cc01e171faf748edf53bcfd720f4d1/predicators/envs/assets/imgs/floorwood.png -------------------------------------------------------------------------------- /predicators/envs/assets/imgs/grill.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Learning-and-Intelligent-Systems/predicators/5bd3f5bd21cc01e171faf748edf53bcfd720f4d1/predicators/envs/assets/imgs/grill.png -------------------------------------------------------------------------------- /predicators/envs/assets/imgs/raw_patty.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Learning-and-Intelligent-Systems/predicators/5bd3f5bd21cc01e171faf748edf53bcfd720f4d1/predicators/envs/assets/imgs/raw_patty.png -------------------------------------------------------------------------------- /predicators/envs/assets/imgs/realistic_cooked_patty.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Learning-and-Intelligent-Systems/predicators/5bd3f5bd21cc01e171faf748edf53bcfd720f4d1/predicators/envs/assets/imgs/realistic_cooked_patty.png -------------------------------------------------------------------------------- /predicators/envs/assets/imgs/realistic_cooked_patty_full.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Learning-and-Intelligent-Systems/predicators/5bd3f5bd21cc01e171faf748edf53bcfd720f4d1/predicators/envs/assets/imgs/realistic_cooked_patty_full.png -------------------------------------------------------------------------------- /predicators/envs/assets/imgs/realistic_raw_patty.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Learning-and-Intelligent-Systems/predicators/5bd3f5bd21cc01e171faf748edf53bcfd720f4d1/predicators/envs/assets/imgs/realistic_raw_patty.png -------------------------------------------------------------------------------- /predicators/envs/assets/imgs/realistic_raw_patty_full.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Learning-and-Intelligent-Systems/predicators/5bd3f5bd21cc01e171faf748edf53bcfd720f4d1/predicators/envs/assets/imgs/realistic_raw_patty_full.png -------------------------------------------------------------------------------- /predicators/envs/assets/imgs/robot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Learning-and-Intelligent-Systems/predicators/5bd3f5bd21cc01e171faf748edf53bcfd720f4d1/predicators/envs/assets/imgs/robot.png -------------------------------------------------------------------------------- /predicators/envs/assets/imgs/robot_down.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Learning-and-Intelligent-Systems/predicators/5bd3f5bd21cc01e171faf748edf53bcfd720f4d1/predicators/envs/assets/imgs/robot_down.png -------------------------------------------------------------------------------- /predicators/envs/assets/imgs/robot_left.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Learning-and-Intelligent-Systems/predicators/5bd3f5bd21cc01e171faf748edf53bcfd720f4d1/predicators/envs/assets/imgs/robot_left.png -------------------------------------------------------------------------------- /predicators/envs/assets/imgs/robot_right.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Learning-and-Intelligent-Systems/predicators/5bd3f5bd21cc01e171faf748edf53bcfd720f4d1/predicators/envs/assets/imgs/robot_right.png -------------------------------------------------------------------------------- /predicators/envs/assets/imgs/robot_up.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Learning-and-Intelligent-Systems/predicators/5bd3f5bd21cc01e171faf748edf53bcfd720f4d1/predicators/envs/assets/imgs/robot_up.png -------------------------------------------------------------------------------- /predicators/envs/assets/imgs/sliced_tomato.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Learning-and-Intelligent-Systems/predicators/5bd3f5bd21cc01e171faf748edf53bcfd720f4d1/predicators/envs/assets/imgs/sliced_tomato.png -------------------------------------------------------------------------------- /predicators/envs/assets/imgs/top_bun.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Learning-and-Intelligent-Systems/predicators/5bd3f5bd21cc01e171faf748edf53bcfd720f4d1/predicators/envs/assets/imgs/top_bun.png -------------------------------------------------------------------------------- /predicators/envs/assets/imgs/uncut_lettuce.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Learning-and-Intelligent-Systems/predicators/5bd3f5bd21cc01e171faf748edf53bcfd720f4d1/predicators/envs/assets/imgs/uncut_lettuce.png -------------------------------------------------------------------------------- /predicators/envs/assets/imgs/whole_tomato.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Learning-and-Intelligent-Systems/predicators/5bd3f5bd21cc01e171faf748edf53bcfd720f4d1/predicators/envs/assets/imgs/whole_tomato.png -------------------------------------------------------------------------------- /predicators/envs/assets/pddl/blocks/domain.pddl: -------------------------------------------------------------------------------- 1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 2 | ;;; 4 Op-blocks world 3 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 4 | 5 | (define (domain BLOCKS) 6 | (:requirements :strips :typing) 7 | (:types block) 8 | (:predicates (on ?x - block ?y - block) 9 | (ontable ?x - block) 10 | (clear ?x - block) 11 | (handempty) 12 | (holding ?x - block) 13 | ) 14 | 15 | (:action pick-up 16 | :parameters (?x - block) 17 | :precondition (and (clear ?x) (ontable ?x) (handempty)) 18 | :effect 19 | (and (not (ontable ?x)) 20 | (not (clear ?x)) 21 | (not (handempty)) 22 | (holding ?x))) 23 | 24 | (:action put-down 25 | :parameters (?x - block) 26 | :precondition (holding ?x) 27 | :effect 28 | (and (not (holding ?x)) 29 | (clear ?x) 30 | (handempty) 31 | (ontable ?x))) 32 | (:action stack 33 | :parameters (?x - block ?y - block) 34 | :precondition (and (holding ?x) (clear ?y)) 35 | :effect 36 | (and (not (holding ?x)) 37 | (not (clear ?y)) 38 | (clear ?x) 39 | (handempty) 40 | (on ?x ?y))) 41 | (:action unstack 42 | :parameters (?x - block ?y - block) 43 | :precondition (and (on ?x ?y) (clear ?x) (handempty)) 44 | :effect 45 | (and (holding ?x) 46 | (clear ?y) 47 | (not (clear ?x)) 48 | (not (handempty)) 49 | (not (on ?x ?y))))) 50 | -------------------------------------------------------------------------------- /predicators/envs/assets/pddl/blocks/task1.pddl: -------------------------------------------------------------------------------- 1 | (define (problem BLOCKS-4-0) 2 | (:domain BLOCKS) 3 | (:objects D B A C - block) 4 | (:INIT (CLEAR C) (CLEAR A) (CLEAR B) (CLEAR D) (ONTABLE C) (ONTABLE A) 5 | (ONTABLE B) (ONTABLE D) (HANDEMPTY)) 6 | (:goal (AND (ON D C) (ON C B) (ON B A))) 7 | ) -------------------------------------------------------------------------------- /predicators/envs/assets/pddl/blocks/task10.pddl: -------------------------------------------------------------------------------- 1 | (define (problem BLOCKS-7-0) 2 | (:domain BLOCKS) 3 | (:objects C F A B G D E - block) 4 | (:INIT (CLEAR E) (ONTABLE D) (ON E G) (ON G B) (ON B A) (ON A F) (ON F C) 5 | (ON C D) (HANDEMPTY)) 6 | (:goal (AND (ON A G) (ON G D) (ON D B) (ON B C) (ON C F) (ON F E))) 7 | ) -------------------------------------------------------------------------------- /predicators/envs/assets/pddl/blocks/task11.pddl: -------------------------------------------------------------------------------- 1 | (define (problem BLOCKS-7-1) 2 | (:domain BLOCKS) 3 | (:objects E B D F G C A - block) 4 | (:INIT (CLEAR A) (CLEAR C) (ONTABLE G) (ONTABLE F) (ON A G) (ON C D) (ON D B) 5 | (ON B E) (ON E F) (HANDEMPTY)) 6 | (:goal (AND (ON A E) (ON E B) (ON B F) (ON F G) (ON G C) (ON C D))) 7 | ) -------------------------------------------------------------------------------- /predicators/envs/assets/pddl/blocks/task12.pddl: -------------------------------------------------------------------------------- 1 | (define (problem BLOCKS-7-2) 2 | (:domain BLOCKS) 3 | (:objects E G C D F A B - block) 4 | (:INIT (CLEAR B) (CLEAR A) (ONTABLE F) (ONTABLE D) (ON B C) (ON C G) (ON G E) 5 | (ON E F) (ON A D) (HANDEMPTY)) 6 | (:goal (AND (ON E B) (ON B F) (ON F D) (ON D A) (ON A C) (ON C G))) 7 | ) -------------------------------------------------------------------------------- /predicators/envs/assets/pddl/blocks/task13.pddl: -------------------------------------------------------------------------------- 1 | (define (problem BLOCKS-8-0) 2 | (:domain BLOCKS) 3 | (:objects H G F E C B D A - block) 4 | (:INIT (CLEAR A) (CLEAR D) (CLEAR B) (CLEAR C) (ONTABLE E) (ONTABLE F) 5 | (ONTABLE B) (ONTABLE C) (ON A G) (ON G E) (ON D H) (ON H F) (HANDEMPTY)) 6 | (:goal (AND (ON D F) (ON F E) (ON E H) (ON H C) (ON C A) (ON A G) (ON G B))) 7 | ) -------------------------------------------------------------------------------- /predicators/envs/assets/pddl/blocks/task14.pddl: -------------------------------------------------------------------------------- 1 | (define (problem BLOCKS-8-1) 2 | (:domain BLOCKS) 3 | (:objects B A G C F D H E - block) 4 | (:INIT (CLEAR E) (CLEAR H) (CLEAR D) (CLEAR F) (ONTABLE C) (ONTABLE G) 5 | (ONTABLE D) (ONTABLE F) (ON E C) (ON H A) (ON A B) (ON B G) (HANDEMPTY)) 6 | (:goal (AND (ON C D) (ON D B) (ON B G) (ON G F) (ON F H) (ON H A) (ON A E))) 7 | ) -------------------------------------------------------------------------------- /predicators/envs/assets/pddl/blocks/task15.pddl: -------------------------------------------------------------------------------- 1 | (define (problem BLOCKS-8-2) 2 | (:domain BLOCKS) 3 | (:objects F B G C H E A D - block) 4 | (:INIT (CLEAR D) (CLEAR A) (CLEAR E) (CLEAR H) (CLEAR C) (ONTABLE G) 5 | (ONTABLE A) (ONTABLE E) (ONTABLE H) (ONTABLE C) (ON D B) (ON B F) (ON F G) 6 | (HANDEMPTY)) 7 | (:goal (AND (ON C B) (ON B E) (ON E G) (ON G F) (ON F A) (ON A D) (ON D H))) 8 | ) -------------------------------------------------------------------------------- /predicators/envs/assets/pddl/blocks/task16.pddl: -------------------------------------------------------------------------------- 1 | (define (problem BLOCKS-9-0) 2 | (:domain BLOCKS) 3 | (:objects H D I A E G B F C - block) 4 | (:INIT (CLEAR C) (CLEAR F) (ONTABLE C) (ONTABLE B) (ON F G) (ON G E) (ON E A) 5 | (ON A I) (ON I D) (ON D H) (ON H B) (HANDEMPTY)) 6 | (:goal (AND (ON G D) (ON D B) (ON B C) (ON C A) (ON A I) (ON I F) (ON F E) 7 | (ON E H))) 8 | ) -------------------------------------------------------------------------------- /predicators/envs/assets/pddl/blocks/task17.pddl: -------------------------------------------------------------------------------- 1 | (define (problem BLOCKS-9-1) 2 | (:domain BLOCKS) 3 | (:objects H G I C D B E A F - block) 4 | (:INIT (CLEAR F) (ONTABLE A) (ON F E) (ON E B) (ON B D) (ON D C) (ON C I) 5 | (ON I G) (ON G H) (ON H A) (HANDEMPTY)) 6 | (:goal (AND (ON D I) (ON I A) (ON A B) (ON B H) (ON H G) (ON G F) (ON F E) 7 | (ON E C))) 8 | ) -------------------------------------------------------------------------------- /predicators/envs/assets/pddl/blocks/task18.pddl: -------------------------------------------------------------------------------- 1 | (define (problem BLOCKS-9-2) 2 | (:domain BLOCKS) 3 | (:objects B I C E D A G F H - block) 4 | (:INIT (CLEAR H) (CLEAR F) (ONTABLE G) (ONTABLE F) (ON H A) (ON A D) (ON D E) 5 | (ON E C) (ON C I) (ON I B) (ON B G) (HANDEMPTY)) 6 | (:goal (AND (ON F G) (ON G H) (ON H D) (ON D I) (ON I E) (ON E B) (ON B C) 7 | (ON C A))) 8 | ) 9 | -------------------------------------------------------------------------------- /predicators/envs/assets/pddl/blocks/task19.pddl: -------------------------------------------------------------------------------- 1 | (define (problem BLOCKS-10-0) 2 | (:domain BLOCKS) 3 | (:objects D A H G B J E I F C - block) 4 | (:INIT (CLEAR C) (CLEAR F) (ONTABLE I) (ONTABLE F) (ON C E) (ON E J) (ON J B) 5 | (ON B G) (ON G H) (ON H A) (ON A D) (ON D I) (HANDEMPTY)) 6 | (:goal (AND (ON D C) (ON C F) (ON F J) (ON J E) (ON E H) (ON H B) (ON B A) 7 | (ON A G) (ON G I))) 8 | ) -------------------------------------------------------------------------------- /predicators/envs/assets/pddl/blocks/task2.pddl: -------------------------------------------------------------------------------- 1 | (define (problem BLOCKS-4-1) 2 | (:domain BLOCKS) 3 | (:objects A C D B - block) 4 | (:INIT (CLEAR B) (ONTABLE D) (ON B C) (ON C A) (ON A D) (HANDEMPTY)) 5 | (:goal (AND (ON D C) (ON C A) (ON A B))) 6 | ) -------------------------------------------------------------------------------- /predicators/envs/assets/pddl/blocks/task20.pddl: -------------------------------------------------------------------------------- 1 | (define (problem BLOCKS-10-1) 2 | (:domain BLOCKS) 3 | (:objects D A J I E G H B F C - block) 4 | (:INIT (CLEAR C) (CLEAR F) (ONTABLE B) (ONTABLE H) (ON C G) (ON G E) (ON E I) 5 | (ON I J) (ON J A) (ON A B) (ON F D) (ON D H) (HANDEMPTY)) 6 | (:goal (AND (ON C B) (ON B D) (ON D F) (ON F I) (ON I A) (ON A E) (ON E H) 7 | (ON H G) (ON G J))) 8 | ) -------------------------------------------------------------------------------- /predicators/envs/assets/pddl/blocks/task21.pddl: -------------------------------------------------------------------------------- 1 | (define (problem BLOCKS-10-2) 2 | (:domain BLOCKS) 3 | (:objects B G E D F H I A C J - block) 4 | (:INIT (CLEAR J) (CLEAR C) (ONTABLE A) (ONTABLE C) (ON J I) (ON I H) (ON H F) 5 | (ON F D) (ON D E) (ON E G) (ON G B) (ON B A) (HANDEMPTY)) 6 | (:goal (AND (ON B E) (ON E I) (ON I G) (ON G H) (ON H C) (ON C A) (ON A F) 7 | (ON F J) (ON J D))) 8 | ) -------------------------------------------------------------------------------- /predicators/envs/assets/pddl/blocks/task22.pddl: -------------------------------------------------------------------------------- 1 | (define (problem BLOCKS-11-0) 2 | (:domain BLOCKS) 3 | (:objects F A K H G E D I C J B - block) 4 | (:INIT (CLEAR B) (CLEAR J) (CLEAR C) (ONTABLE I) (ONTABLE D) (ONTABLE E) 5 | (ON B G) (ON G H) (ON H K) (ON K A) (ON A F) (ON F I) (ON J D) (ON C E) 6 | (HANDEMPTY)) 7 | (:goal (AND (ON A J) (ON J D) (ON D B) (ON B H) (ON H K) (ON K I) (ON I F) 8 | (ON F E) (ON E G) (ON G C))) 9 | ) -------------------------------------------------------------------------------- /predicators/envs/assets/pddl/blocks/task23.pddl: -------------------------------------------------------------------------------- 1 | (define (problem BLOCKS-11-1) 2 | (:domain BLOCKS) 3 | (:objects B C E A H K I G D F J - block) 4 | (:INIT (CLEAR J) (CLEAR F) (CLEAR D) (CLEAR G) (ONTABLE I) (ONTABLE K) 5 | (ONTABLE H) (ONTABLE A) (ON J I) (ON F E) (ON E K) (ON D C) (ON C H) (ON G B) 6 | (ON B A) (HANDEMPTY)) 7 | (:goal (AND (ON B D) (ON D J) (ON J K) (ON K H) (ON H A) (ON A C) (ON C F) 8 | (ON F G) (ON G I) (ON I E))) 9 | ) -------------------------------------------------------------------------------- /predicators/envs/assets/pddl/blocks/task24.pddl: -------------------------------------------------------------------------------- 1 | (define (problem BLOCKS-11-2) 2 | (:domain BLOCKS) 3 | (:objects E J D C F K H G A I B - block) 4 | (:INIT (CLEAR B) (CLEAR I) (ONTABLE A) (ONTABLE G) (ON B H) (ON H K) (ON K F) 5 | (ON F C) (ON C D) (ON D J) (ON J A) (ON I E) (ON E G) (HANDEMPTY)) 6 | (:goal (AND (ON I G) (ON G C) (ON C D) (ON D E) (ON E J) (ON J B) (ON B H) 7 | (ON H A) (ON A F) (ON F K))) 8 | ) -------------------------------------------------------------------------------- /predicators/envs/assets/pddl/blocks/task25.pddl: -------------------------------------------------------------------------------- 1 | (define (problem BLOCKS-12-0) 2 | (:domain BLOCKS) 3 | (:objects I D B E K G A F C J L H - block) 4 | (:INIT (CLEAR H) (CLEAR L) (CLEAR J) (ONTABLE C) (ONTABLE F) (ONTABLE J) 5 | (ON H A) (ON A G) (ON G K) (ON K E) (ON E B) (ON B D) (ON D I) (ON I C) 6 | (ON L F) (HANDEMPTY)) 7 | (:goal (AND (ON I C) (ON C B) (ON B L) (ON L D) (ON D J) (ON J E) (ON E K) 8 | (ON K F) (ON F A) (ON A H) (ON H G))) 9 | ) -------------------------------------------------------------------------------- /predicators/envs/assets/pddl/blocks/task26.pddl: -------------------------------------------------------------------------------- 1 | (define (problem BLOCKS-12-1) 2 | (:domain BLOCKS) 3 | (:objects E L A B F I H G D J K C - block) 4 | (:INIT (CLEAR C) (CLEAR K) (ONTABLE J) (ONTABLE D) (ON C G) (ON G H) (ON H I) 5 | (ON I F) (ON F B) (ON B A) (ON A L) (ON L E) (ON E J) (ON K D) (HANDEMPTY)) 6 | (:goal (AND (ON J C) (ON C E) (ON E K) (ON K H) (ON H A) (ON A F) (ON F L) 7 | (ON L G) (ON G B) (ON B I) (ON I D))) 8 | ) -------------------------------------------------------------------------------- /predicators/envs/assets/pddl/blocks/task27.pddl: -------------------------------------------------------------------------------- 1 | (define (problem BLOCKS-13-0) 2 | (:domain BLOCKS) 3 | (:objects L H E A J C D F G K M I B - block) 4 | (:INIT (CLEAR B) (CLEAR I) (CLEAR M) (ONTABLE K) (ONTABLE G) (ONTABLE M) 5 | (ON B F) (ON F D) (ON D C) (ON C J) (ON J A) (ON A E) (ON E H) (ON H L) 6 | (ON L K) (ON I G) (HANDEMPTY)) 7 | (:goal (AND (ON G I) (ON I C) (ON C D) (ON D F) (ON F A) (ON A M) (ON M H) 8 | (ON H E) (ON E L) (ON L J) (ON J B) (ON B K))) 9 | ) -------------------------------------------------------------------------------- /predicators/envs/assets/pddl/blocks/task28.pddl: -------------------------------------------------------------------------------- 1 | (define (problem BLOCKS-13-1) 2 | (:domain BLOCKS) 3 | (:objects I M G H L A C D E K F B J - block) 4 | (:INIT (CLEAR J) (CLEAR B) (ONTABLE F) (ONTABLE K) (ON J E) (ON E D) (ON D C) 5 | (ON C A) (ON A L) (ON L H) (ON H G) (ON G M) (ON M I) (ON I F) (ON B K) 6 | (HANDEMPTY)) 7 | (:goal (AND (ON D A) (ON A E) (ON E L) (ON L M) (ON M C) (ON C J) (ON J F) 8 | (ON F K) (ON K G) (ON G H) (ON H I) (ON I B))) 9 | ) -------------------------------------------------------------------------------- /predicators/envs/assets/pddl/blocks/task29.pddl: -------------------------------------------------------------------------------- 1 | (define (problem BLOCKS-14-0) 2 | (:domain BLOCKS) 3 | (:objects I D B L C K M H J N E F G A - block) 4 | (:INIT (CLEAR A) (CLEAR G) (CLEAR F) (ONTABLE E) (ONTABLE N) (ONTABLE F) 5 | (ON A J) (ON J H) (ON H M) (ON M K) (ON K C) (ON C L) (ON L B) (ON B E) 6 | (ON G D) (ON D I) (ON I N) (HANDEMPTY)) 7 | (:goal (AND (ON E L) (ON L F) (ON F B) (ON B J) (ON J I) (ON I N) (ON N C) 8 | (ON C K) (ON K G) (ON G D) (ON D M) (ON M A) (ON A H))) 9 | ) -------------------------------------------------------------------------------- /predicators/envs/assets/pddl/blocks/task3.pddl: -------------------------------------------------------------------------------- 1 | (define (problem BLOCKS-4-2) 2 | (:domain BLOCKS) 3 | (:objects B D C A - block) 4 | (:INIT (CLEAR A) (CLEAR C) (CLEAR D) (ONTABLE A) (ONTABLE B) (ONTABLE D) 5 | (ON C B) (HANDEMPTY)) 6 | (:goal (AND (ON A B) (ON B C) (ON C D))) 7 | ) -------------------------------------------------------------------------------- /predicators/envs/assets/pddl/blocks/task30.pddl: -------------------------------------------------------------------------------- 1 | (define (problem BLOCKS-14-1) 2 | (:domain BLOCKS) 3 | (:objects K A F L D B M E J N H I C G - block) 4 | (:INIT (CLEAR G) (CLEAR C) (CLEAR I) (CLEAR H) (CLEAR N) (ONTABLE J) 5 | (ONTABLE E) (ONTABLE M) (ONTABLE B) (ONTABLE N) (ON G J) (ON C E) (ON I D) 6 | (ON D L) (ON L M) (ON H F) (ON F A) (ON A K) (ON K B) (HANDEMPTY)) 7 | (:goal (AND (ON J D) (ON D B) (ON B H) (ON H M) (ON M K) (ON K F) (ON F G) 8 | (ON G A) (ON A I) (ON I E) (ON E L) (ON L N) (ON N C))) 9 | ) -------------------------------------------------------------------------------- /predicators/envs/assets/pddl/blocks/task31.pddl: -------------------------------------------------------------------------------- 1 | (define (problem BLOCKS-15-0) 2 | (:domain BLOCKS) 3 | (:objects A C L D J H K O N G I F B M E - block) 4 | (:INIT (CLEAR E) (CLEAR M) (CLEAR B) (CLEAR F) (CLEAR I) (ONTABLE G) 5 | (ONTABLE N) (ONTABLE O) (ONTABLE K) (ONTABLE H) (ON E J) (ON J D) (ON D L) 6 | (ON L C) (ON C G) (ON M N) (ON B A) (ON A O) (ON F K) (ON I H) (HANDEMPTY)) 7 | (:goal (AND (ON G O) (ON O H) (ON H K) (ON K M) (ON M F) (ON F E) (ON E A) 8 | (ON A B) (ON B L) (ON L J) (ON J D) (ON D N) (ON N I) (ON I C))) 9 | ) -------------------------------------------------------------------------------- /predicators/envs/assets/pddl/blocks/task32.pddl: -------------------------------------------------------------------------------- 1 | (define (problem BLOCKS-15-1) 2 | (:domain BLOCKS) 3 | (:objects J B K A D H E N C F L M I O G - block) 4 | (:INIT (CLEAR G) (CLEAR O) (ONTABLE I) (ONTABLE M) (ON G L) (ON L F) (ON F C) 5 | (ON C N) (ON N E) (ON E H) (ON H D) (ON D A) (ON A K) (ON K B) (ON B J) 6 | (ON J I) (ON O M) (HANDEMPTY)) 7 | (:goal (AND (ON D G) (ON G F) (ON F K) (ON K J) (ON J E) (ON E M) (ON M A) 8 | (ON A B) (ON B C) (ON C N) (ON N O) (ON O I) (ON I L) (ON L H))) 9 | ) -------------------------------------------------------------------------------- /predicators/envs/assets/pddl/blocks/task33.pddl: -------------------------------------------------------------------------------- 1 | (define (problem BLOCKS-16-1) 2 | (:domain BLOCKS) 3 | (:objects K C D B I N P J M L G E A O H F - block) 4 | (:INIT (CLEAR F) (CLEAR H) (CLEAR O) (ONTABLE A) (ONTABLE E) (ONTABLE G) 5 | (ON F L) (ON L M) (ON M J) (ON J P) (ON P N) (ON N I) (ON I B) (ON B D) 6 | (ON D C) (ON C K) (ON K A) (ON H E) (ON O G) (HANDEMPTY)) 7 | (:goal (AND (ON D B) (ON B P) (ON P F) (ON F G) (ON G K) (ON K I) (ON I L) 8 | (ON L J) (ON J H) (ON H A) (ON A N) (ON N E) (ON E M) (ON M C) 9 | (ON C O))) 10 | ) -------------------------------------------------------------------------------- /predicators/envs/assets/pddl/blocks/task34.pddl: -------------------------------------------------------------------------------- 1 | (define (problem BLOCKS-16-2) 2 | (:domain BLOCKS) 3 | (:objects K I G N P A D M C B H F O J L E - block) 4 | (:INIT (CLEAR E) (CLEAR L) (ONTABLE J) (ONTABLE O) (ON E F) (ON F H) (ON H B) 5 | (ON B C) (ON C M) (ON M D) (ON D A) (ON A P) (ON P N) (ON N G) (ON G I) 6 | (ON I K) (ON K J) (ON L O) (HANDEMPTY)) 7 | (:goal (AND (ON I D) (ON D H) (ON H F) (ON F B) (ON B K) (ON K J) (ON J G) 8 | (ON G E) (ON E C) (ON C L) (ON L M) (ON M N) (ON N A) (ON A P) 9 | (ON P O))) 10 | ) -------------------------------------------------------------------------------- /predicators/envs/assets/pddl/blocks/task35.pddl: -------------------------------------------------------------------------------- 1 | (define (problem BLOCKS-17-0) 2 | (:domain BLOCKS) 3 | (:objects C D E F B I J A N O K M P H G L Q - block) 4 | (:INIT (CLEAR Q) (CLEAR L) (CLEAR G) (CLEAR H) (CLEAR P) (ONTABLE M) 5 | (ONTABLE K) (ONTABLE O) (ONTABLE N) (ONTABLE P) (ON Q A) (ON A J) (ON J I) 6 | (ON I B) (ON B M) (ON L F) (ON F E) (ON E K) (ON G D) (ON D C) (ON C O) 7 | (ON H N) (HANDEMPTY)) 8 | (:goal (AND (ON Q N) (ON N L) (ON L O) (ON O J) (ON J H) (ON H C) (ON C E) 9 | (ON E M) (ON M P) (ON P A) (ON A G) (ON G B) (ON B I) (ON I K) 10 | (ON K F) (ON F D))) 11 | ) -------------------------------------------------------------------------------- /predicators/envs/assets/pddl/blocks/task4.pddl: -------------------------------------------------------------------------------- 1 | (define (problem BLOCKS-5-0) 2 | (:domain BLOCKS) 3 | (:objects B E A C D - block) 4 | (:INIT (CLEAR D) (CLEAR C) (ONTABLE D) (ONTABLE A) (ON C E) (ON E B) (ON B A) 5 | (HANDEMPTY)) 6 | (:goal (AND (ON A E) (ON E B) (ON B D) (ON D C))) 7 | ) -------------------------------------------------------------------------------- /predicators/envs/assets/pddl/blocks/task5.pddl: -------------------------------------------------------------------------------- 1 | (define (problem BLOCKS-5-1) 2 | (:domain BLOCKS) 3 | (:objects A D C E B - block) 4 | (:INIT (CLEAR B) (CLEAR E) (CLEAR C) (ONTABLE D) (ONTABLE E) (ONTABLE C) 5 | (ON B A) (ON A D) (HANDEMPTY)) 6 | (:goal (AND (ON D C) (ON C B) (ON B A) (ON A E))) 7 | ) -------------------------------------------------------------------------------- /predicators/envs/assets/pddl/blocks/task6.pddl: -------------------------------------------------------------------------------- 1 | (define (problem BLOCKS-5-2) 2 | (:domain BLOCKS) 3 | (:objects A C E B D - block) 4 | (:INIT (CLEAR D) (ONTABLE B) (ON D E) (ON E C) (ON C A) (ON A B) (HANDEMPTY)) 5 | (:goal (AND (ON D C) (ON C B) (ON B E) (ON E A))) 6 | ) -------------------------------------------------------------------------------- /predicators/envs/assets/pddl/blocks/task7.pddl: -------------------------------------------------------------------------------- 1 | (define (problem BLOCKS-6-0) 2 | (:domain BLOCKS) 3 | (:objects E A B C F D - block) 4 | (:INIT (CLEAR D) (CLEAR F) (ONTABLE C) (ONTABLE B) (ON D A) (ON A C) (ON F E) 5 | (ON E B) (HANDEMPTY)) 6 | (:goal (AND (ON C B) (ON B A) (ON A E) (ON E F) (ON F D))) 7 | ) -------------------------------------------------------------------------------- /predicators/envs/assets/pddl/blocks/task8.pddl: -------------------------------------------------------------------------------- 1 | (define (problem BLOCKS-6-1) 2 | (:domain BLOCKS) 3 | (:objects F D C E B A - block) 4 | (:INIT (CLEAR A) (CLEAR B) (CLEAR E) (CLEAR C) (CLEAR D) (ONTABLE F) 5 | (ONTABLE B) (ONTABLE E) (ONTABLE C) (ONTABLE D) (ON A F) (HANDEMPTY)) 6 | (:goal (AND (ON E F) (ON F C) (ON C B) (ON B A) (ON A D))) 7 | ) -------------------------------------------------------------------------------- /predicators/envs/assets/pddl/blocks/task9.pddl: -------------------------------------------------------------------------------- 1 | (define (problem BLOCKS-6-2) 2 | (:domain BLOCKS) 3 | (:objects E F B D C A - block) 4 | (:INIT (CLEAR A) (ONTABLE C) (ON A D) (ON D B) (ON B F) (ON F E) (ON E C) 5 | (HANDEMPTY)) 6 | (:goal (AND (ON E F) (ON F A) (ON A B) (ON B C) (ON C D))) 7 | ) -------------------------------------------------------------------------------- /predicators/envs/assets/pddl/delivery/domain.pddl: -------------------------------------------------------------------------------- 1 | (define (domain delivery) 2 | (:requirements :strips :typing) 3 | (:types loc paper) 4 | (:predicates 5 | (at ?loc - loc) 6 | (isHomeBase ?loc - loc) 7 | (satisfied ?loc - loc) 8 | (wantsPaper ?loc - loc) 9 | (safe ?loc - loc) 10 | (unpacked ?paper - paper) 11 | (carrying ?paper - paper) 12 | ) 13 | 14 | (:action pick-up 15 | :parameters (?paper - paper ?loc - loc) 16 | :precondition (and 17 | (at ?loc) 18 | (isHomeBase ?loc) 19 | (unpacked ?paper) 20 | ) 21 | :effect (and 22 | (not (unpacked ?paper)) 23 | (carrying ?paper) 24 | ) 25 | ) 26 | 27 | (:action move 28 | :parameters (?from - loc ?to - loc) 29 | :precondition (and 30 | (at ?from) 31 | (safe ?from) 32 | ) 33 | :effect (and 34 | (not (at ?from)) 35 | (at ?to) 36 | ) 37 | ) 38 | 39 | (:action deliver 40 | :parameters (?paper - paper ?loc - loc) 41 | :precondition (and 42 | (at ?loc) 43 | (carrying ?paper) 44 | ) 45 | :effect (and 46 | (not (carrying ?paper)) 47 | (not (wantsPaper ?loc)) 48 | (satisfied ?loc) 49 | ) 50 | ) 51 | 52 | ) 53 | -------------------------------------------------------------------------------- /predicators/envs/assets/pddl/ferry/domain.pddl: -------------------------------------------------------------------------------- 1 | (define (domain ferry) 2 | (:predicates (not-eq ?x ?y) 3 | (car ?c) 4 | (location ?l) 5 | (at-ferry ?l) 6 | (at ?c ?l) 7 | (empty-ferry) 8 | (on ?c)) 9 | 10 | (:action sail 11 | :parameters (?from ?to) 12 | :precondition (and (not-eq ?from ?to) 13 | (location ?from) (location ?to) (at-ferry ?from)) 14 | :effect (and (at-ferry ?to) 15 | (not (at-ferry ?from)))) 16 | 17 | 18 | (:action board 19 | :parameters (?car ?loc) 20 | :precondition (and (car ?car) (location ?loc) 21 | (at ?car ?loc) (at-ferry ?loc) (empty-ferry)) 22 | :effect (and (on ?car) 23 | (not (at ?car ?loc)) 24 | (not (empty-ferry)))) 25 | 26 | (:action debark 27 | :parameters (?car ?loc) 28 | :precondition (and (car ?car) (location ?loc) 29 | (on ?car) (at-ferry ?loc)) 30 | :effect (and (at ?car ?loc) 31 | (empty-ferry) 32 | (not (on ?car))))) 33 | -------------------------------------------------------------------------------- /predicators/envs/assets/pddl/forest/domain.pddl: -------------------------------------------------------------------------------- 1 | (define (domain forest) 2 | (:requirements :strips :typing) 3 | (:types loc) 4 | 5 | (:predicates 6 | (at ?loc - loc) 7 | (isNotWater ?loc - loc) 8 | (isHill ?loc - loc) 9 | (isNotHill ?loc - loc) 10 | (adjacent ?loc1 - loc ?loc2 - loc) 11 | (onTrail ?from - loc ?to - loc) 12 | ) 13 | 14 | (:action walk 15 | :parameters (?from - loc ?to - loc) 16 | :precondition (and 17 | (isNotHill ?to) 18 | (at ?from) 19 | (adjacent ?from ?to) 20 | (isNotWater ?from)) 21 | :effect (and (at ?to) (not (at ?from))) 22 | ) 23 | 24 | (:action climb 25 | :parameters (?from - loc ?to - loc) 26 | :precondition (and 27 | (isHill ?to) 28 | (at ?from) 29 | (adjacent ?from ?to) 30 | (isNotWater ?from)) 31 | :effect (and (at ?to) (not (at ?from))) 32 | ) 33 | 34 | 35 | ) -------------------------------------------------------------------------------- /predicators/envs/assets/pddl/gripper/domain.pddl: -------------------------------------------------------------------------------- 1 | 2 | (define (domain gripper) 3 | (:predicates (room ?r) 4 | (ball ?b) 5 | (gripper ?g) 6 | (at-robby ?r) 7 | (at ?b ?r) 8 | (free ?g) 9 | (carry ?o ?g)) 10 | 11 | (:action move 12 | :parameters (?from ?to) 13 | :precondition (and (room ?from) (room ?to) (at-robby ?from)) 14 | :effect (and (at-robby ?to) 15 | (not (at-robby ?from)))) 16 | 17 | 18 | 19 | (:action pick 20 | :parameters (?obj ?room ?gripper) 21 | :precondition (and (ball ?obj) (room ?room) (gripper ?gripper) 22 | (at ?obj ?room) (at-robby ?room) (free ?gripper)) 23 | :effect (and (carry ?obj ?gripper) 24 | (not (at ?obj ?room)) 25 | (not (free ?gripper)))) 26 | 27 | 28 | (:action drop 29 | :parameters (?obj ?room ?gripper) 30 | :precondition (and (ball ?obj) (room ?room) (gripper ?gripper) 31 | (carry ?obj ?gripper) (at-robby ?room)) 32 | :effect (and (at ?obj ?room) 33 | (free ?gripper) 34 | (not (carry ?obj ?gripper))))) -------------------------------------------------------------------------------- /predicators/envs/assets/pddl/gripper/prefixed_domain.pddl: -------------------------------------------------------------------------------- 1 | (define (domain pregripper) 2 | (:predicates (preroom ?r) 3 | (preball ?b) 4 | (pregripper ?g) 5 | (preat-robby ?r) 6 | (preat ?b ?r) 7 | (prefree ?g) 8 | (precarry ?o ?g)) 9 | 10 | (:action move 11 | :parameters (?from ?to) 12 | :precondition (and (preroom ?from) (preroom ?to) (preat-robby ?from)) 13 | :effect (and (preat-robby ?to) 14 | (not (preat-robby ?from)))) 15 | 16 | 17 | 18 | (:action pick 19 | :parameters (?obj ?preroom ?pregripper) 20 | :precondition (and (preball ?obj) (preroom ?preroom) (pregripper ?pregripper) 21 | (preat ?obj ?preroom) (preat-robby ?preroom) (prefree ?pregripper)) 22 | :effect (and (precarry ?obj ?pregripper) 23 | (not (preat ?obj ?preroom)) 24 | (not (prefree ?pregripper)))) 25 | 26 | 27 | (:action drop 28 | :parameters (?obj ?preroom ?pregripper) 29 | :precondition (and (preball ?obj) (preroom ?preroom) (pregripper ?pregripper) 30 | (precarry ?obj ?pregripper) (preat-robby ?preroom)) 31 | :effect (and (preat ?obj ?preroom) 32 | (prefree ?pregripper) 33 | (not (precarry ?obj ?pregripper))))) -------------------------------------------------------------------------------- /predicators/envs/assets/pddl/miconic/domain.pddl: -------------------------------------------------------------------------------- 1 | (define (domain miconic) 2 | (:requirements :strips) 3 | (:types passenger - object 4 | floor - object 5 | ) 6 | 7 | (:predicates 8 | (origin ?person - passenger ?floor - floor) 9 | (destin ?person - passenger ?floor - floor) 10 | (above ?floor1 - floor ?floor2 - floor) 11 | (boarded ?person - passenger) 12 | (served ?person - passenger) 13 | (lift-at ?floor - floor) 14 | ) 15 | 16 | (:action board 17 | :parameters (?f - floor ?p - passenger) 18 | :precondition (and (lift-at ?f) 19 | (origin ?p ?f) 20 | ) 21 | :effect (and (boarded ?p) 22 | ) 23 | ) 24 | 25 | (:action depart 26 | :parameters (?f - floor ?p - passenger) 27 | :precondition (and (lift-at ?f) 28 | (destin ?p ?f) 29 | (boarded ?p) 30 | ) 31 | :effect (and (not (boarded ?p)) 32 | (served ?p) 33 | ) 34 | ) 35 | 36 | (:action up 37 | :parameters (?f1 - floor ?f2 - floor) 38 | :precondition (and (lift-at ?f1) 39 | (above ?f1 ?f2) 40 | ) 41 | :effect (and (lift-at ?f2) 42 | (not (lift-at ?f1)) 43 | ) 44 | ) 45 | 46 | (:action down 47 | :parameters (?f1 - floor ?f2 - floor) 48 | :precondition (and (lift-at ?f1) 49 | (above ?f2 ?f1) 50 | ) 51 | :effect (and (lift-at ?f2) 52 | (not (lift-at ?f1)) 53 | ) 54 | ) 55 | ) 56 | -------------------------------------------------------------------------------- /predicators/envs/assets/pddl/spannerlearning/domain.pddl: -------------------------------------------------------------------------------- 1 | (define (domain spanner) 2 | (:requirements :typing :strips) 3 | (:types 4 | location locatable - object 5 | man nut spanner - locatable 6 | ) 7 | 8 | (:predicates 9 | (at ?m - locatable ?l - location) 10 | (carrying ?m - man ?s - spanner) 11 | (useable ?s - spanner) 12 | (link ?l1 - location ?l2 - location) 13 | (tightened ?n - nut) 14 | (loose ?n - nut)) 15 | 16 | (:action walk 17 | :parameters (?start - location ?end - location ?m - man) 18 | :precondition (and (at ?m ?start) 19 | (link ?start ?end)) 20 | :effect (and (not (at ?m ?start)) (at ?m ?end))) 21 | 22 | (:action pickup_spanner 23 | :parameters (?l - location ?s - spanner ?m - man) 24 | :precondition (and (at ?m ?l) 25 | (at ?s ?l)) 26 | :effect (and (not (at ?s ?l)) 27 | (carrying ?m ?s))) 28 | 29 | (:action tighten_nut 30 | :parameters (?l - location ?s - spanner ?m - man ?n - nut) 31 | :precondition (and (at ?m ?l) 32 | (at ?n ?l) 33 | (carrying ?m ?s) 34 | (useable ?s) 35 | (loose ?n)) 36 | :effect (and (not (loose ?n))(not (useable ?s)) (tightened ?n))) 37 | ) 38 | -------------------------------------------------------------------------------- /predicators/envs/assets/urdf/fetch_description/meshes/base_link_collision.STL: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Learning-and-Intelligent-Systems/predicators/5bd3f5bd21cc01e171faf748edf53bcfd720f4d1/predicators/envs/assets/urdf/fetch_description/meshes/base_link_collision.STL -------------------------------------------------------------------------------- /predicators/envs/assets/urdf/fetch_description/meshes/base_link_uv.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Learning-and-Intelligent-Systems/predicators/5bd3f5bd21cc01e171faf748edf53bcfd720f4d1/predicators/envs/assets/urdf/fetch_description/meshes/base_link_uv.png -------------------------------------------------------------------------------- /predicators/envs/assets/urdf/fetch_description/meshes/bellows_link.STL: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Learning-and-Intelligent-Systems/predicators/5bd3f5bd21cc01e171faf748edf53bcfd720f4d1/predicators/envs/assets/urdf/fetch_description/meshes/bellows_link.STL -------------------------------------------------------------------------------- /predicators/envs/assets/urdf/fetch_description/meshes/bellows_link_collision.STL: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Learning-and-Intelligent-Systems/predicators/5bd3f5bd21cc01e171faf748edf53bcfd720f4d1/predicators/envs/assets/urdf/fetch_description/meshes/bellows_link_collision.STL -------------------------------------------------------------------------------- /predicators/envs/assets/urdf/fetch_description/meshes/elbow_flex_link_collision.STL: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Learning-and-Intelligent-Systems/predicators/5bd3f5bd21cc01e171faf748edf53bcfd720f4d1/predicators/envs/assets/urdf/fetch_description/meshes/elbow_flex_link_collision.STL -------------------------------------------------------------------------------- /predicators/envs/assets/urdf/fetch_description/meshes/elbow_flex_uv.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Learning-and-Intelligent-Systems/predicators/5bd3f5bd21cc01e171faf748edf53bcfd720f4d1/predicators/envs/assets/urdf/fetch_description/meshes/elbow_flex_uv.png -------------------------------------------------------------------------------- /predicators/envs/assets/urdf/fetch_description/meshes/estop_link.STL: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Learning-and-Intelligent-Systems/predicators/5bd3f5bd21cc01e171faf748edf53bcfd720f4d1/predicators/envs/assets/urdf/fetch_description/meshes/estop_link.STL -------------------------------------------------------------------------------- /predicators/envs/assets/urdf/fetch_description/meshes/forearm_roll_link_collision.STL: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Learning-and-Intelligent-Systems/predicators/5bd3f5bd21cc01e171faf748edf53bcfd720f4d1/predicators/envs/assets/urdf/fetch_description/meshes/forearm_roll_link_collision.STL -------------------------------------------------------------------------------- /predicators/envs/assets/urdf/fetch_description/meshes/forearm_roll_uv.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Learning-and-Intelligent-Systems/predicators/5bd3f5bd21cc01e171faf748edf53bcfd720f4d1/predicators/envs/assets/urdf/fetch_description/meshes/forearm_roll_uv.png -------------------------------------------------------------------------------- /predicators/envs/assets/urdf/fetch_description/meshes/gripper_link.STL: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Learning-and-Intelligent-Systems/predicators/5bd3f5bd21cc01e171faf748edf53bcfd720f4d1/predicators/envs/assets/urdf/fetch_description/meshes/gripper_link.STL -------------------------------------------------------------------------------- /predicators/envs/assets/urdf/fetch_description/meshes/gripper_uv.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Learning-and-Intelligent-Systems/predicators/5bd3f5bd21cc01e171faf748edf53bcfd720f4d1/predicators/envs/assets/urdf/fetch_description/meshes/gripper_uv.png -------------------------------------------------------------------------------- /predicators/envs/assets/urdf/fetch_description/meshes/head_pan_link_collision.STL: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Learning-and-Intelligent-Systems/predicators/5bd3f5bd21cc01e171faf748edf53bcfd720f4d1/predicators/envs/assets/urdf/fetch_description/meshes/head_pan_link_collision.STL -------------------------------------------------------------------------------- /predicators/envs/assets/urdf/fetch_description/meshes/head_pan_uv.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Learning-and-Intelligent-Systems/predicators/5bd3f5bd21cc01e171faf748edf53bcfd720f4d1/predicators/envs/assets/urdf/fetch_description/meshes/head_pan_uv.png -------------------------------------------------------------------------------- /predicators/envs/assets/urdf/fetch_description/meshes/head_tilt_link_collision.STL: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Learning-and-Intelligent-Systems/predicators/5bd3f5bd21cc01e171faf748edf53bcfd720f4d1/predicators/envs/assets/urdf/fetch_description/meshes/head_tilt_link_collision.STL -------------------------------------------------------------------------------- /predicators/envs/assets/urdf/fetch_description/meshes/head_tilt_uv.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Learning-and-Intelligent-Systems/predicators/5bd3f5bd21cc01e171faf748edf53bcfd720f4d1/predicators/envs/assets/urdf/fetch_description/meshes/head_tilt_uv.png -------------------------------------------------------------------------------- /predicators/envs/assets/urdf/fetch_description/meshes/l_gripper_finger_link.STL: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Learning-and-Intelligent-Systems/predicators/5bd3f5bd21cc01e171faf748edf53bcfd720f4d1/predicators/envs/assets/urdf/fetch_description/meshes/l_gripper_finger_link.STL -------------------------------------------------------------------------------- /predicators/envs/assets/urdf/fetch_description/meshes/l_wheel_link.STL: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Learning-and-Intelligent-Systems/predicators/5bd3f5bd21cc01e171faf748edf53bcfd720f4d1/predicators/envs/assets/urdf/fetch_description/meshes/l_wheel_link.STL -------------------------------------------------------------------------------- /predicators/envs/assets/urdf/fetch_description/meshes/l_wheel_link_collision.STL: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Learning-and-Intelligent-Systems/predicators/5bd3f5bd21cc01e171faf748edf53bcfd720f4d1/predicators/envs/assets/urdf/fetch_description/meshes/l_wheel_link_collision.STL -------------------------------------------------------------------------------- /predicators/envs/assets/urdf/fetch_description/meshes/laser_link.STL: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Learning-and-Intelligent-Systems/predicators/5bd3f5bd21cc01e171faf748edf53bcfd720f4d1/predicators/envs/assets/urdf/fetch_description/meshes/laser_link.STL -------------------------------------------------------------------------------- /predicators/envs/assets/urdf/fetch_description/meshes/r_gripper_finger_link.STL: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Learning-and-Intelligent-Systems/predicators/5bd3f5bd21cc01e171faf748edf53bcfd720f4d1/predicators/envs/assets/urdf/fetch_description/meshes/r_gripper_finger_link.STL -------------------------------------------------------------------------------- /predicators/envs/assets/urdf/fetch_description/meshes/r_wheel_link.STL: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Learning-and-Intelligent-Systems/predicators/5bd3f5bd21cc01e171faf748edf53bcfd720f4d1/predicators/envs/assets/urdf/fetch_description/meshes/r_wheel_link.STL -------------------------------------------------------------------------------- /predicators/envs/assets/urdf/fetch_description/meshes/r_wheel_link_collision.STL: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Learning-and-Intelligent-Systems/predicators/5bd3f5bd21cc01e171faf748edf53bcfd720f4d1/predicators/envs/assets/urdf/fetch_description/meshes/r_wheel_link_collision.STL -------------------------------------------------------------------------------- /predicators/envs/assets/urdf/fetch_description/meshes/shoulder_lift_link_collision.STL: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Learning-and-Intelligent-Systems/predicators/5bd3f5bd21cc01e171faf748edf53bcfd720f4d1/predicators/envs/assets/urdf/fetch_description/meshes/shoulder_lift_link_collision.STL -------------------------------------------------------------------------------- /predicators/envs/assets/urdf/fetch_description/meshes/shoulder_lift_uv.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Learning-and-Intelligent-Systems/predicators/5bd3f5bd21cc01e171faf748edf53bcfd720f4d1/predicators/envs/assets/urdf/fetch_description/meshes/shoulder_lift_uv.png -------------------------------------------------------------------------------- /predicators/envs/assets/urdf/fetch_description/meshes/shoulder_pan_link_collision.STL: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Learning-and-Intelligent-Systems/predicators/5bd3f5bd21cc01e171faf748edf53bcfd720f4d1/predicators/envs/assets/urdf/fetch_description/meshes/shoulder_pan_link_collision.STL -------------------------------------------------------------------------------- /predicators/envs/assets/urdf/fetch_description/meshes/shoulder_pan_uv.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Learning-and-Intelligent-Systems/predicators/5bd3f5bd21cc01e171faf748edf53bcfd720f4d1/predicators/envs/assets/urdf/fetch_description/meshes/shoulder_pan_uv.png -------------------------------------------------------------------------------- /predicators/envs/assets/urdf/fetch_description/meshes/torso_fixed_link.STL: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Learning-and-Intelligent-Systems/predicators/5bd3f5bd21cc01e171faf748edf53bcfd720f4d1/predicators/envs/assets/urdf/fetch_description/meshes/torso_fixed_link.STL -------------------------------------------------------------------------------- /predicators/envs/assets/urdf/fetch_description/meshes/torso_fixed_uv.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Learning-and-Intelligent-Systems/predicators/5bd3f5bd21cc01e171faf748edf53bcfd720f4d1/predicators/envs/assets/urdf/fetch_description/meshes/torso_fixed_uv.png -------------------------------------------------------------------------------- /predicators/envs/assets/urdf/fetch_description/meshes/torso_lift_link_collision.STL: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Learning-and-Intelligent-Systems/predicators/5bd3f5bd21cc01e171faf748edf53bcfd720f4d1/predicators/envs/assets/urdf/fetch_description/meshes/torso_lift_link_collision.STL -------------------------------------------------------------------------------- /predicators/envs/assets/urdf/fetch_description/meshes/torso_lift_uv.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Learning-and-Intelligent-Systems/predicators/5bd3f5bd21cc01e171faf748edf53bcfd720f4d1/predicators/envs/assets/urdf/fetch_description/meshes/torso_lift_uv.png -------------------------------------------------------------------------------- /predicators/envs/assets/urdf/fetch_description/meshes/upperarm_roll_link_collision.STL: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Learning-and-Intelligent-Systems/predicators/5bd3f5bd21cc01e171faf748edf53bcfd720f4d1/predicators/envs/assets/urdf/fetch_description/meshes/upperarm_roll_link_collision.STL -------------------------------------------------------------------------------- /predicators/envs/assets/urdf/fetch_description/meshes/upperarm_roll_uv.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Learning-and-Intelligent-Systems/predicators/5bd3f5bd21cc01e171faf748edf53bcfd720f4d1/predicators/envs/assets/urdf/fetch_description/meshes/upperarm_roll_uv.png -------------------------------------------------------------------------------- /predicators/envs/assets/urdf/fetch_description/meshes/wrist_flex_link_collision.STL: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Learning-and-Intelligent-Systems/predicators/5bd3f5bd21cc01e171faf748edf53bcfd720f4d1/predicators/envs/assets/urdf/fetch_description/meshes/wrist_flex_link_collision.STL -------------------------------------------------------------------------------- /predicators/envs/assets/urdf/fetch_description/meshes/wrist_flex_uv.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Learning-and-Intelligent-Systems/predicators/5bd3f5bd21cc01e171faf748edf53bcfd720f4d1/predicators/envs/assets/urdf/fetch_description/meshes/wrist_flex_uv.png -------------------------------------------------------------------------------- /predicators/envs/assets/urdf/fetch_description/meshes/wrist_roll_link_collision.STL: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Learning-and-Intelligent-Systems/predicators/5bd3f5bd21cc01e171faf748edf53bcfd720f4d1/predicators/envs/assets/urdf/fetch_description/meshes/wrist_roll_link_collision.STL -------------------------------------------------------------------------------- /predicators/envs/assets/urdf/fetch_description/meshes/wrist_roll_uv.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Learning-and-Intelligent-Systems/predicators/5bd3f5bd21cc01e171faf748edf53bcfd720f4d1/predicators/envs/assets/urdf/fetch_description/meshes/wrist_roll_uv.png -------------------------------------------------------------------------------- /predicators/envs/assets/urdf/franka_description/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8.3) 2 | project(franka_description) 3 | 4 | find_package(catkin REQUIRED) 5 | catkin_package(CATKIN_DEPENDS xacro) 6 | 7 | install(DIRECTORY meshes 8 | DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION} 9 | ) 10 | install(DIRECTORY robots 11 | DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION} 12 | ) 13 | -------------------------------------------------------------------------------- /predicators/envs/assets/urdf/franka_description/mainpage.dox: -------------------------------------------------------------------------------- 1 | /** 2 | * @mainpage 3 | * @htmlinclude "manifest.html" 4 | * 5 | * Overview page for Franka Emika research robots: https://frankaemika.github.io 6 | */ 7 | -------------------------------------------------------------------------------- /predicators/envs/assets/urdf/franka_description/meshes/collision/finger.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Learning-and-Intelligent-Systems/predicators/5bd3f5bd21cc01e171faf748edf53bcfd720f4d1/predicators/envs/assets/urdf/franka_description/meshes/collision/finger.stl -------------------------------------------------------------------------------- /predicators/envs/assets/urdf/franka_description/meshes/collision/hand.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Learning-and-Intelligent-Systems/predicators/5bd3f5bd21cc01e171faf748edf53bcfd720f4d1/predicators/envs/assets/urdf/franka_description/meshes/collision/hand.stl -------------------------------------------------------------------------------- /predicators/envs/assets/urdf/franka_description/meshes/collision/link0.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Learning-and-Intelligent-Systems/predicators/5bd3f5bd21cc01e171faf748edf53bcfd720f4d1/predicators/envs/assets/urdf/franka_description/meshes/collision/link0.stl -------------------------------------------------------------------------------- /predicators/envs/assets/urdf/franka_description/meshes/collision/link1.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Learning-and-Intelligent-Systems/predicators/5bd3f5bd21cc01e171faf748edf53bcfd720f4d1/predicators/envs/assets/urdf/franka_description/meshes/collision/link1.stl -------------------------------------------------------------------------------- /predicators/envs/assets/urdf/franka_description/meshes/collision/link2.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Learning-and-Intelligent-Systems/predicators/5bd3f5bd21cc01e171faf748edf53bcfd720f4d1/predicators/envs/assets/urdf/franka_description/meshes/collision/link2.stl -------------------------------------------------------------------------------- /predicators/envs/assets/urdf/franka_description/meshes/collision/link3.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Learning-and-Intelligent-Systems/predicators/5bd3f5bd21cc01e171faf748edf53bcfd720f4d1/predicators/envs/assets/urdf/franka_description/meshes/collision/link3.stl -------------------------------------------------------------------------------- /predicators/envs/assets/urdf/franka_description/meshes/collision/link4.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Learning-and-Intelligent-Systems/predicators/5bd3f5bd21cc01e171faf748edf53bcfd720f4d1/predicators/envs/assets/urdf/franka_description/meshes/collision/link4.stl -------------------------------------------------------------------------------- /predicators/envs/assets/urdf/franka_description/meshes/collision/link5.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Learning-and-Intelligent-Systems/predicators/5bd3f5bd21cc01e171faf748edf53bcfd720f4d1/predicators/envs/assets/urdf/franka_description/meshes/collision/link5.stl -------------------------------------------------------------------------------- /predicators/envs/assets/urdf/franka_description/meshes/collision/link6.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Learning-and-Intelligent-Systems/predicators/5bd3f5bd21cc01e171faf748edf53bcfd720f4d1/predicators/envs/assets/urdf/franka_description/meshes/collision/link6.stl -------------------------------------------------------------------------------- /predicators/envs/assets/urdf/franka_description/meshes/collision/link7.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Learning-and-Intelligent-Systems/predicators/5bd3f5bd21cc01e171faf748edf53bcfd720f4d1/predicators/envs/assets/urdf/franka_description/meshes/collision/link7.stl -------------------------------------------------------------------------------- /predicators/envs/assets/urdf/franka_description/package.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | franka_description 4 | 0.7.0 5 | franka_description contains URDF files and meshes of Franka Emika robots 6 | Franka Emika GmbH 7 | Apache 2.0 8 | 9 | http://wiki.ros.org/franka_description 10 | https://github.com/frankaemika/franka_ros 11 | https://github.com/frankaemika/franka_ros/issues 12 | Franka Emika GmbH 13 | 14 | catkin 15 | 16 | xacro 17 | 18 | -------------------------------------------------------------------------------- /predicators/envs/assets/urdf/franka_description/robots/hand.urdf.xacro: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /predicators/envs/assets/urdf/franka_description/robots/panda_arm.urdf.xacro: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /predicators/envs/assets/urdf/franka_description/robots/panda_arm_hand.urdf.xacro: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /predicators/envs/assets/urdf/franka_description/rosdoc.yaml: -------------------------------------------------------------------------------- 1 | - builder: doxygen 2 | javadoc_autobrief: YES 3 | -------------------------------------------------------------------------------- /predicators/envs/assets/urdf/plane.obj: -------------------------------------------------------------------------------- 1 | # Blender v2.66 (sub 1) OBJ File: '' 2 | # www.blender.org 3 | mtllib plane.mtl 4 | o Plane 5 | v 15.000000 -15.000000 0.000000 6 | v 15.000000 15.000000 0.000000 7 | v -15.000000 15.000000 0.000000 8 | v -15.000000 -15.000000 0.000000 9 | 10 | vt 15.000000 0.000000 11 | vt 15.000000 15.000000 12 | vt 0.000000 15.000000 13 | vt 0.000000 0.000000 14 | 15 | usemtl Material 16 | s off 17 | f 1/1 2/2 3/3 18 | f 1/1 3/3 4/4 19 | -------------------------------------------------------------------------------- /predicators/envs/assets/urdf/plane.urdf: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /predicators/envs/assets/urdf/table.obj: -------------------------------------------------------------------------------- 1 | # table.obj 2 | # 3 | 4 | o table 5 | mtllib table.mtl 6 | 7 | v -0.500000 -0.500000 0.500000 8 | v 0.500000 -0.500000 0.500000 9 | v -0.500000 0.500000 0.500000 10 | v 0.500000 0.500000 0.500000 11 | v -0.500000 0.500000 -0.500000 12 | v 0.500000 0.500000 -0.500000 13 | v -0.500000 -0.500000 -0.500000 14 | v 0.500000 -0.500000 -0.500000 15 | 16 | vt 0.000000 0.000000 17 | vt 1.000000 0.000000 18 | vt 0.000000 1.000000 19 | vt 1.000000 1.000000 20 | 21 | vn 0.000000 0.000000 1.000000 22 | vn 0.000000 1.000000 0.000000 23 | vn 0.000000 0.000000 -1.000000 24 | vn 0.000000 -1.000000 0.000000 25 | vn 1.000000 0.000000 0.000000 26 | vn -1.000000 0.000000 0.000000 27 | 28 | g table 29 | usemtl table 30 | s 1 31 | f 1/1/1 2/2/1 3/3/1 32 | f 3/3/1 2/2/1 4/4/1 33 | s 2 34 | f 3/1/2 4/2/2 5/3/2 35 | f 5/3/2 4/2/2 6/4/2 36 | s 3 37 | f 5/4/3 6/3/3 7/2/3 38 | f 7/2/3 6/3/3 8/1/3 39 | s 4 40 | f 7/1/4 8/2/4 1/3/4 41 | f 1/3/4 8/2/4 2/4/4 42 | s 5 43 | f 2/1/5 8/2/5 4/3/5 44 | f 4/3/5 8/2/5 6/4/5 45 | s 6 46 | f 7/1/6 1/2/6 5/3/6 47 | f 5/3/6 1/2/6 3/4/6 48 | 49 | -------------------------------------------------------------------------------- /predicators/envs/assets/urdf/table.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Learning-and-Intelligent-Systems/predicators/5bd3f5bd21cc01e171faf748edf53bcfd720f4d1/predicators/envs/assets/urdf/table.png -------------------------------------------------------------------------------- /predicators/envs/assets/urdf/table.urdf: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /predicators/execution_monitoring/__init__.py: -------------------------------------------------------------------------------- 1 | """Handle creation of execution monitors.""" 2 | 3 | from predicators import utils 4 | from predicators.execution_monitoring.base_execution_monitor import \ 5 | BaseExecutionMonitor 6 | 7 | __all__ = ["BaseExecutionMonitor"] 8 | 9 | # Find the subclasses. 10 | utils.import_submodules(__path__, __name__) 11 | 12 | 13 | def create_execution_monitor(name: str, ) -> BaseExecutionMonitor: 14 | """Create an execution monitor given its name.""" 15 | for cls in utils.get_all_subclasses(BaseExecutionMonitor): 16 | if not cls.__abstractmethods__ and cls.get_name() == name: 17 | execution_monitor = cls() 18 | break 19 | else: 20 | raise NotImplementedError(f"Unrecognized execution monitor: {name}") 21 | return execution_monitor 22 | -------------------------------------------------------------------------------- /predicators/execution_monitoring/base_execution_monitor.py: -------------------------------------------------------------------------------- 1 | """Base class for execution monitors.""" 2 | 3 | import abc 4 | from typing import Any, List 5 | 6 | from predicators.structs import State, Task 7 | 8 | 9 | class BaseExecutionMonitor(abc.ABC): 10 | """An execution monitor consumes states and decides whether to replan.""" 11 | 12 | def __init__(self) -> None: 13 | self._approach_info: List[Any] = [] 14 | self._curr_plan_timestep = 0 15 | 16 | @classmethod 17 | @abc.abstractmethod 18 | def get_name(cls) -> str: 19 | """Get the unique name of this execution monitor.""" 20 | 21 | def reset(self, task: Task) -> None: 22 | """Reset after replanning.""" 23 | del task # unused 24 | self._curr_plan_timestep = 0 25 | self._approach_info = [] 26 | 27 | @abc.abstractmethod 28 | def step(self, state: State) -> bool: 29 | """Return true if the agent should replan.""" 30 | 31 | def update_approach_info(self, info: List[Any]) -> None: 32 | """Update internal info received from approach.""" 33 | self._approach_info = info 34 | -------------------------------------------------------------------------------- /predicators/execution_monitoring/mpc_execution_monitor.py: -------------------------------------------------------------------------------- 1 | """A model-predictive control monitor that always suggests replanning.""" 2 | from predicators.execution_monitoring.base_execution_monitor import \ 3 | BaseExecutionMonitor 4 | from predicators.structs import State 5 | 6 | 7 | class MpcExecutionMonitor(BaseExecutionMonitor): 8 | """A model-predictive control monitor that always suggests replanning.""" 9 | 10 | @classmethod 11 | def get_name(cls) -> str: 12 | return "mpc" 13 | 14 | def step(self, state: State) -> bool: 15 | # Don't trigger replanning on the 0th 16 | # timestep. 17 | if self._curr_plan_timestep == 0: 18 | self._curr_plan_timestep += 1 19 | return False 20 | # Otherwise, trigger replanning. 21 | return True 22 | -------------------------------------------------------------------------------- /predicators/execution_monitoring/trivial_execution_monitor.py: -------------------------------------------------------------------------------- 1 | """A trivial execution monitor that never suggests replanning.""" 2 | 3 | from predicators.execution_monitoring.base_execution_monitor import \ 4 | BaseExecutionMonitor 5 | from predicators.structs import State, Task 6 | 7 | 8 | class TrivialExecutionMonitor(BaseExecutionMonitor): 9 | """A trivial execution monitor that never suggests replanning.""" 10 | 11 | @classmethod 12 | def get_name(cls) -> str: 13 | return "trivial" 14 | 15 | def reset(self, task: Task) -> None: 16 | pass 17 | 18 | def step(self, state: State) -> bool: 19 | return False 20 | -------------------------------------------------------------------------------- /predicators/explorers/exploit_bilevel_planning_explorer.py: -------------------------------------------------------------------------------- 1 | """An explorer that explores by solving tasks with bilevel planning.""" 2 | 3 | from typing import List, Set 4 | 5 | from gym.spaces import Box 6 | 7 | from predicators.explorers.bilevel_planning_explorer import \ 8 | BilevelPlanningExplorer 9 | from predicators.explorers.random_options_explorer import RandomOptionsExplorer 10 | from predicators.option_model import _OptionModelBase 11 | from predicators.planning import PlanningFailure, PlanningTimeout 12 | from predicators.structs import NSRT, ExplorationStrategy, \ 13 | ParameterizedOption, Predicate, Task, Type 14 | 15 | 16 | class ExploitBilevelPlanningExplorer(BilevelPlanningExplorer): 17 | """ExploitBilevelPlanningExplorer implementation.""" 18 | 19 | def __init__(self, predicates: Set[Predicate], 20 | options: Set[ParameterizedOption], types: Set[Type], 21 | action_space: Box, train_tasks: List[Task], 22 | max_steps_before_termination: int, nsrts: Set[NSRT], 23 | option_model: _OptionModelBase) -> None: 24 | super().__init__(predicates, options, types, action_space, train_tasks, 25 | max_steps_before_termination, nsrts, option_model) 26 | # Falls back to random options. 27 | self._fallback_explorer = RandomOptionsExplorer( 28 | predicates, options, types, action_space, train_tasks, 29 | max_steps_before_termination) 30 | 31 | @classmethod 32 | def get_name(cls) -> str: 33 | return "exploit_planning" 34 | 35 | def _get_exploration_strategy(self, train_task_idx: int, 36 | timeout: int) -> ExplorationStrategy: 37 | task = self._train_tasks[train_task_idx] 38 | try: 39 | return self._solve(task, timeout) 40 | except (PlanningFailure, PlanningTimeout): 41 | return self._fallback_explorer.get_exploration_strategy( 42 | train_task_idx, timeout) 43 | -------------------------------------------------------------------------------- /predicators/explorers/no_explore_explorer.py: -------------------------------------------------------------------------------- 1 | """An explorer that always terminates immediately without taking an action.""" 2 | 3 | from predicators.explorers import BaseExplorer 4 | from predicators.structs import Action, ExplorationStrategy, State 5 | 6 | 7 | class NoExploreExplorer(BaseExplorer): 8 | """Terminates immediately during exploration.""" 9 | 10 | @classmethod 11 | def get_name(cls) -> str: 12 | return "no_explore" 13 | 14 | def _get_exploration_strategy(self, train_task_idx: int, 15 | timeout: int) -> ExplorationStrategy: 16 | 17 | def policy(_: State) -> Action: 18 | raise RuntimeError("The policy for no-explore shouldn't be used.") 19 | 20 | # Terminate immediately. 21 | termination_function = lambda _: True 22 | 23 | return policy, termination_function 24 | -------------------------------------------------------------------------------- /predicators/explorers/random_actions_explorer.py: -------------------------------------------------------------------------------- 1 | """An explorer that just takes random low-level actions.""" 2 | 3 | from predicators.explorers import BaseExplorer 4 | from predicators.structs import Action, ExplorationStrategy 5 | 6 | 7 | class RandomActionsExplorer(BaseExplorer): 8 | """Samples random low-level actions.""" 9 | 10 | @classmethod 11 | def get_name(cls) -> str: 12 | return "random_actions" 13 | 14 | def _get_exploration_strategy(self, train_task_idx: int, 15 | timeout: int) -> ExplorationStrategy: 16 | # Take random actions. 17 | policy = lambda _: Action(self._action_space.sample()) 18 | # Never terminate (until the interaction budget is exceeded). 19 | termination_function = lambda _: False 20 | return policy, termination_function 21 | -------------------------------------------------------------------------------- /predicators/explorers/random_options_explorer.py: -------------------------------------------------------------------------------- 1 | """An explorer that takes random options.""" 2 | 3 | from predicators import utils 4 | from predicators.explorers import BaseExplorer 5 | from predicators.structs import Action, ExplorationStrategy, State 6 | 7 | 8 | class RandomOptionsExplorer(BaseExplorer): 9 | """Samples random options.""" 10 | 11 | @classmethod 12 | def get_name(cls) -> str: 13 | return "random_options" 14 | 15 | def _get_exploration_strategy(self, train_task_idx: int, 16 | timeout: int) -> ExplorationStrategy: 17 | # Take random options, and raise an exception if no applicable option 18 | # can be found. 19 | 20 | # Note that this fallback policy is different from the one in 21 | # RandomOptionsApproach because explorers should raise 22 | # RequestActPolicyFailure instead of ApproachFailure. 23 | def fallback_policy(state: State) -> Action: 24 | del state # unused 25 | raise utils.RequestActPolicyFailure( 26 | "Random option sampling failed!") 27 | 28 | policy = utils.create_random_option_policy(self._options, self._rng, 29 | fallback_policy) 30 | # Never terminate (until the interaction budget is exceeded). 31 | termination_function = lambda _: False 32 | return policy, termination_function 33 | -------------------------------------------------------------------------------- /predicators/gnn/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Learning-and-Intelligent-Systems/predicators/5bd3f5bd21cc01e171faf748edf53bcfd720f4d1/predicators/gnn/__init__.py -------------------------------------------------------------------------------- /predicators/ground_truth_models/ball_and_cup_sticky_table/__init__.py: -------------------------------------------------------------------------------- 1 | """Ground-truth models for ball and cup sticky table environment.""" 2 | 3 | from .nsrts import BallAndCupStickyTableGroundTruthNSRTFactory 4 | from .options import BallAndCupStickyTableGroundTruthOptionFactory 5 | 6 | __all__ = [ 7 | "BallAndCupStickyTableGroundTruthNSRTFactory", 8 | "BallAndCupStickyTableGroundTruthOptionFactory" 9 | ] 10 | -------------------------------------------------------------------------------- /predicators/ground_truth_models/blocks/__init__.py: -------------------------------------------------------------------------------- 1 | """Ground-truth models for blocks environment and variants.""" 2 | 3 | from .nsrts import BlocksGroundTruthNSRTFactory 4 | from .options import BlocksGroundTruthOptionFactory, \ 5 | PyBulletBlocksGroundTruthOptionFactory 6 | 7 | __all__ = [ 8 | "BlocksGroundTruthNSRTFactory", "BlocksGroundTruthOptionFactory", 9 | "PyBulletBlocksGroundTruthOptionFactory" 10 | ] 11 | -------------------------------------------------------------------------------- /predicators/ground_truth_models/burger/__init__.py: -------------------------------------------------------------------------------- 1 | """Ground truth models for burger environment.""" 2 | 3 | from .nsrts import BurgerGroundTruthNSRTFactory, \ 4 | BurgerNoMoveGroundTruthNSRTFactory 5 | from .options import BurgerGroundTruthOptionFactory, \ 6 | BurgerNoMoveGroundTruthOptionFactory 7 | 8 | __all__ = [ 9 | "BurgerGroundTruthOptionFactory", "BurgerGroundTruthNSRTFactory", 10 | "BurgerNoMoveGroundTruthOptionFactory", 11 | "BurgerNoMoveGroundTruthNSRTFactory" 12 | ] 13 | -------------------------------------------------------------------------------- /predicators/ground_truth_models/cluttered_table/__init__.py: -------------------------------------------------------------------------------- 1 | """Ground-truth models for cluttered table environment and variants.""" 2 | 3 | from .nsrts import ClutteredTableGroundTruthNSRTFactory 4 | from .options import ClutteredTableGroundTruthOptionFactory, \ 5 | ClutteredTablePlaceGroundTruthOptionFactory 6 | 7 | __all__ = [ 8 | "ClutteredTableGroundTruthNSRTFactory", 9 | "ClutteredTableGroundTruthOptionFactory", 10 | "ClutteredTablePlaceGroundTruthOptionFactory" 11 | ] 12 | -------------------------------------------------------------------------------- /predicators/ground_truth_models/coffee/__init__.py: -------------------------------------------------------------------------------- 1 | """Ground-truth models for coffee environment and variants.""" 2 | 3 | from .nsrts import CoffeeGroundTruthNSRTFactory 4 | from .options import CoffeeGroundTruthOptionFactory 5 | 6 | __all__ = ["CoffeeGroundTruthNSRTFactory", "CoffeeGroundTruthOptionFactory"] 7 | -------------------------------------------------------------------------------- /predicators/ground_truth_models/cover/__init__.py: -------------------------------------------------------------------------------- 1 | """Ground-truth models for cover environment and variants.""" 2 | 3 | from .nsrts import CoverGroundTruthNSRTFactory, \ 4 | RegionalBumpyCoverGroundTruthNSRTFactory 5 | from .options import BumpyCoverGroundTruthOptionFactory, \ 6 | CoverGroundTruthOptionFactory, \ 7 | CoverMultiStepOptionsGroundTruthOptionFactory, \ 8 | CoverTypedOptionsGroundTruthOptionFactory, \ 9 | PyBulletCoverGroundTruthOptionFactory 10 | 11 | __all__ = [ 12 | "CoverGroundTruthOptionFactory", "CoverGroundTruthNSRTFactory", 13 | "CoverMultiStepOptionsGroundTruthOptionFactory", 14 | "CoverTypedOptionsGroundTruthOptionFactory", 15 | "PyBulletCoverGroundTruthOptionFactory", 16 | "BumpyCoverGroundTruthOptionFactory", 17 | "RegionalBumpyCoverGroundTruthNSRTFactory" 18 | ] 19 | -------------------------------------------------------------------------------- /predicators/ground_truth_models/doors/__init__.py: -------------------------------------------------------------------------------- 1 | """Ground-truth models for doors environment and variants.""" 2 | 3 | from .nsrts import DoorsGroundTruthNSRTFactory 4 | from .options import DoorsGroundTruthOptionFactory 5 | 6 | __all__ = ["DoorsGroundTruthNSRTFactory", "DoorsGroundTruthOptionFactory"] 7 | -------------------------------------------------------------------------------- /predicators/ground_truth_models/exit_garage/__init__.py: -------------------------------------------------------------------------------- 1 | """Ground-truth models for exit garage environment and variants.""" 2 | 3 | from .nsrts import ExitGarageGroundTruthNSRTFactory 4 | from .options import ExitGarageGroundTruthOptionFactory 5 | 6 | __all__ = [ 7 | "ExitGarageGroundTruthNSRTFactory", "ExitGarageGroundTruthOptionFactory" 8 | ] 9 | -------------------------------------------------------------------------------- /predicators/ground_truth_models/grid_row/__init__.py: -------------------------------------------------------------------------------- 1 | """Ground-truth models for grid row environment and variants.""" 2 | 3 | from .nsrts import GridRowGroundTruthNSRTFactory 4 | from .options import GridRowGroundTruthOptionFactory 5 | 6 | __all__ = ["GridRowGroundTruthNSRTFactory", "GridRowGroundTruthOptionFactory"] 7 | -------------------------------------------------------------------------------- /predicators/ground_truth_models/ice_tea_making/__init__.py: -------------------------------------------------------------------------------- 1 | """Ground-truth models for ice tea making environment.""" 2 | 3 | from .nsrts import TeaMakingGroundTruthNSRTFactory 4 | from .options import TeaMakingGroundTruthOptionFactory 5 | 6 | __all__ = [ 7 | "TeaMakingGroundTruthNSRTFactory", "TeaMakingGroundTruthOptionFactory" 8 | ] 9 | -------------------------------------------------------------------------------- /predicators/ground_truth_models/ice_tea_making/nsrts.py: -------------------------------------------------------------------------------- 1 | """Ground-truth NSRTs for the tea making environment.""" 2 | 3 | from typing import Dict, Set 4 | 5 | from predicators.ground_truth_models import GroundTruthNSRTFactory 6 | from predicators.structs import NSRT, ParameterizedOption, Predicate, Type 7 | 8 | 9 | class TeaMakingGroundTruthNSRTFactory(GroundTruthNSRTFactory): 10 | """Ground-truth NSRTs for the tea making environment.""" 11 | 12 | @classmethod 13 | def get_env_names(cls) -> Set[str]: # pragma: no cover 14 | return {"ice_tea_making"} 15 | 16 | @staticmethod 17 | def get_nsrts( 18 | env_name: str, types: Dict[str, Type], predicates: Dict[str, 19 | Predicate], 20 | options: Dict[str, 21 | ParameterizedOption]) -> Set[NSRT]: # pragma: no cover 22 | # For now, there are just no NSRTs 23 | return set() 24 | -------------------------------------------------------------------------------- /predicators/ground_truth_models/kitchen/__init__.py: -------------------------------------------------------------------------------- 1 | """Ground truth models for Kitchen mujoco environment.""" 2 | 3 | from .nsrts import KitchenGroundTruthNSRTFactory 4 | from .options import KitchenGroundTruthOptionFactory 5 | 6 | __all__ = ["KitchenGroundTruthOptionFactory", "KitchenGroundTruthNSRTFactory"] 7 | -------------------------------------------------------------------------------- /predicators/ground_truth_models/narrow_passage/__init__.py: -------------------------------------------------------------------------------- 1 | """Ground-truth models for narrow passage environment and variants.""" 2 | 3 | from .nsrts import NarrowPassageGroundTruthNSRTFactory 4 | from .options import NarrowPassageGroundTruthOptionFactory 5 | 6 | __all__ = [ 7 | "NarrowPassageGroundTruthNSRTFactory", 8 | "NarrowPassageGroundTruthOptionFactory" 9 | ] 10 | -------------------------------------------------------------------------------- /predicators/ground_truth_models/noisy_button/__init__.py: -------------------------------------------------------------------------------- 1 | """Ground-truth models for noisy button environment and variants.""" 2 | 3 | from .nsrts import NoisyButtonGroundTruthNSRTFactory 4 | from .options import NoisyButtonGroundTruthOptionFactory 5 | 6 | __all__ = [ 7 | "NoisyButtonGroundTruthNSRTFactory", 8 | "NoisyButtonGroundTruthOptionFactory", 9 | ] 10 | -------------------------------------------------------------------------------- /predicators/ground_truth_models/noisy_button/options.py: -------------------------------------------------------------------------------- 1 | """Ground-truth options for the noisy button environment.""" 2 | 3 | from typing import Dict, Sequence, Set 4 | 5 | from gym.spaces import Box 6 | 7 | from predicators import utils 8 | from predicators.ground_truth_models import GroundTruthOptionFactory 9 | from predicators.structs import Action, Array, Object, ParameterizedOption, \ 10 | Predicate, State, Type 11 | 12 | 13 | class NoisyButtonGroundTruthOptionFactory(GroundTruthOptionFactory): 14 | """Ground-truth options for the noisy button environment.""" 15 | 16 | @classmethod 17 | def get_env_names(cls) -> Set[str]: 18 | return {"noisy_button"} 19 | 20 | @classmethod 21 | def get_options(cls, env_name: str, types: Dict[str, Type], 22 | predicates: Dict[str, Predicate], 23 | action_space: Box) -> Set[ParameterizedOption]: 24 | 25 | button_type = types["button"] 26 | 27 | def _policy(state: State, memory: Dict, objects: Sequence[Object], 28 | params: Array) -> Action: 29 | del state, memory, objects # unused 30 | return Action(params) # action is simply the parameter 31 | 32 | Click = utils.SingletonParameterizedOption("Click", 33 | _policy, 34 | types=[button_type], 35 | params_space=Box( 36 | 0, 1, (2, ))) 37 | 38 | return {Click} 39 | -------------------------------------------------------------------------------- /predicators/ground_truth_models/painting/__init__.py: -------------------------------------------------------------------------------- 1 | """Ground-truth models for painting environment and variants.""" 2 | 3 | from .ldl_bridge_policy import PaintingLDLBridgePolicyFactory 4 | from .nsrts import PaintingGroundTruthNSRTFactory 5 | from .options import PaintingGroundTruthOptionFactory, \ 6 | RNTPaintingGroundTruthOptionFactory 7 | 8 | __all__ = [ 9 | "PaintingGroundTruthNSRTFactory", "PaintingGroundTruthOptionFactory", 10 | "RNTPaintingGroundTruthOptionFactory", "PaintingLDLBridgePolicyFactory" 11 | ] 12 | -------------------------------------------------------------------------------- /predicators/ground_truth_models/painting/ldl_bridge_policy.py: -------------------------------------------------------------------------------- 1 | """Ground-truth LDL bridge policy for the painting environment.""" 2 | 3 | from pathlib import Path 4 | from typing import Set 5 | 6 | from predicators.ground_truth_models import GroundTruthLDLBridgePolicyFactory 7 | 8 | 9 | class PaintingLDLBridgePolicyFactory(GroundTruthLDLBridgePolicyFactory): 10 | """Ground-truth LDL bridge policy for the painting environment.""" 11 | 12 | @classmethod 13 | def get_env_names(cls) -> Set[str]: 14 | return {"painting"} 15 | 16 | @classmethod 17 | def _get_ldl_file(cls) -> Path: 18 | return Path(__file__).parent / "painting_bridge_policy.ldl" 19 | -------------------------------------------------------------------------------- /predicators/ground_truth_models/painting/painting_bridge_policy.ldl: -------------------------------------------------------------------------------- 1 | (define (policy) 2 | (:rule OpenLid 3 | :parameters (?lid - lid ?robot - robot) 4 | :preconditions (and (GripperOpen ?robot) (PlaceFailed_arg0 ?robot) (not (IsOpen ?lid))) 5 | :goals () 6 | :action (OpenLid ?lid ?robot) 7 | ) 8 | (:rule PlaceOnTableFromHoldingTop 9 | :parameters (?obj - obj ?robot - robot) 10 | :preconditions (and (Holding ?obj) (HoldingTop ?obj) (IsClean ?obj) (IsDry ?obj) (OnTable ?obj) (PlaceFailed_arg0 ?robot) (not (GripperOpen ?robot))) 11 | :goals () 12 | :action (PlaceOnTableFromHoldingTop ?obj ?robot) 13 | ) 14 | ) 15 | -------------------------------------------------------------------------------- /predicators/ground_truth_models/pddl_env/__init__.py: -------------------------------------------------------------------------------- 1 | """Ground-truth models for PDDLEnv and variants.""" 2 | 3 | from .nsrts import PDDLEnvGroundTruthNSRTFactory 4 | from .options import PDDLEnvGroundTruthOptionFactory 5 | 6 | __all__ = ["PDDLEnvGroundTruthNSRTFactory", "PDDLEnvGroundTruthOptionFactory"] 7 | -------------------------------------------------------------------------------- /predicators/ground_truth_models/pddl_env/nsrts.py: -------------------------------------------------------------------------------- 1 | """Ground-truth NSRTs for the PDDLEnv.""" 2 | 3 | from typing import Dict, Set 4 | 5 | from predicators import utils 6 | from predicators.envs import get_or_create_env 7 | from predicators.envs.pddl_env import _PDDLEnv 8 | from predicators.ground_truth_models import GroundTruthNSRTFactory 9 | from predicators.structs import NSRT, ParameterizedOption, Predicate, Type 10 | from predicators.utils import null_sampler 11 | 12 | 13 | class PDDLEnvGroundTruthNSRTFactory(GroundTruthNSRTFactory): 14 | """Ground-truth NSRTs for the PDDLEnv.""" 15 | 16 | @classmethod 17 | def get_env_names(cls) -> Set[str]: 18 | pddl_env_classes = utils.get_all_subclasses(_PDDLEnv) 19 | return { 20 | c.get_name() 21 | for c in pddl_env_classes if not c.__abstractmethods__ 22 | } 23 | 24 | @staticmethod 25 | def get_nsrts(env_name: str, types: Dict[str, Type], 26 | predicates: Dict[str, Predicate], 27 | options: Dict[str, ParameterizedOption]) -> Set[NSRT]: 28 | env = get_or_create_env(env_name) 29 | assert isinstance(env, _PDDLEnv) 30 | 31 | nsrts = set() 32 | 33 | for strips_op in env.strips_operators: 34 | option = options[strips_op.name] 35 | nsrt = strips_op.make_nsrt( 36 | option=option, 37 | option_vars=strips_op.parameters, 38 | sampler=null_sampler, 39 | ) 40 | nsrts.add(nsrt) 41 | 42 | return nsrts 43 | -------------------------------------------------------------------------------- /predicators/ground_truth_models/playroom/__init__.py: -------------------------------------------------------------------------------- 1 | """Ground-truth models for playroom environment and variants.""" 2 | 3 | from .nsrts import PlayroomGroundTruthNSRTFactory 4 | from .options import PlayroomGroundTruthOptionFactory, \ 5 | PlayroomSimpleGroundTruthOptionFactory 6 | 7 | __all__ = [ 8 | "PlayroomGroundTruthNSRTFactory", "PlayroomGroundTruthOptionFactory", 9 | "PlayroomSimpleGroundTruthOptionFactory" 10 | ] 11 | -------------------------------------------------------------------------------- /predicators/ground_truth_models/repeated_nextto/__init__.py: -------------------------------------------------------------------------------- 1 | """Ground-truth models for repeated nextto environment and variants.""" 2 | 3 | from .nsrts import RepeatedNextToGroundTruthNSRTFactory, \ 4 | RNTSingleOptGroundTruthNSRTFactory 5 | from .options import RepeatedNextToGroundTruthOptionFactory, \ 6 | RNTSingleOptionGroundTruthOptionFactory 7 | 8 | __all__ = [ 9 | "RepeatedNextToGroundTruthNSRTFactory", 10 | "RNTSingleOptGroundTruthNSRTFactory", 11 | "RepeatedNextToGroundTruthOptionFactory", 12 | "RNTSingleOptionGroundTruthOptionFactory" 13 | ] 14 | -------------------------------------------------------------------------------- /predicators/ground_truth_models/sandwich/__init__.py: -------------------------------------------------------------------------------- 1 | """Ground-truth models for sandwich environment and variants.""" 2 | 3 | from .nsrts import SandwichGroundTruthNSRTFactory 4 | from .options import SandwichGroundTruthOptionFactory 5 | 6 | __all__ = [ 7 | "SandwichGroundTruthNSRTFactory", "SandwichGroundTruthOptionFactory" 8 | ] 9 | -------------------------------------------------------------------------------- /predicators/ground_truth_models/satellites/__init__.py: -------------------------------------------------------------------------------- 1 | """Ground-truth models for satellites environment and variants.""" 2 | 3 | from .nsrts import SatellitesGroundTruthNSRTFactory 4 | from .options import SatellitesGroundTruthOptionFactory 5 | 6 | __all__ = [ 7 | "SatellitesGroundTruthNSRTFactory", "SatellitesGroundTruthOptionFactory" 8 | ] 9 | -------------------------------------------------------------------------------- /predicators/ground_truth_models/screws/__init__.py: -------------------------------------------------------------------------------- 1 | """Ground-truth models for screws environment and variants.""" 2 | 3 | from .nsrts import ScrewsGroundTruthNSRTFactory 4 | from .options import ScrewsGroundTruthOptionFactory 5 | 6 | __all__ = ["ScrewsGroundTruthNSRTFactory", "ScrewsGroundTruthOptionFactory"] 7 | -------------------------------------------------------------------------------- /predicators/ground_truth_models/sokoban/__init__.py: -------------------------------------------------------------------------------- 1 | """Ground truth models for Sokoban gym environment.""" 2 | 3 | from .nsrts import SokobanGroundTruthNSRTFactory 4 | from .options import SokobanGroundTruthOptionFactory 5 | 6 | __all__ = ["SokobanGroundTruthOptionFactory", "SokobanGroundTruthNSRTFactory"] 7 | -------------------------------------------------------------------------------- /predicators/ground_truth_models/sokoban/options.py: -------------------------------------------------------------------------------- 1 | """Ground-truth options for the sokoban environment.""" 2 | 3 | from typing import Dict, Sequence, Set 4 | 5 | import numpy as np 6 | from gym.spaces import Box 7 | from gym_sokoban.envs.sokoban_env import ACTION_LOOKUP as SOKOBAN_ACTION_LOOKUP 8 | 9 | from predicators import utils 10 | from predicators.ground_truth_models import GroundTruthOptionFactory 11 | from predicators.structs import Action, Array, Object, ParameterizedOption, \ 12 | ParameterizedPolicy, Predicate, State, Type 13 | 14 | 15 | class SokobanGroundTruthOptionFactory(GroundTruthOptionFactory): 16 | """Ground-truth options for the sokoban environment.""" 17 | 18 | @classmethod 19 | def get_env_names(cls) -> Set[str]: 20 | return {"sokoban"} 21 | 22 | @classmethod 23 | def get_options(cls, env_name: str, types: Dict[str, Type], 24 | predicates: Dict[str, Predicate], 25 | action_space: Box) -> Set[ParameterizedOption]: 26 | 27 | # Reformat names for consistency with other option naming. 28 | def _format_name(name: str) -> str: 29 | return "".join([n.capitalize() for n in name.split(" ")]) 30 | 31 | options: Set[ParameterizedOption] = { 32 | utils.SingletonParameterizedOption( 33 | _format_name(name), cls._create_policy(discrete_action=i)) 34 | for i, name in SOKOBAN_ACTION_LOOKUP.items() 35 | } 36 | 37 | return options 38 | 39 | @classmethod 40 | def _create_policy(cls, discrete_action: int) -> ParameterizedPolicy: 41 | 42 | def policy(state: State, memory: Dict, objects: Sequence[Object], 43 | params: Array) -> Action: 44 | del state, memory, objects, params # unused. 45 | arr = np.zeros(9, dtype=np.float32) 46 | arr[discrete_action] = 1 47 | return Action(arr) 48 | 49 | return policy 50 | -------------------------------------------------------------------------------- /predicators/ground_truth_models/stick_button/__init__.py: -------------------------------------------------------------------------------- 1 | """Ground-truth models for stick button environment and variants.""" 2 | 3 | from .ldl_bridge_policy import StickButtonLDLBridgePolicyFactory 4 | from .nsrts import StickButtonGroundTruthNSRTFactory 5 | from .options import StickButtonGroundTruthOptionFactory 6 | 7 | __all__ = [ 8 | "StickButtonGroundTruthNSRTFactory", "StickButtonGroundTruthOptionFactory", 9 | "StickButtonLDLBridgePolicyFactory" 10 | ] 11 | -------------------------------------------------------------------------------- /predicators/ground_truth_models/stick_button/ldl_bridge_policy.py: -------------------------------------------------------------------------------- 1 | """Ground-truth LDL bridge policy for the stick button environment.""" 2 | 3 | from pathlib import Path 4 | from typing import Set 5 | 6 | from predicators.ground_truth_models import GroundTruthLDLBridgePolicyFactory 7 | 8 | 9 | class StickButtonLDLBridgePolicyFactory(GroundTruthLDLBridgePolicyFactory): 10 | """Ground-truth LDL bridge policy for the stick button environment.""" 11 | 12 | @classmethod 13 | def get_env_names(cls) -> Set[str]: 14 | return {"stick_button"} 15 | 16 | @classmethod 17 | def _get_ldl_file(cls) -> Path: 18 | return Path(__file__).parent / "stick_button_bridge_policy.ldl" 19 | -------------------------------------------------------------------------------- /predicators/ground_truth_models/stick_button/stick_button_bridge_policy.ldl: -------------------------------------------------------------------------------- 1 | (define (policy) 2 | (:rule PickStickFromButton 3 | :parameters (?robot - robot ?stick - stick ?from_button - button) 4 | :preconditions (and (HandEmpty ?robot) (RobotAboveButton ?robot ?from_button) (RobotPressButtonFailed_arg0 ?robot) (not (AboveNoButton )) (not (Grasped ?robot ?stick)) (not (RobotPressButtonFailed_arg1 ?from_button))) 5 | :goals () 6 | :action (PickStickFromButton ?robot ?stick ?from-button) 7 | ) 8 | (:rule PickStickFromNothing 9 | :parameters (?robot - robot ?stick - stick) 10 | :preconditions (and (AboveNoButton ) (HandEmpty ?robot) (RobotPressButtonFailed_arg0 ?robot) (not (Grasped ?robot ?stick))) 11 | :goals () 12 | :action (PickStickFromNothing ?robot ?stick) 13 | ) 14 | (:rule PlaceStickFromButton 15 | :parameters (?robot - robot ?stick - stick) 16 | :preconditions (and (Grasped ?robot ?stick) (RobotPressButtonFailed_arg0 ?robot) (StickPressButtonFailed_arg0 ?robot) (StickPressButtonFailed_arg1 ?stick) (not (AboveNoButton )) (not (HandEmpty ?robot))) 17 | :goals () 18 | :action (PlaceStickFromButton ?robot ?stick) 19 | ) 20 | (:rule PlaceStickFromNothing 21 | :parameters (?robot - robot ?stick - stick) 22 | :preconditions (and (AboveNoButton ) (Grasped ?robot ?stick) (RobotPressButtonFailed_arg0 ?robot) (StickPressButtonFailed_arg0 ?robot) (StickPressButtonFailed_arg1 ?stick) (not (HandEmpty ?robot))) 23 | :goals () 24 | :action (PlaceStickFromNothing ?robot ?stick) 25 | ) 26 | ) 27 | -------------------------------------------------------------------------------- /predicators/ground_truth_models/sticky_table/__init__.py: -------------------------------------------------------------------------------- 1 | """Ground-truth models for sticky table environment and variants.""" 2 | 3 | from .nsrts import StickyTableGroundTruthNSRTFactory 4 | from .options import StickyTableGroundTruthOptionFactory 5 | 6 | __all__ = [ 7 | "StickyTableGroundTruthNSRTFactory", "StickyTableGroundTruthOptionFactory" 8 | ] 9 | -------------------------------------------------------------------------------- /predicators/ground_truth_models/tools/__init__.py: -------------------------------------------------------------------------------- 1 | """Ground-truth models for tools environment and variants.""" 2 | 3 | from .nsrts import ToolsGroundTruthNSRTFactory 4 | from .options import ToolsGroundTruthOptionFactory 5 | 6 | __all__ = ["ToolsGroundTruthNSRTFactory", "ToolsGroundTruthOptionFactory"] 7 | -------------------------------------------------------------------------------- /predicators/ground_truth_models/touch_open/__init__.py: -------------------------------------------------------------------------------- 1 | """Ground-truth models for touch open environment and variants.""" 2 | 3 | from .nsrts import TouchOpenGroundTruthNSRTFactory 4 | from .options import TouchOpenGroundTruthOptionFactory 5 | 6 | __all__ = [ 7 | "TouchOpenGroundTruthNSRTFactory", "TouchOpenGroundTruthOptionFactory" 8 | ] 9 | -------------------------------------------------------------------------------- /predicators/ground_truth_models/touch_point/__init__.py: -------------------------------------------------------------------------------- 1 | """Ground-truth models for touch point environment and variants.""" 2 | 3 | from .nsrts import TouchPointGroundTruthNSRTFactory 4 | from .options import TouchPointGroundTruthOptionFactory, \ 5 | TouchPointParamGroundTruthOptionFactory 6 | 7 | __all__ = [ 8 | "TouchPointGroundTruthNSRTFactory", "TouchPointGroundTruthOptionFactory", 9 | "TouchPointParamGroundTruthOptionFactory" 10 | ] 11 | -------------------------------------------------------------------------------- /predicators/nsrt_learning/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Learning-and-Intelligent-Systems/predicators/5bd3f5bd21cc01e171faf748edf53bcfd720f4d1/predicators/nsrt_learning/__init__.py -------------------------------------------------------------------------------- /predicators/nsrt_learning/strips_learning/__init__.py: -------------------------------------------------------------------------------- 1 | """This directory contains algorithms for STRIPS operator learning.""" 2 | 3 | from typing import Any, List, Optional, Set 4 | 5 | from predicators import utils 6 | from predicators.nsrt_learning.strips_learning.base_strips_learner import \ 7 | BaseSTRIPSLearner 8 | from predicators.settings import CFG 9 | from predicators.structs import PNAD, LowLevelTrajectory, Predicate, Segment, \ 10 | Task 11 | 12 | __all__ = ["BaseSTRIPSLearner"] 13 | 14 | # Find the subclasses. 15 | utils.import_submodules(__path__, __name__) 16 | 17 | 18 | def learn_strips_operators(trajectories: List[LowLevelTrajectory], 19 | train_tasks: List[Task], 20 | predicates: Set[Predicate], 21 | segmented_trajs: List[List[Segment]], 22 | verify_harmlessness: bool, 23 | annotations: Optional[List[Any]], 24 | verbose: bool = True) -> List[PNAD]: 25 | """Learn strips operators on the given data segments. 26 | 27 | Return a list of PNADs with op (STRIPSOperator), datastore, and 28 | option_spec fields filled in (but not sampler). 29 | """ 30 | for cls in utils.get_all_subclasses(BaseSTRIPSLearner): 31 | if not cls.__abstractmethods__ and \ 32 | cls.get_name() == CFG.strips_learner: 33 | learner = cls(trajectories, train_tasks, predicates, 34 | segmented_trajs, verify_harmlessness, annotations, 35 | verbose) 36 | break 37 | else: 38 | raise ValueError(f"Unrecognized STRIPS learner: {CFG.strips_learner}") 39 | return learner.learn() 40 | -------------------------------------------------------------------------------- /predicators/perception/__init__.py: -------------------------------------------------------------------------------- 1 | """Handle creation of perceivers.""" 2 | 3 | from predicators import utils 4 | from predicators.perception.base_perceiver import BasePerceiver 5 | 6 | __all__ = ["BasePerceiver"] 7 | 8 | # Find the subclasses. 9 | utils.import_submodules(__path__, __name__) 10 | 11 | 12 | def create_perceiver(name: str, ) -> BasePerceiver: 13 | """Create a perceiver given its name.""" 14 | for cls in utils.get_all_subclasses(BasePerceiver): 15 | if not cls.__abstractmethods__ and cls.get_name() == name: 16 | perceiver = cls() 17 | break 18 | else: 19 | raise NotImplementedError(f"Unrecognized perceiver: {name}") 20 | return perceiver 21 | -------------------------------------------------------------------------------- /predicators/perception/base_perceiver.py: -------------------------------------------------------------------------------- 1 | """Base class for perceivers.""" 2 | 3 | import abc 4 | 5 | from predicators.structs import EnvironmentTask, Observation, State, Task, \ 6 | Video 7 | 8 | 9 | class BasePerceiver(abc.ABC): 10 | """A perceiver consumes observations and produces states.""" 11 | 12 | @classmethod 13 | @abc.abstractmethod 14 | def get_name(cls) -> str: 15 | """Get the unique name of this perceiver.""" 16 | 17 | @abc.abstractmethod 18 | def reset(self, env_task: EnvironmentTask) -> Task: 19 | """Start a new episode of environment interaction.""" 20 | 21 | @abc.abstractmethod 22 | def step(self, observation: Observation) -> State: 23 | """Produce a State given the current and past observations.""" 24 | 25 | @abc.abstractmethod 26 | def render_mental_images(self, observation: Observation, 27 | env_task: EnvironmentTask) -> Video: 28 | """Create mental images for the given observation.""" 29 | -------------------------------------------------------------------------------- /predicators/perception/trivial_perceiver.py: -------------------------------------------------------------------------------- 1 | """A trivial perceiver that assumes observations are already states.""" 2 | 3 | from predicators.envs import get_or_create_env 4 | from predicators.perception.base_perceiver import BasePerceiver 5 | from predicators.settings import CFG 6 | from predicators.structs import EnvironmentTask, Observation, State, Task, \ 7 | Video 8 | 9 | 10 | class TrivialPerceiver(BasePerceiver): 11 | """A trivial perceiver that assumes observations are already states.""" 12 | 13 | @classmethod 14 | def get_name(cls) -> str: 15 | return "trivial" 16 | 17 | def reset(self, env_task: EnvironmentTask) -> Task: 18 | return env_task.task 19 | 20 | def step(self, observation: Observation) -> State: 21 | assert isinstance(observation, State) 22 | return observation 23 | 24 | def render_mental_images(self, observation: Observation, 25 | env_task: EnvironmentTask) -> Video: 26 | # Use the environment's render function by default. 27 | assert isinstance(observation, State) 28 | env = get_or_create_env(CFG.env) 29 | return env.render_state(observation, env_task) 30 | -------------------------------------------------------------------------------- /predicators/pybullet_helpers/__init__.py: -------------------------------------------------------------------------------- 1 | """This implementation is heavily based on the pybullet-planning repository by 2 | Caelan Garrett (https://github.com/caelan/pybullet-planning/). 3 | 4 | In addition, the structure is loosely based off the pb_robot repository 5 | by Rachel Holladay (https://github.com/rachelholladay/pb_robot). 6 | """ 7 | -------------------------------------------------------------------------------- /predicators/pybullet_helpers/camera.py: -------------------------------------------------------------------------------- 1 | """PyBullet helpers for cameras and rendering.""" 2 | 3 | import pybullet as p 4 | 5 | from predicators.pybullet_helpers.geometry import Pose3D 6 | 7 | 8 | def create_gui_connection( 9 | camera_distance: float = 0.8, 10 | camera_yaw: float = 90, 11 | camera_pitch: float = -24, 12 | camera_target: Pose3D = (1.65, 0.75, 0.42), 13 | disable_preview_windows: bool = True) -> int: # pragma: no cover 14 | """Creates a PyBullet GUI connection and initializes the camera. 15 | 16 | Returns the physics client ID for the connection. 17 | 18 | Not covered by unit tests because unit tests need to be headless. 19 | """ 20 | physics_client_id = p.connect(p.GUI) 21 | # Disable the PyBullet GUI preview windows for faster rendering. 22 | if disable_preview_windows: 23 | p.configureDebugVisualizer(p.COV_ENABLE_GUI, 24 | False, 25 | physicsClientId=physics_client_id) 26 | p.configureDebugVisualizer(p.COV_ENABLE_RGB_BUFFER_PREVIEW, 27 | False, 28 | physicsClientId=physics_client_id) 29 | p.configureDebugVisualizer(p.COV_ENABLE_DEPTH_BUFFER_PREVIEW, 30 | False, 31 | physicsClientId=physics_client_id) 32 | p.configureDebugVisualizer(p.COV_ENABLE_SEGMENTATION_MARK_PREVIEW, 33 | False, 34 | physicsClientId=physics_client_id) 35 | p.resetDebugVisualizerCamera(camera_distance, 36 | camera_yaw, 37 | camera_pitch, 38 | camera_target, 39 | physicsClientId=physics_client_id) 40 | return physics_client_id 41 | -------------------------------------------------------------------------------- /predicators/pybullet_helpers/ikfast/__init__.py: -------------------------------------------------------------------------------- 1 | """The `ikfast` module contains all the functionality to compile, install, and 2 | load the IKFast module and also run IK using it.""" 3 | 4 | from typing import List, NamedTuple 5 | 6 | 7 | class IKFastInfo(NamedTuple): 8 | """IKFast information for a given robot.""" 9 | module_dir: str 10 | module_name: str 11 | base_link: str 12 | ee_link: str 13 | free_joints: List[str] 14 | -------------------------------------------------------------------------------- /predicators/pybullet_helpers/robots/__init__.py: -------------------------------------------------------------------------------- 1 | """Handles the creation of robots.""" 2 | from typing import Dict, Optional, Type 3 | 4 | from predicators.pybullet_helpers.geometry import Pose, Pose3D 5 | from predicators.pybullet_helpers.robots.fetch import FetchPyBulletRobot 6 | from predicators.pybullet_helpers.robots.panda import PandaPyBulletRobot 7 | from predicators.pybullet_helpers.robots.single_arm import \ 8 | SingleArmPyBulletRobot 9 | from predicators.settings import CFG 10 | 11 | # Note: these are static base poses which suffice for the current environments. 12 | _ROBOT_TO_BASE_POSE: Dict[str, Pose] = { 13 | "fetch": Pose(position=(0.75, 0.7441, 0.0)), 14 | "panda": Pose(position=(0.8, 0.7441, 0.195)), 15 | } 16 | 17 | _ROBOT_TO_CLS: Dict[str, Type[SingleArmPyBulletRobot]] = { 18 | "fetch": FetchPyBulletRobot, 19 | "panda": PandaPyBulletRobot, 20 | } 21 | 22 | # Used if home position is not specified during robot creation. 23 | _DEFAULT_EE_HOME_POSITION: Pose3D = (1.35, 0.6, 0.7) 24 | 25 | 26 | def create_single_arm_pybullet_robot( 27 | robot_name: str, 28 | physics_client_id: int, 29 | ee_home_pose: Optional[Pose] = None, 30 | ) -> SingleArmPyBulletRobot: 31 | """Create a single-arm PyBullet robot.""" 32 | if robot_name not in _ROBOT_TO_CLS: 33 | raise NotImplementedError(f"Unrecognized robot name: {robot_name}.") 34 | if ee_home_pose is None: 35 | robot_to_ee_orn = CFG.pybullet_robot_ee_orns[CFG.env] 36 | assert robot_name in robot_to_ee_orn, \ 37 | f"Default home orn not specified for robot {robot_name}." 38 | ee_orientation = robot_to_ee_orn[robot_name] 39 | ee_home_pose = Pose(_DEFAULT_EE_HOME_POSITION, ee_orientation) 40 | assert robot_name in _ROBOT_TO_BASE_POSE, \ 41 | f"Base pose not specified for robot {robot_name}." 42 | base_pose = _ROBOT_TO_BASE_POSE[robot_name] 43 | cls = _ROBOT_TO_CLS[robot_name] 44 | return cls(ee_home_pose, physics_client_id, base_pose=base_pose) 45 | -------------------------------------------------------------------------------- /predicators/pybullet_helpers/robots/fetch.py: -------------------------------------------------------------------------------- 1 | """Fetch Robotics Mobile Manipulator (Fetch).""" 2 | 3 | from predicators import utils 4 | from predicators.pybullet_helpers.robots.single_arm import \ 5 | SingleArmPyBulletRobot 6 | 7 | 8 | class FetchPyBulletRobot(SingleArmPyBulletRobot): 9 | """A Fetch robot with a fixed base and only one arm in use.""" 10 | 11 | @classmethod 12 | def get_name(cls) -> str: 13 | return "fetch" 14 | 15 | @classmethod 16 | def urdf_path(cls) -> str: 17 | return utils.get_env_asset_path( 18 | "urdf/fetch_description/robots/fetch.urdf") 19 | 20 | @property 21 | def end_effector_name(self) -> str: 22 | return "gripper_axis" 23 | 24 | @property 25 | def tool_link_name(self) -> str: 26 | return "gripper_link" 27 | 28 | @property 29 | def left_finger_joint_name(self) -> str: 30 | return "l_gripper_finger_joint" 31 | 32 | @property 33 | def right_finger_joint_name(self) -> str: 34 | return "r_gripper_finger_joint" 35 | 36 | @property 37 | def open_fingers(self) -> float: 38 | return 0.04 39 | 40 | @property 41 | def closed_fingers(self) -> float: 42 | return 0.01 43 | -------------------------------------------------------------------------------- /predicators/pybullet_helpers/robots/panda.py: -------------------------------------------------------------------------------- 1 | """Franka Emika Panda robot.""" 2 | from typing import Optional 3 | 4 | from predicators import utils 5 | from predicators.pybullet_helpers.ikfast import IKFastInfo 6 | from predicators.pybullet_helpers.robots.single_arm import \ 7 | SingleArmPyBulletRobot 8 | 9 | 10 | class PandaPyBulletRobot(SingleArmPyBulletRobot): 11 | """Franka Emika Panda which we assume is fixed on some base.""" 12 | 13 | @classmethod 14 | def get_name(cls) -> str: 15 | return "panda" 16 | 17 | @classmethod 18 | def urdf_path(cls) -> str: 19 | return utils.get_env_asset_path( 20 | "urdf/franka_description/robots/panda_arm_hand.urdf") 21 | 22 | @property 23 | def end_effector_name(self) -> str: 24 | """The tool joint is offset from the final arm joint such that it 25 | represents the point in the center of the two fingertips of the gripper 26 | (fingertips, NOT the entire fingers). 27 | 28 | This differs from the "panda_hand" joint which represents the 29 | center of the gripper itself including parts of the gripper 30 | body. 31 | """ 32 | return "tool_joint" 33 | 34 | @property 35 | def tool_link_name(self) -> str: 36 | return "tool_link" 37 | 38 | @property 39 | def left_finger_joint_name(self) -> str: 40 | return "panda_finger_joint1" 41 | 42 | @property 43 | def right_finger_joint_name(self) -> str: 44 | return "panda_finger_joint2" 45 | 46 | @property 47 | def open_fingers(self) -> float: 48 | return 0.04 49 | 50 | @property 51 | def closed_fingers(self) -> float: 52 | return 0.03 53 | 54 | @classmethod 55 | def ikfast_info(cls) -> Optional[IKFastInfo]: 56 | return IKFastInfo( 57 | module_dir="panda_arm", 58 | module_name="ikfast_panda_arm", 59 | base_link="panda_link0", 60 | ee_link="panda_link8", 61 | free_joints=["panda_joint7"], 62 | ) 63 | -------------------------------------------------------------------------------- /predicators/refinement_estimators/__init__.py: -------------------------------------------------------------------------------- 1 | """Handle creation of refinement cost estimators.""" 2 | 3 | from predicators import utils 4 | from predicators.refinement_estimators.base_refinement_estimator import \ 5 | BaseRefinementEstimator 6 | 7 | __all__ = ["BaseRefinementEstimator", "create_refinement_estimator"] 8 | 9 | # Find the subclasses. 10 | utils.import_submodules(__path__, __name__) 11 | 12 | 13 | def create_refinement_estimator(name: str) -> BaseRefinementEstimator: 14 | """Create an approach given its name.""" 15 | for cls in utils.get_all_subclasses(BaseRefinementEstimator): 16 | if not cls.__abstractmethods__ and cls.get_name() == name: 17 | estimator = cls() 18 | break 19 | else: 20 | raise NotImplementedError(f"Unknown refinement cost estimator: {name}") 21 | return estimator 22 | -------------------------------------------------------------------------------- /predicators/refinement_estimators/base_refinement_estimator.py: -------------------------------------------------------------------------------- 1 | """Base class for a refinement cost estimator.""" 2 | 3 | import abc 4 | from pathlib import Path 5 | from typing import List, Set 6 | 7 | import numpy as np 8 | 9 | from predicators.envs import get_or_create_env 10 | from predicators.settings import CFG 11 | from predicators.structs import GroundAtom, Task, _GroundNSRT 12 | 13 | 14 | class BaseRefinementEstimator(abc.ABC): 15 | """Base refinement cost estimator.""" 16 | 17 | def __init__(self) -> None: 18 | self._env = get_or_create_env(CFG.env) 19 | self._rng = np.random.default_rng(CFG.seed) 20 | 21 | @classmethod 22 | @abc.abstractmethod 23 | def get_name(cls) -> str: 24 | """Get the unique name of this refinement cost estimator, for future 25 | use as the argument to `--refinement_estimator`.""" 26 | raise NotImplementedError("Override me!") 27 | 28 | @property 29 | @abc.abstractmethod 30 | def is_learning_based(self) -> bool: 31 | """Does the estimator learn from training tasks?""" 32 | raise NotImplementedError("Override me!") 33 | 34 | @abc.abstractmethod 35 | def get_cost(self, initial_task: Task, skeleton: List[_GroundNSRT], 36 | atoms_sequence: List[Set[GroundAtom]]) -> float: 37 | """Return an estimated cost for a proposed high-level skeleton.""" 38 | raise NotImplementedError("Override me!") 39 | 40 | def train(self, data: List) -> None: 41 | """Train the estimator on given training data. 42 | 43 | Only called if is_learning_based is True. 44 | """ 45 | 46 | def save_model(self, filepath: Path) -> None: 47 | """Save the training model of the approach to a file. 48 | 49 | Only called if is_learning_based is True. 50 | """ 51 | 52 | def load_model(self, filepath: Path) -> None: 53 | """Load the training model of the approach from a file. 54 | 55 | Only called if is_learning_based is True. 56 | """ 57 | -------------------------------------------------------------------------------- /predicators/third_party/fast_downward_translator/README.md: -------------------------------------------------------------------------------- 1 | Fast Downward translator, with light modifications made by Rohan. 2 | 3 | Code copied from the `src/translate/` directory in the [official repository at this commit from May 9, 2022](https://github.com/aibasel/downward/tree/3e3759d091196515fa68c44a729153100747c4bf). All credits go to the original authors. 4 | 5 | To use, call the function `main()` in translate.py, which takes in domain and problem file strings and returns a `SASTask` object (sas_tasks.py) representing a ground planning problem. 6 | 7 | Modifications: 8 | * Changed input and output to not require file I/O. 9 | * Removed [options.py](https://github.com/aibasel/downward/blob/3e3759d091196515fa68c44a729153100747c4bf/src/translate/options.py) and associated command-line arguments, replacing with the default values from the linked file. 10 | * Removed tests. 11 | * Changed imports to be absolute. 12 | * Ran our code autoformatter. -------------------------------------------------------------------------------- /predicators/third_party/fast_downward_translator/graph.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | 3 | 4 | class Graph: 5 | 6 | def __init__(self, nodes): 7 | self.nodes = nodes 8 | self.neighbours = {u: set() for u in nodes} 9 | 10 | def connect(self, u, v): 11 | self.neighbours[u].add(v) 12 | self.neighbours[v].add(u) 13 | 14 | def connected_components(self): 15 | remaining_nodes = set(self.nodes) 16 | result = [] 17 | 18 | def dfs(node): 19 | result[-1].append(node) 20 | remaining_nodes.remove(node) 21 | for neighbour in self.neighbours[node]: 22 | if neighbour in remaining_nodes: 23 | dfs(neighbour) 24 | 25 | while remaining_nodes: 26 | node = next(iter(remaining_nodes)) 27 | result.append([]) 28 | dfs(node) 29 | result[-1].sort() 30 | return sorted(result) 31 | 32 | 33 | def transitive_closure(pairs): 34 | # Warshall's algorithm. 35 | result = set(pairs) 36 | nodes = {u for (u, v) in pairs} | {v for (u, v) in pairs} 37 | for k in nodes: 38 | for i in nodes: 39 | for j in nodes: 40 | if (i, j) not in result and (i, k) in result and (k, 41 | j) in result: 42 | result.add((i, j)) 43 | return sorted(result) 44 | -------------------------------------------------------------------------------- /predicators/third_party/fast_downward_translator/pddl/__init__.py: -------------------------------------------------------------------------------- 1 | from .actions import Action, PropositionalAction 2 | from .axioms import Axiom, PropositionalAxiom 3 | from .conditions import Atom, Conjunction, Disjunction, ExistentialCondition, \ 4 | Falsity, Literal, NegatedAtom, Truth, UniversalCondition 5 | from .effects import ConditionalEffect, ConjunctiveEffect, CostEffect, \ 6 | Effect, SimpleEffect, UniversalEffect 7 | from .f_expression import Assign, Increase, NumericConstant, \ 8 | PrimitiveNumericExpression 9 | from .functions import Function 10 | from .pddl_types import Type, TypedObject 11 | from .predicates import Predicate 12 | from .tasks import Requirements, Task 13 | -------------------------------------------------------------------------------- /predicators/third_party/fast_downward_translator/pddl/functions.py: -------------------------------------------------------------------------------- 1 | class Function: 2 | 3 | def __init__(self, name, arguments, type_name): 4 | self.name = name 5 | self.arguments = arguments 6 | if type_name != "number": 7 | raise SystemExit("Error: object fluents not supported\n" + 8 | "(function %s has type %s)" % (name, type_name)) 9 | self.type_name = type_name 10 | 11 | def __str__(self): 12 | result = "%s(%s)" % (self.name, ", ".join(map(str, self.arguments))) 13 | if self.type_name: 14 | result += ": %s" % self.type_name 15 | return result 16 | -------------------------------------------------------------------------------- /predicators/third_party/fast_downward_translator/pddl/predicates.py: -------------------------------------------------------------------------------- 1 | class Predicate: 2 | 3 | def __init__(self, name, arguments): 4 | self.name = name 5 | self.arguments = arguments 6 | 7 | def __str__(self): 8 | return "%s(%s)" % (self.name, ", ".join(map(str, self.arguments))) 9 | 10 | def get_arity(self): 11 | return len(self.arguments) 12 | -------------------------------------------------------------------------------- /predicators/third_party/fast_downward_translator/pddl_parser/__init__.py: -------------------------------------------------------------------------------- 1 | from .pddl_file import open 2 | -------------------------------------------------------------------------------- /predicators/third_party/fast_downward_translator/pddl_parser/lisp_parser.py: -------------------------------------------------------------------------------- 1 | __all__ = ["ParseError", "parse_nested_list"] 2 | 3 | 4 | class ParseError(Exception): 5 | 6 | def __init__(self, value): 7 | self.value = value 8 | 9 | def __str__(self): 10 | return self.value 11 | 12 | 13 | # Basic functions for parsing PDDL (Lisp) files. 14 | def parse_nested_list(input_file): 15 | tokens = tokenize(input_file) 16 | next_token = next(tokens) 17 | if next_token != "(": 18 | raise ParseError("Expected '(', got %s." % next_token) 19 | result = list(parse_list_aux(tokens)) 20 | for tok in tokens: # Check that generator is exhausted. 21 | raise ParseError("Unexpected token: %s." % tok) 22 | return result 23 | 24 | 25 | def tokenize(input): 26 | for line in input.split("\n"): 27 | line = line.split(";", 1)[0] # Strip comments. 28 | try: 29 | line.encode("ascii") 30 | except UnicodeEncodeError: 31 | raise ParseError("Non-ASCII character outside comment: %s" % 32 | line[0:-1]) 33 | line = line.replace("(", " ( ").replace(")", " ) ").replace("?", " ?") 34 | for token in line.split(): 35 | yield token.lower() 36 | 37 | 38 | def parse_list_aux(tokenstream): 39 | # Leading "(" has already been swallowed. 40 | while True: 41 | try: 42 | token = next(tokenstream) 43 | except StopIteration: 44 | raise ParseError("Missing ')'") 45 | if token == ")": 46 | return 47 | elif token == "(": 48 | yield list(parse_list_aux(tokenstream)) 49 | else: 50 | yield token 51 | -------------------------------------------------------------------------------- /predicators/third_party/fast_downward_translator/pddl_parser/pddl_file.py: -------------------------------------------------------------------------------- 1 | from predicators.third_party.fast_downward_translator.pddl_parser import \ 2 | lisp_parser, parsing_functions 3 | 4 | file_open = open 5 | 6 | 7 | def open(domain_string, task_string): 8 | domain_pddl = lisp_parser.parse_nested_list(domain_string) 9 | task_pddl = lisp_parser.parse_nested_list(task_string) 10 | return parsing_functions.parse_task(domain_pddl, task_pddl) 11 | -------------------------------------------------------------------------------- /predicators/third_party/fast_downward_translator/timers.py: -------------------------------------------------------------------------------- 1 | import contextlib 2 | import os 3 | import sys 4 | import time 5 | 6 | 7 | class Timer: 8 | 9 | def __init__(self): 10 | self.start_time = time.time() 11 | self.start_clock = self._clock() 12 | 13 | def _clock(self): 14 | times = os.times() 15 | return times[0] + times[1] 16 | 17 | def __str__(self): 18 | return "[%.3fs CPU, %.3fs wall-clock]" % ( 19 | self._clock() - self.start_clock, time.time() - self.start_time) 20 | 21 | 22 | @contextlib.contextmanager 23 | def timing(text, block=False): 24 | timer = Timer() 25 | if block: 26 | print("%s..." % text) 27 | else: 28 | print("%s..." % text, end=' ') 29 | sys.stdout.flush() 30 | yield 31 | if block: 32 | print("%s: %s" % (text, timer)) 33 | else: 34 | print(timer) 35 | sys.stdout.flush() 36 | -------------------------------------------------------------------------------- /predicators/third_party/fast_downward_translator/tools.py: -------------------------------------------------------------------------------- 1 | def cartesian_product(sequences): 2 | # TODO: Rename this. It's not good that we have two functions 3 | # called "product" and "cartesian_product", of which "product" 4 | # computes cartesian products, while "cartesian_product" does not. 5 | 6 | # This isn't actually a proper cartesian product because we 7 | # concatenate lists, rather than forming sequences of atomic elements. 8 | # We could probably also use something like 9 | # map(itertools.chain, product(*sequences)) 10 | # but that does not produce the same results 11 | if not sequences: 12 | yield [] 13 | else: 14 | temp = list(cartesian_product(sequences[1:])) 15 | for item in sequences[0]: 16 | for sequence in temp: 17 | yield item + sequence 18 | 19 | 20 | def get_peak_memory_in_kb(): 21 | try: 22 | # This will only work on Linux systems. 23 | with open("/proc/self/status") as status_file: 24 | for line in status_file: 25 | parts = line.split() 26 | if parts[0] == "VmPeak:": 27 | return int(parts[1]) 28 | except OSError: 29 | pass 30 | raise Warning("warning: could not determine peak memory") 31 | -------------------------------------------------------------------------------- /predicators/third_party/ikfast/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Learning-and-Intelligent-Systems/predicators/5bd3f5bd21cc01e171faf748edf53bcfd720f4d1/predicators/third_party/ikfast/__init__.py -------------------------------------------------------------------------------- /predicators/third_party/ikfast/compile.py: -------------------------------------------------------------------------------- 1 | import fnmatch 2 | import importlib 3 | import os 4 | import shutil 5 | from distutils.core import setup 6 | from distutils.dir_util import copy_tree 7 | from distutils.extension import Extension 8 | 9 | # Build C++ extension by running: 'python setup.py build' 10 | # see: https://docs.python.org/3/extending/building.html 11 | 12 | # http://openrave.org/docs/0.8.2/openravepy/ikfast/ 13 | # https://github.com/rdiankov/openrave/blob/master/python/ikfast.py#L92 14 | # http://wiki.ros.org/Industrial/Tutorials/Create_a_Fast_IK_Solution 15 | 16 | # Yijiang 17 | # https://github.com/yijiangh/ikfast_pybind 18 | # https://github.com/yijiangh/conrob_pybullet/tree/master/utils/ikfast 19 | # https://github.com/yijiangh/choreo/blob/bc777069b8eb7283c74af26e5461532aec3d9e8a/framefab_robot/abb/framefab_irb6600/framefab_irb6600_support/doc/ikfast_tutorial.rst 20 | 21 | 22 | def compile_ikfast(module_name, cpp_filename, remove_build=False): 23 | ikfast_module = Extension(module_name, sources=[cpp_filename]) 24 | setup(name=module_name, 25 | version='1.0', 26 | description="ikfast module {}".format(module_name), 27 | ext_modules=[ikfast_module]) 28 | 29 | build_lib_path = None 30 | for root, dirnames, filenames in os.walk(os.getcwd()): 31 | if fnmatch.fnmatch(root, os.path.join(os.getcwd(), "*build", "lib*")): 32 | build_lib_path = root 33 | break 34 | assert build_lib_path 35 | 36 | copy_tree(build_lib_path, os.getcwd()) 37 | if remove_build: 38 | # TODO: error when compiling multiple arms for python2 39 | # error: unable to open output file 'build/temp.macosx-10.15-x86_64-2.7/movo_right_arm_ik.o': 'No such file or directory' 40 | shutil.rmtree(os.path.join(os.getcwd(), 'build')) 41 | 42 | try: 43 | importlib.import_module(module_name) 44 | print('\nikfast module {} imported successful'.format(module_name)) 45 | except ImportError as e: 46 | print('\nikfast module {} imported failed'.format(module_name)) 47 | raise e 48 | return True 49 | -------------------------------------------------------------------------------- /predicators/third_party/ikfast/panda_arm/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Learning-and-Intelligent-Systems/predicators/5bd3f5bd21cc01e171faf748edf53bcfd720f4d1/predicators/third_party/ikfast/panda_arm/__init__.py -------------------------------------------------------------------------------- /predicators/third_party/ikfast/panda_arm/compile.py: -------------------------------------------------------------------------------- 1 | ../compile.py -------------------------------------------------------------------------------- /predicators/third_party/ikfast/panda_arm/ikfast.h: -------------------------------------------------------------------------------- 1 | ../ikfast.h -------------------------------------------------------------------------------- /predicators/third_party/ikfast/panda_arm/setup.py: -------------------------------------------------------------------------------- 1 | """Note: this subdirectory is modified from the pybullet-planning repository 2 | by Caelan Garrett (https://github.com/caelan/pybullet-planning/).""" 3 | 4 | import sys 5 | 6 | from compile import compile_ikfast 7 | 8 | 9 | def main(): 10 | # lib name template: 'ikfast_' 11 | sys.argv[:] = sys.argv[:1] + ['build'] 12 | robot_name = 'panda_arm' 13 | compile_ikfast(module_name='ikfast_{}'.format(robot_name), 14 | cpp_filename='ikfast_{}.cpp'.format(robot_name)) 15 | 16 | 17 | if __name__ == '__main__': 18 | main() 19 | -------------------------------------------------------------------------------- /run_autoformat.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | yapf -i -r --style .style.yapf --exclude '**/third_party' predicators 3 | yapf -i -r --style .style.yapf scripts 4 | yapf -i -r --style .style.yapf tests 5 | yapf -i -r --style .style.yapf setup.py 6 | docformatter -i -r . --exclude venv predicators/third_party 7 | isort . 8 | -------------------------------------------------------------------------------- /scripts/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Learning-and-Intelligent-Systems/predicators/5bd3f5bd21cc01e171faf748edf53bcfd720f4d1/scripts/__init__.py -------------------------------------------------------------------------------- /scripts/configs/backchaining_predicate_invention.yaml: -------------------------------------------------------------------------------- 1 | # Predicate invention with backchaining operator learning 2 | --- 3 | APPROACHES: 4 | invent_allexclude_backchaining: 5 | NAME: "grammar_search_invention" 6 | FLAGS: 7 | strips_learner: "backchaining" 8 | excluded_predicates: "all" 9 | ENVS: 10 | cover: 11 | NAME: "cover" 12 | pybullet_blocks: 13 | NAME: "pybullet_blocks" 14 | painting: 15 | NAME: "painting" 16 | tools: 17 | NAME: "tools" 18 | FLAGS: 19 | num_train_tasks: 200 # requires more data (default is 50) 20 | pybullet_cover: 21 | NAME: "pybullet_cover" 22 | ARGS: [] 23 | FLAGS: {} 24 | START_SEED: 456 25 | NUM_SEEDS: 10 26 | ... 27 | -------------------------------------------------------------------------------- /scripts/configs/example_basic.yaml: -------------------------------------------------------------------------------- 1 | # An example configuration file. 2 | --- 3 | APPROACHES: 4 | my-oracle: # used in constructing the experiment ID 5 | NAME: "oracle" 6 | nsrt-learning: 7 | NAME: "nsrt_learning" 8 | FLAGS: 9 | disable_harmlessness_check: True # just an example 10 | ENVS: 11 | cover-default-settings: # used in constructing the experiment ID 12 | NAME: "cover" 13 | cover-single-block: 14 | NAME: "cover" 15 | FLAGS: 16 | cover_num_blocks: 1 17 | cover_block_widths: [0.1] 18 | ARGS: 19 | - "debug" 20 | FLAGS: # general flags 21 | num_train_tasks: 20 22 | num_test_tasks: 10 23 | START_SEED: 456 24 | NUM_SEEDS: 2 25 | -------------------------------------------------------------------------------- /scripts/configs/example_multiple_combinations.yaml: -------------------------------------------------------------------------------- 1 | # An example configuration file showing how to define multiple approach/env 2 | # combinations, i.e., not just one cross product. In this example, the oracle 3 | # approach is run in cover, and both the oracle approach and nsrt_learning are 4 | # run in blocks. 5 | --- 6 | APPROACHES: 7 | oracle: 8 | NAME: "oracle" 9 | ENVS: 10 | cover: 11 | NAME: "cover" 12 | ARGS: [] 13 | FLAGS: {} 14 | START_SEED: 456 15 | NUM_SEEDS: 3 16 | ... 17 | --- 18 | APPROACHES: 19 | oracle: 20 | NAME: "oracle" 21 | nsrt-learning: 22 | NAME: "nsrt_learning" 23 | ENVS: 24 | blocks: 25 | NAME: "blocks" 26 | ARGS: [] 27 | FLAGS: {} 28 | START_SEED: 456 29 | NUM_SEEDS: 3 30 | -------------------------------------------------------------------------------- /scripts/configs/full_pipeline.yaml: -------------------------------------------------------------------------------- 1 | # Learning operators, samplers, policies, and predicates. 2 | --- 3 | APPROACHES: 4 | learn_all: 5 | NAME: "grammar_search_invention" 6 | FLAGS: 7 | min_perc_data_for_nsrt: 1 8 | segmenter: "contacts" 9 | neural_gaus_regressor_max_itr: 50000 10 | option_learner: direct_bc 11 | sesame_max_samples_per_step: 100 # mainly to improve demo collection 12 | ENVS: 13 | cover: 14 | NAME: "cover_multistep_options" 15 | ARGS: [] 16 | FLAGS: 17 | num_train_tasks: 1000 18 | excluded_predicates: "all" 19 | timeout: 300 20 | START_SEED: 456 21 | NUM_SEEDS: 10 22 | ... 23 | -------------------------------------------------------------------------------- /scripts/configs/kitchen_active_learning.yaml: -------------------------------------------------------------------------------- 1 | # Run active learning experiments in the kitchen environment. 2 | --- 3 | APPROACHES: 4 | active_sampler_learning: 5 | NAME: "active_sampler_learning" 6 | FLAGS: 7 | explorer: "active_sampler" 8 | ENVS: 9 | kitchen-knob-only: 10 | NAME: "kitchen" 11 | FLAGS: 12 | kitchen_goals: "knob_only" 13 | kitchen-light-only: 14 | NAME: "kitchen" 15 | FLAGS: 16 | kitchen_goals: "light_only" 17 | kitchen-kettle-only: 18 | NAME: "kitchen" 19 | FLAGS: 20 | kitchen_goals: "kettle_only" 21 | kitchen-all: 22 | NAME: "kitchen" 23 | FLAGS: 24 | kitchen_goals: "all" 25 | ARGS: [] 26 | FLAGS: # general flags 27 | bilevel_plan_without_sim: True 28 | num_train_tasks: 100 29 | num_test_tasks: 10 30 | max_initial_demos: 0 31 | max_num_steps_interaction_request: 500 32 | max_num_steps_option_rollout: 250 33 | online_nsrt_learning_requests_per_cycle: 5 34 | num_online_learning_cycles: 5 35 | sampler_mlp_classifier_max_itr: 100000 36 | mlp_classifier_balance_data: False 37 | active_sampler_learning_use_teacher: False 38 | strips_learner: "oracle" 39 | sampler_learner: "oracle" 40 | active_sampler_learning_explore_length_base: 10000 # effectively disable 41 | START_SEED: 456 42 | NUM_SEEDS: 10 43 | -------------------------------------------------------------------------------- /scripts/configs/kitchen_oracle.yaml: -------------------------------------------------------------------------------- 1 | # Run oracle on kitchen environment. 2 | --- 3 | APPROACHES: 4 | oracle-perfect-samplers: 5 | NAME: "oracle" 6 | FLAGS: 7 | kitchen_use_perfect_samplers: True 8 | oracle: 9 | NAME: "oracle" 10 | ENVS: 11 | kitchen: 12 | NAME: "kitchen" 13 | ARGS: 14 | - "debug" 15 | FLAGS: # general flags 16 | bilevel_plan_without_sim: True 17 | num_train_tasks: 0 18 | num_test_tasks: 5 19 | START_SEED: 456 20 | NUM_SEEDS: 2 21 | -------------------------------------------------------------------------------- /scripts/configs/llm_pddl_ablations.yaml: -------------------------------------------------------------------------------- 1 | # Varun's experiments on predicate, operator, and syntax renaming. 2 | --- 3 | APPROACHES: 4 | llm_predicate_renaming: 5 | NAME: "llm_predicate_renaming" 6 | FLAGS: 7 | llm_num_completions: 1 8 | llm_option_renaming: 9 | NAME: "llm_option_renaming" 10 | FLAGS: 11 | llm_num_completions: 1 12 | llm_syntax_renaming: 13 | NAME: "llm_syntax_renaming" 14 | FLAGS: 15 | llm_num_completions: 1 16 | ENVS: 17 | easy_delivery: 18 | NAME: "pddl_delivery_procedural_tasks" 19 | FLAGS: 20 | pddl_delivery_procedural_train_min_num_locs: 3 21 | pddl_delivery_procedural_train_max_num_locs: 5 22 | pddl_delivery_procedural_train_min_want_locs: 1 23 | pddl_delivery_procedural_train_max_want_locs: 2 24 | pddl_delivery_procedural_test_min_num_locs: 4 25 | pddl_delivery_procedural_test_max_num_locs: 6 26 | pddl_delivery_procedural_test_min_want_locs: 2 27 | pddl_delivery_procedural_test_max_want_locs: 3 28 | pddl_delivery_procedural_test_max_extra_newspapers: 1 29 | ARGS: 30 | - "debug" 31 | FLAGS: 32 | num_train_tasks: 5 33 | num_test_tasks: 10 34 | strips_learner: "oracle" 35 | timeout: 100 36 | llm_model_name: "text-davinci-002" 37 | llm_use_cache_only: False # change to true to rerun 38 | START_SEED: 456 39 | NUM_SEEDS: 5 40 | -------------------------------------------------------------------------------- /scripts/configs/online_rl_cover.yaml: -------------------------------------------------------------------------------- 1 | # Sanity test for online RL approach. 2 | --- 3 | APPROACHES: 4 | maple_q: 5 | NAME: "maple_q" 6 | FLAGS: 7 | explorer: "maple_q" 8 | mlp_regressor_max_itr: 640000 9 | active_sampler_learning_batch_size: 512 10 | ENVS: 11 | discrete_regional_bumpy_cover: 12 | NAME: "regional_bumpy_cover" 13 | FLAGS: 14 | regional_bumpy_cover_include_impossible_nsrt: "True" # NOTE 15 | bumpy_cover_init_bumpy_prob: 0.0 # NOTE 16 | bumpy_cover_num_bumps: 3 17 | bumpy_cover_spaces_per_bump: 3 18 | cover_num_blocks: 1 19 | cover_block_widths: '[0.01]' 20 | cover_num_targets: 1 21 | cover_target_widths: '[0.008]' 22 | continuous_regional_bumpy_cover: 23 | NAME: "regional_bumpy_cover" 24 | FLAGS: 25 | regional_bumpy_cover_include_impossible_nsrt: "False" # NOTE 26 | bumpy_cover_init_bumpy_prob: 1.0 # NOTE 27 | bumpy_cover_num_bumps: 3 28 | bumpy_cover_spaces_per_bump: 3 29 | cover_num_blocks: 1 30 | cover_block_widths: '[0.01]' 31 | cover_num_targets: 1 32 | cover_target_widths: '[0.008]' 33 | hybrid_regional_bumpy_cover: 34 | NAME: "regional_bumpy_cover" 35 | FLAGS: 36 | regional_bumpy_cover_include_impossible_nsrt: "True" # NOTE 37 | bumpy_cover_init_bumpy_prob: 1.0 # NOTE 38 | bumpy_cover_num_bumps: 3 39 | bumpy_cover_spaces_per_bump: 3 40 | cover_num_blocks: 1 41 | cover_block_widths: '[0.01]' 42 | cover_num_targets: 1 43 | cover_target_widths: '[0.008]' 44 | ARGS: 45 | - "debug" 46 | FLAGS: 47 | strips_learner: "oracle" 48 | sampler_learner: "oracle" 49 | bilevel_plan_without_sim: "True" 50 | max_initial_demos: 0 51 | online_nsrt_learning_requests_per_cycle: 200 52 | num_online_learning_cycles: 20 53 | num_train_tasks: 1000 54 | num_test_tasks: 10 55 | max_num_steps_interaction_request: 5 56 | horizon: 2 # NOTE, otherwise too easy 57 | START_SEED: 456 58 | NUM_SEEDS: 5 59 | -------------------------------------------------------------------------------- /scripts/configs/pg3_offline.yaml: -------------------------------------------------------------------------------- 1 | # Offline PG3 Configuration File 2 | --- 3 | APPROACHES: 4 | pg3: 5 | NAME: "pg3" 6 | pg3-given-ops: 7 | NAME: "pg3" 8 | FLAGS: 9 | strips_learner: oracle 10 | plan-only: 11 | NAME: "oracle" 12 | ENVS: 13 | delivery: 14 | NAME: "pddl_easy_delivery_procedural_tasks" 15 | spanner: 16 | NAME: "pddl_spanner_procedural_tasks" 17 | forest: 18 | NAME: "pddl_forest_procedural_tasks" 19 | ARGS: [] 20 | FLAGS: 21 | num_train_tasks: 50 22 | START_SEED: 456 23 | NUM_SEEDS: 10 24 | -------------------------------------------------------------------------------- /scripts/configs/pg3_online.yaml: -------------------------------------------------------------------------------- 1 | # Online PG3 Configuration File 2 | --- 3 | APPROACHES: 4 | pg3: 5 | NAME: "online_pg3" 6 | pg3-random-options: 7 | NAME: "online_pg3" 8 | FLAGS: 9 | explorer: random_options 10 | pg3-glib: 11 | NAME: "online_pg3" 12 | FLAGS: 13 | explorer: glib 14 | pg3-given-ops: 15 | NAME: "online_pg3" 16 | FLAGS: 17 | strips_learner: oracle 18 | plan-only: 19 | NAME: "oracle" 20 | ENVS: 21 | delivery: 22 | NAME: "pddl_easy_delivery_procedural_tasks" 23 | spanner: 24 | NAME: "pddl_spanner_procedural_tasks" 25 | forest: 26 | NAME: "pddl_forest_procedural_tasks" 27 | ARGS: [] 28 | FLAGS: 29 | num_train_tasks: 50 30 | num_test_tasks: 10 31 | max_initial_demos: 0 32 | max_num_steps_interaction_request: 10 33 | START_SEED: 456 34 | NUM_SEEDS: 10 35 | -------------------------------------------------------------------------------- /scripts/configs/pg4.yaml: -------------------------------------------------------------------------------- 1 | # PG4 experiments. 2 | --- 3 | APPROACHES: 4 | pg3: 5 | NAME: "pg3" 6 | pg4: 7 | NAME: "pg4" 8 | plan-only: 9 | NAME: "oracle" 10 | ENVS: 11 | cover-easy: # downward refinable. PG3 should succeed 12 | NAME: "cover" 13 | FLAGS: 14 | cover_initial_holding_prob: 0.0 15 | cover: # PG3 should sometimes fail, but PG4 should succeed 16 | NAME: "cover" 17 | painting-no-holding-shelf-only: 18 | NAME: "painting" 19 | FLAGS: 20 | painting_initial_holding_prob: 0.0 21 | painting_goal_receptacles: "shelf" 22 | painting-no-lid-no-holding-box-only: 23 | NAME: "painting" 24 | FLAGS: 25 | painting_lid_open_prob: 1.0 26 | painting_initial_holding_prob: 0.0 27 | painting_goal_receptacles: "box" 28 | painting-lid-no-holding-box-only: 29 | NAME: "painting" 30 | FLAGS: 31 | painting_initial_holding_prob: 0.0 32 | painting_goal_receptacles: "box" 33 | painting-lid-no-holding-boxandshelf: 34 | NAME: "painting" 35 | FLAGS: 36 | painting_initial_holding_prob: 0.0 37 | screws: 38 | NAME: "screws" 39 | repeated-nextto: 40 | NAME: "repeated_nextto" 41 | cluttered-table: 42 | NAME: "cluttered_table" 43 | coffee-easy: 44 | NAME: "coffee" 45 | FLAGS: 46 | coffee_jug_init_rot_amt: 0 47 | coffee-hard: 48 | NAME: "coffee" 49 | ARGS: [] 50 | FLAGS: 51 | strips_learner: oracle 52 | sampler_learner: oracle 53 | num_train_tasks: 50 54 | START_SEED: 456 55 | NUM_SEEDS: 10 56 | -------------------------------------------------------------------------------- /scripts/configs/pred_invention_slowness.yaml: -------------------------------------------------------------------------------- 1 | # Predicate invention slowness tests 2 | --- 3 | APPROACHES: 4 | invent_allexclude_backchaining: 5 | NAME: "grammar_search_invention" 6 | FLAGS: 7 | strips_learner: "pnad_search" 8 | excluded_predicates: "all" 9 | grammar_search_grammar_use_diff_features: True 10 | grammar_search_max_predicates: 250 11 | grammar_search_predicate_cost_upper_bound: 15 12 | repeated_nextto_nextto_thresh: 1.0 13 | 14 | ENVS: 15 | rnt_simple: 16 | NAME: "repeated_nextto_simple" 17 | ARGS: [] 18 | FLAGS: {} 19 | START_SEED: 456 20 | NUM_SEEDS: 10 21 | ... 22 | -------------------------------------------------------------------------------- /scripts/find_unused_functions.py: -------------------------------------------------------------------------------- 1 | """Report all unused top-level functions in a particular file. 2 | 3 | Note: this can report false positives because we only check for the string: 4 | "(", while sometimes functions are used in other ways. 5 | """ 6 | 7 | import re 8 | import subprocess 9 | 10 | FILENAME = "predicators/utils.py" 11 | DIRS_TO_CHECK = [ 12 | "predicators/", 13 | "scripts/", 14 | # "tests/", 15 | ] 16 | 17 | with open(FILENAME, "r", encoding="utf-8") as f: 18 | lines = f.readlines() 19 | for line in lines: 20 | if line.startswith("def "): # top-level only! 21 | match = re.match(r"def (.+?)\(.*", line) 22 | assert match is not None, f"Malformed line: {line}" 23 | func_name = match.groups()[0] 24 | dirs = " ".join(DIRS_TO_CHECK) 25 | results = subprocess.getoutput(f"git grep '{func_name}(' {dirs}") 26 | assert results # at least must match the definition line 27 | num_hits = len(results.split("\n")) 28 | assert num_hits > 0 29 | if num_hits == 1: 30 | print(func_name) 31 | -------------------------------------------------------------------------------- /scripts/local/launch.py: -------------------------------------------------------------------------------- 1 | """Launch experiments defined in config files locally. 2 | 3 | Run experiments sequentially, not in parallel. 4 | 5 | python scripts/local/launch.py --config example_basic.yaml 6 | 7 | The default branch can be overridden with the --branch flag. 8 | """ 9 | 10 | import argparse 11 | import os 12 | import subprocess 13 | 14 | from scripts.cluster_utils import DEFAULT_BRANCH, config_to_cmd_flags, \ 15 | config_to_logfile, generate_run_configs, get_cmds_to_prep_repo 16 | 17 | 18 | def _main() -> None: 19 | # Set up argparse. 20 | parser = argparse.ArgumentParser() 21 | parser.add_argument("--config", required=True, type=str) 22 | parser.add_argument("--branch", type=str, default=DEFAULT_BRANCH) 23 | args = parser.parse_args() 24 | # Prepare the repo. 25 | for cmd in get_cmds_to_prep_repo(args.branch): 26 | subprocess.run(cmd, shell=True, check=False) 27 | # Create the run commands. 28 | cmds = [] 29 | for cfg in generate_run_configs(args.config): 30 | cmd_flags = config_to_cmd_flags(cfg) 31 | logfile = os.path.join("logs", config_to_logfile(cfg)) 32 | cmd_flags = config_to_cmd_flags(cfg) 33 | if cfg.train_refinement_estimator: 34 | entry_point = "train_refinement_estimator.py" 35 | else: 36 | entry_point = "main.py" 37 | cmd = f"python predicators/{entry_point} {cmd_flags} > {logfile}" 38 | cmds.append(cmd) 39 | # Run the commands in order. 40 | num_cmds = len(cmds) 41 | for i, cmd in enumerate(cmds): 42 | print(f"********* RUNNING COMMAND {i+1} of {num_cmds} *********") 43 | subprocess.run(cmd, shell=True, check=False) 44 | 45 | 46 | if __name__ == "__main__": 47 | _main() 48 | -------------------------------------------------------------------------------- /scripts/local/print_commands.py: -------------------------------------------------------------------------------- 1 | """Helper script for just printing out the commands for a config. 2 | 3 | Unlike other scripts, doesn't change the branch or prepare the repo. 4 | """ 5 | 6 | import argparse 7 | 8 | from scripts.cluster_utils import config_to_cmd_flags, generate_run_configs 9 | 10 | 11 | def _main() -> None: 12 | parser = argparse.ArgumentParser() 13 | parser.add_argument("--config", required=True, type=str) 14 | args = parser.parse_args() 15 | for i, cfg in enumerate(generate_run_configs(args.config)): 16 | cmd_flags = config_to_cmd_flags(cfg) 17 | cmd = f"python predicators/main.py {cmd_flags}" 18 | print(f"\n************** COMMAND {i} **************") 19 | print(cmd) 20 | 21 | 22 | if __name__ == "__main__": 23 | _main() 24 | -------------------------------------------------------------------------------- /scripts/openstack/README.md: -------------------------------------------------------------------------------- 1 | # Instructions for Using Openstack 2 | 3 | 1. Request an account through the LIS group. See [here](https://tig.csail.mit.edu/shared-computing/open-stack/quick-start/). 4 | 2. Follow the [instructions for creating and uploading a private key](https://tig.csail.mit.edu/shared-computing/open-stack/openstack-ssh-key/). 5 | 3. Launch instances using the `predicators` image and your private key. Make sure to enable `allow_incoming_ssh` in the security settings when launching the instance so that the machine is actually accessible. Make sure you launch enough instances so that each (environment, approach, seed) can have one instance. 6 | 1. You might need to create a new image. You can do this by launching an instance, ssh'ing it, installing everything you need, and then using the `Create Snapshot` Action on the instances dashboard. To ssh a machine, find its IP on openstack, and do `ssh ubuntu@` (be sure you're on the MIT network)! 7 | 4. Create a file (e.g. `machines.txt`) that lists your instance IP addresses, one per line. Do not include anything on the line that isn't the IP address. 8 | 5. Create an experiment yaml file (see `scripts/openstack/configs/example_basic.yaml` for an example). 9 | 6. Run `python scripts/openstack/launch.py --config --machines --sshkey ` to launch your experiments. 10 | 7. Wait for your experiments to complete. 11 | 8. Run `python scripts/openstack/download.py --dir --machines --sshkey ` to download the results. 12 | -------------------------------------------------------------------------------- /scripts/openstack/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Learning-and-Intelligent-Systems/predicators/5bd3f5bd21cc01e171faf748edf53bcfd720f4d1/scripts/openstack/__init__.py -------------------------------------------------------------------------------- /scripts/openstack/kill_all.py: -------------------------------------------------------------------------------- 1 | """Script for killing all active openstack predicator experiments. 2 | 3 | Analogous to scancel on supercloud. 4 | 5 | WARNING: any other python3.8 processes running on the machine will also be 6 | killed (but there typically shouldn't be any). 7 | 8 | See launch.py for information about the format of machines.txt. 9 | 10 | Usage example: 11 | python scripts/openstack/kill_all.py --machines machines.txt \ 12 | --sshkey ~/.ssh/cloud.key 13 | """ 14 | 15 | import argparse 16 | import os 17 | 18 | from scripts.cluster_utils import run_cmds_on_machine 19 | 20 | 21 | def _main() -> None: 22 | # Set up argparse. 23 | parser = argparse.ArgumentParser() 24 | parser.add_argument("--machines", required=True, type=str) 25 | parser.add_argument("--sshkey", required=True, type=str) 26 | args = parser.parse_args() 27 | openstack_dir = os.path.dirname(os.path.realpath(__file__)) 28 | # Load the machine IPs. 29 | machine_file = os.path.join(openstack_dir, args.machines) 30 | with open(machine_file, "r", encoding="utf-8") as f: 31 | machines = f.read().splitlines() 32 | # Make sure that the ssh key exists. 33 | assert os.path.exists(args.sshkey) 34 | # Loop through each machine and kill the python3.8 process. 35 | kill_cmd = "pkill -9 python3.8" 36 | for machine in machines: 37 | print(f"Killing machine {machine}") 38 | # Allow return code 1, meaning that no process was found to kill. 39 | run_cmds_on_machine([kill_cmd], 40 | "ubuntu", 41 | machine, 42 | ssh_key=args.sshkey, 43 | allowed_return_codes=(0, 1)) 44 | 45 | 46 | if __name__ == "__main__": 47 | _main() 48 | -------------------------------------------------------------------------------- /scripts/run_checks.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "Running autoformatting." 4 | yapf -i -r --style .style.yapf --exclude '**/third_party' predicators 5 | yapf -i -r --style .style.yapf scripts 6 | yapf -i -r --style .style.yapf tests 7 | docformatter -i -r . --exclude venv predicators/third_party 8 | isort . 9 | echo "Autoformatting complete." 10 | 11 | echo "Running type checking." 12 | mypy . --config-file mypy.ini 13 | if [ $? -eq 0 ]; then 14 | echo "Type checking passed." 15 | else 16 | echo "Type checking failed! Terminating check script early." 17 | exit 18 | fi 19 | 20 | echo "Running linting." 21 | pytest . --pylint -m pylint --pylint-rcfile=.predicators_pylintrc 22 | if [ $? -eq 0 ]; then 23 | echo "Linting passed." 24 | else 25 | echo "Linting failed! Terminating check script early." 26 | exit 27 | fi 28 | 29 | echo "Running unit tests." 30 | pytest -s tests/ --cov-config=.coveragerc --cov=predicators/ --cov=tests/ --cov-fail-under=100 --cov-report=term-missing:skip-covered --durations=0 31 | if [ $? -eq 0 ]; then 32 | echo "Unit tests passed." 33 | else 34 | echo "Unit tests failed!" 35 | exit 36 | fi 37 | 38 | echo "All checks passed!" 39 | -------------------------------------------------------------------------------- /scripts/supercloud/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Learning-and-Intelligent-Systems/predicators/5bd3f5bd21cc01e171faf748edf53bcfd720f4d1/scripts/supercloud/__init__.py -------------------------------------------------------------------------------- /scripts/supercloud/download.py: -------------------------------------------------------------------------------- 1 | """Download results from supercloud experiments. 2 | 3 | Usage example: 4 | 5 | python scripts/supercloud/download.py --dir "$PWD" --user tslvr 6 | 7 | By default, we assume that the predicators directory on supercloud is located 8 | at ~/predicators. Otherwise, use the --supercloud_dir flag. Example: 9 | 10 | python scripts/supercloud/download.py --dir "$PWD" --user njk \ 11 | --supercloud_dir "~/GitHub/research/predicators" 12 | """ 13 | 14 | import argparse 15 | import os 16 | 17 | from scripts.cluster_utils import SAVE_DIRS, SUPERCLOUD_IP 18 | 19 | 20 | def _main() -> None: 21 | # Set up argparse. 22 | parser = argparse.ArgumentParser() 23 | parser.add_argument("--dir", required=True, type=str) 24 | parser.add_argument("--user", required=True, type=str) 25 | parser.add_argument("--supercloud_dir", default="~/predicators", type=str) 26 | args = parser.parse_args() 27 | # Create the download directory if it doesn't exist. 28 | os.makedirs(args.dir, exist_ok=True) 29 | # Download the results. 30 | print(f"Downloading results from supercloud for user {args.user}") 31 | host = f"{args.user}@{SUPERCLOUD_IP}" 32 | for save_dir in SAVE_DIRS: 33 | local_save_dir = os.path.join(args.dir, save_dir) 34 | os.makedirs(local_save_dir, exist_ok=True) 35 | cmd = "scp -r -o StrictHostKeyChecking=no " + \ 36 | f"{host}:{args.supercloud_dir}/{save_dir}/* {local_save_dir}" 37 | retcode = os.system(cmd) 38 | if retcode != 0: 39 | print(f"WARNING: command failed: {cmd}") 40 | 41 | 42 | if __name__ == "__main__": 43 | _main() 44 | -------------------------------------------------------------------------------- /scripts/supercloud/kill_all.py: -------------------------------------------------------------------------------- 1 | """Script to kill all experiments running on supercloud for a given user. 2 | 3 | Runs scancel -u on supercloud. 4 | 5 | Usage example: 6 | 7 | python scripts/supercloud/kill_all.py --user tslvr 8 | """ 9 | 10 | import argparse 11 | 12 | from scripts.cluster_utils import SUPERCLOUD_IP, run_cmds_on_machine 13 | 14 | 15 | def _main() -> None: 16 | # Set up argparse. 17 | parser = argparse.ArgumentParser() 18 | parser.add_argument("--user", required=True, type=str) 19 | args = parser.parse_args() 20 | print(f"Killing all jobs on supercloud for user {args.user}") 21 | kill_cmd = f"scancel -u {args.user}" 22 | run_cmds_on_machine([kill_cmd], args.user, SUPERCLOUD_IP) 23 | 24 | 25 | if __name__ == "__main__": 26 | _main() 27 | -------------------------------------------------------------------------------- /scripts/supercloud/run_predicators_evalonly_experiments.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | FILE="scripts/supercloud/submit_supercloud_job.py" 4 | NUM_TRAIN_TASKS="200" 5 | ALL_ENVS=( 6 | "cover" 7 | "pybullet_blocks" 8 | "painting" 9 | "tools" 10 | ) 11 | 12 | # We want this to crash if backup_results already exists, because overwriting it would be bad. 13 | mkdir backup_results && mv results/* backup_results 14 | 15 | if [ $? -ne 0 ]; then 16 | echo "backup_results/ already exists, exiting" 17 | exit 1 18 | fi 19 | 20 | for ENV in ${ALL_ENVS[@]}; do 21 | # Downrefeval ablation. 22 | echo python $FILE --experiment_id ${ENV}_main_${NUM_TRAIN_TASKS}demo --env $ENV --approach grammar_search_invention --excluded_predicates all --num_train_tasks $NUM_TRAIN_TASKS --sesame_max_skeletons_optimized 1 --load_approach --load_data 23 | 24 | # GNN model-free baseline. 25 | echo python $FILE --experiment_id ${ENV}_gnn_shooting_${NUM_TRAIN_TASKS}demo --env $ENV --approach gnn_option_policy --excluded_predicates all --num_train_tasks $NUM_TRAIN_TASKS --gnn_option_policy_solve_with_shooting False --load_approach --load_data 26 | done 27 | 28 | # Commands to run after all jobs are finished: 29 | # for i in results/*main* ; do mv "$i" "${i/main/downrefeval}" ; done 30 | # for i in results/*gnn* ; do mv "$i" "${i/gnn_shooting/gnn_modelfree}" ; done 31 | # mv backup_results/* results/ 32 | # rm -r backup_results 33 | -------------------------------------------------------------------------------- /scripts/supercloud/run_predicators_num_demos_experiments.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | FILE="scripts/supercloud/submit_supercloud_job.py" 4 | ALL_NUM_TRAIN_TASKS=( 5 | "25" 6 | "50" 7 | "75" 8 | "100" 9 | "125" 10 | "150" 11 | "175" 12 | ) 13 | ALL_ENVS=( 14 | "cover" 15 | "pybullet_blocks" 16 | "painting" 17 | "tools" 18 | ) 19 | 20 | for ENV in ${ALL_ENVS[@]}; do 21 | for NUM_TRAIN_TASKS in ${ALL_NUM_TRAIN_TASKS[@]}; do 22 | # Main approach. 23 | python $FILE --experiment_id ${ENV}_main_${NUM_TRAIN_TASKS}demo --env $ENV --approach grammar_search_invention --excluded_predicates all --num_train_tasks $NUM_TRAIN_TASKS 24 | # GNN option policy approach. 25 | python $FILE --experiment_id ${ENV}_gnn_shooting_${NUM_TRAIN_TASKS}demo --env $ENV --approach gnn_option_policy --excluded_predicates all --num_train_tasks $NUM_TRAIN_TASKS 26 | done 27 | done 28 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | """Setup script.""" 2 | from setuptools import find_packages, setup 3 | 4 | setup( 5 | name="predicators", 6 | version="0.1.0", 7 | packages=find_packages(include=["predicators", "predicators.*"]), 8 | install_requires=[ 9 | "numpy==1.23.5", 10 | "pytest==7.1.3", 11 | "mypy==1.8.0", 12 | "gym==0.26.2", 13 | "matplotlib==3.6.2", 14 | "imageio==2.22.2", 15 | "imageio-ffmpeg", 16 | "pandas==1.5.1", 17 | "torch==2.0.1", 18 | "scipy==1.9.3", 19 | "tabulate==0.9.0", 20 | "dill==0.3.5.1", 21 | "pyperplan", 22 | "pathos", 23 | "pillow==10.3.0", 24 | "requests", 25 | "slack_bolt", 26 | "pybullet>=3.2.0", 27 | "scikit-learn==1.1.2", 28 | "graphlib-backport", 29 | "openai==1.19.0", 30 | "pyyaml==6.0", 31 | "pylint==2.14.5", 32 | "types-PyYAML", 33 | "lisdf", 34 | "seaborn==0.12.1", 35 | "smepy@git+https://github.com/sebdumancic/structure_mapping.git", 36 | "pg3@git+https://github.com/tomsilver/pg3.git", 37 | "gym_sokoban@git+https://github.com/Learning-and-Intelligent-Systems/gym-sokoban.git", # pylint: disable=line-too-long 38 | "ImageHash", 39 | "google-generativeai", 40 | "tenacity", 41 | "httpx==0.27.0" 42 | ], 43 | include_package_data=True, 44 | extras_require={ 45 | "develop": [ 46 | "pytest-cov==2.12.1", "pytest-pylint==0.18.0", "yapf==0.32.0", 47 | "docformatter==1.4", "isort==5.10.1", "mypy-extensions==1.0.0" 48 | ] 49 | }) 50 | -------------------------------------------------------------------------------- /tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Learning-and-Intelligent-Systems/predicators/5bd3f5bd21cc01e171faf748edf53bcfd720f4d1/tests/__init__.py -------------------------------------------------------------------------------- /tests/approaches/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Learning-and-Intelligent-Systems/predicators/5bd3f5bd21cc01e171faf748edf53bcfd720f4d1/tests/approaches/__init__.py -------------------------------------------------------------------------------- /tests/approaches/test_llm_option_renaming_approach.py: -------------------------------------------------------------------------------- 1 | """Test cases for the option-renaming open-loop LLM approach.""" 2 | from predicators import utils 3 | from predicators.approaches.llm_option_renaming_approach import \ 4 | LLMOptionRenamingApproach 5 | from predicators.envs import create_new_env 6 | from predicators.ground_truth_models import get_gt_options 7 | 8 | 9 | def test_llm_option_renaming_approach(): 10 | """Tests for LLMOptionRenamingApproach().""" 11 | env_name = "pddl_easy_delivery_procedural_tasks" 12 | utils.reset_config({ 13 | "env": env_name, 14 | "approach": "llm_option_renaming", 15 | "num_train_tasks": 1, 16 | "num_test_tasks": 1, 17 | "strips_learner": "oracle", 18 | }) 19 | env = create_new_env(env_name) 20 | train_tasks = [t.task for t in env.get_train_tasks()] 21 | approach = LLMOptionRenamingApproach(env.predicates, 22 | get_gt_options(env.get_name()), 23 | env.types, env.action_space, 24 | train_tasks) 25 | assert approach.get_name() == "llm_option_renaming" 26 | assert approach._renaming_prefixes == [" ", "\n"] # pylint: disable=protected-access 27 | assert approach._renaming_suffixes == ["("] # pylint: disable=protected-access 28 | subs = approach._orig_to_replace # pylint: disable=protected-access 29 | assert set(subs) == {o.name for o in get_gt_options(env.get_name())} 30 | assert all(len(k) == len(v) for k, v in subs.items()) 31 | -------------------------------------------------------------------------------- /tests/approaches/test_llm_predicate_renaming_approach.py: -------------------------------------------------------------------------------- 1 | """Test cases for the predicate-renaming open-loop LLM approach.""" 2 | from predicators import utils 3 | from predicators.approaches.llm_predicate_renaming_approach import \ 4 | LLMPredicateRenamingApproach 5 | from predicators.envs import create_new_env 6 | from predicators.ground_truth_models import get_gt_options 7 | 8 | 9 | def test_llm_predicate_renaming_approach(): 10 | """Tests for LLMPredicateRenamingApproach().""" 11 | env_name = "pddl_easy_delivery_procedural_tasks" 12 | utils.reset_config({ 13 | "env": env_name, 14 | "approach": "llm_predicate_renaming", 15 | "num_train_tasks": 1, 16 | "num_test_tasks": 1, 17 | "strips_learner": "oracle", 18 | }) 19 | env = create_new_env(env_name) 20 | train_tasks = [t.task for t in env.get_train_tasks()] 21 | approach = LLMPredicateRenamingApproach(env.predicates, 22 | get_gt_options(env.get_name()), 23 | env.types, env.action_space, 24 | train_tasks) 25 | assert approach.get_name() == "llm_predicate_renaming" 26 | assert approach._renaming_prefixes == [" ", "\n"] # pylint: disable=protected-access 27 | assert approach._renaming_suffixes == ["("] # pylint: disable=protected-access 28 | subs = approach._orig_to_replace # pylint: disable=protected-access 29 | assert set(subs) == {p.name for p in env.predicates} 30 | assert all(len(k) == len(v) for k, v in subs.items()) 31 | -------------------------------------------------------------------------------- /tests/approaches/test_llm_syntax_renaming_approach.py: -------------------------------------------------------------------------------- 1 | """Test cases for the syntax-renaming open-loop LLM approach.""" 2 | from predicators import utils 3 | from predicators.approaches.llm_syntax_renaming_approach import \ 4 | ORIGINAL_CHARS, REPLACEMENT_CHARS, LLMSyntaxRenamingApproach 5 | from predicators.envs import create_new_env 6 | from predicators.ground_truth_models import get_gt_options 7 | 8 | 9 | def test_llm_syntax_renaming_approach(): 10 | """Tests for LLMSyntaxRenamingApproach().""" 11 | env_name = "pddl_easy_delivery_procedural_tasks" 12 | utils.reset_config({ 13 | "env": env_name, 14 | "approach": "llm_syntax_renaming", 15 | "num_train_tasks": 1, 16 | "num_test_tasks": 1, 17 | "strips_learner": "oracle", 18 | }) 19 | env = create_new_env(env_name) 20 | train_tasks = [t.task for t in env.get_train_tasks()] 21 | approach = LLMSyntaxRenamingApproach(env.predicates, 22 | get_gt_options(env.get_name()), 23 | env.types, env.action_space, 24 | train_tasks) 25 | assert approach.get_name() == "llm_syntax_renaming" 26 | assert approach._renaming_prefixes == [""] # pylint: disable=protected-access 27 | assert approach._renaming_suffixes == [""] # pylint: disable=protected-access 28 | subs = approach._orig_to_replace # pylint: disable=protected-access 29 | assert set(subs) == set(ORIGINAL_CHARS) 30 | assert all(v in REPLACEMENT_CHARS for v in subs.values()) 31 | assert len(set(subs.values())) == len(subs) 32 | assert all(len(k) == len(v) for k, v in subs.items()) 33 | -------------------------------------------------------------------------------- /tests/approaches/test_random_actions_approach.py: -------------------------------------------------------------------------------- 1 | """Test cases for the random actions approach class.""" 2 | from predicators import utils 3 | from predicators.approaches.random_actions_approach import \ 4 | RandomActionsApproach 5 | from predicators.envs.cover import CoverEnv 6 | from predicators.ground_truth_models import get_gt_options 7 | 8 | 9 | def test_random_actions_approach(): 10 | """Tests for RandomActionsApproach class.""" 11 | utils.reset_config({ 12 | "env": "cover", 13 | "approach": "random_actions", 14 | }) 15 | env = CoverEnv() 16 | train_tasks = [t.task for t in env.get_train_tasks()] 17 | task = train_tasks[0] 18 | approach = RandomActionsApproach(env.predicates, 19 | get_gt_options(env.get_name()), env.types, 20 | env.action_space, train_tasks) 21 | assert not approach.is_learning_based 22 | policy = approach.solve(task, 500) 23 | actions = [] 24 | for _ in range(10): 25 | act = policy(task.init) 26 | actions.append(act) 27 | assert env.action_space.contains(act.arr) 28 | # Test reproducibility 29 | assert str(actions) == "[Action(_arr=array([0.6823519], dtype=float32), extra_info=None), Action(_arr=array([0.05382102], dtype=float32), extra_info=None), Action(_arr=array([0.22035988], dtype=float32), extra_info=None), Action(_arr=array([0.18437181], dtype=float32), extra_info=None), Action(_arr=array([0.1759059], dtype=float32), extra_info=None), Action(_arr=array([0.8120945], dtype=float32), extra_info=None), Action(_arr=array([0.92334497], dtype=float32), extra_info=None), Action(_arr=array([0.2765744], dtype=float32), extra_info=None), Action(_arr=array([0.81975454], dtype=float32), extra_info=None), Action(_arr=array([0.8898927], dtype=float32), extra_info=None)]" # pylint: disable=line-too-long 30 | -------------------------------------------------------------------------------- /tests/bridge_policies/test_base_bridge_policy.py: -------------------------------------------------------------------------------- 1 | """Test cases for the base bridge policy class.""" 2 | 3 | import pytest 4 | 5 | from predicators import utils 6 | from predicators.bridge_policies import BaseBridgePolicy, create_bridge_policy 7 | from predicators.envs import get_or_create_env 8 | from predicators.ground_truth_models import get_gt_nsrts, get_gt_options 9 | 10 | 11 | def test_bridge_policy_creation(): 12 | """Tests for create_bridge_policy().""" 13 | utils.reset_config({"env": "painting"}) 14 | env = get_or_create_env("painting") 15 | options = get_gt_options("painting") 16 | nsrts = get_gt_nsrts("painting", env.predicates, options) 17 | bridge_policy = create_bridge_policy("oracle", env.types, env.predicates, 18 | options, nsrts) 19 | assert isinstance(bridge_policy, BaseBridgePolicy) 20 | assert bridge_policy.get_name() == "oracle" 21 | with pytest.raises(NotImplementedError): 22 | create_bridge_policy("not a real bridge policy", env.types, 23 | env.predicates, options, nsrts) 24 | -------------------------------------------------------------------------------- /tests/conftest.py: -------------------------------------------------------------------------------- 1 | """Shared configurations for pytest. 2 | 3 | See https://docs.pytest.org/en/6.2.x/fixture.html. 4 | """ 5 | 6 | 7 | def pytest_addoption(parser): 8 | """Enable a command line flag for running tests decorated with @longrun.""" 9 | parser.addoption('--longrun', 10 | action='store_true', 11 | dest="longrun", 12 | default=False, 13 | help="enable tests decorated with @longrun") 14 | -------------------------------------------------------------------------------- /tests/datasets/mock_vlm_datasets/cover__demo+labelled_atoms__manual__1.txt: -------------------------------------------------------------------------------- 1 | === 2 | {*IsRobot(robby): True 3 | } -> 4 | 5 | PickPlace()[0.6926419734954834] -> 6 | 7 | {*IsRobot(robby): True 8 | } -> 9 | 10 | PickPlace()[0.6926419734954834] -> 11 | 12 | {*IsRobot(robby): True 13 | } 14 | === 15 | -------------------------------------------------------------------------------- /tests/datasets/mock_vlm_datasets/cover__vlm_demos__456__1/traj_0/0/img.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Learning-and-Intelligent-Systems/predicators/5bd3f5bd21cc01e171faf748edf53bcfd720f4d1/tests/datasets/mock_vlm_datasets/cover__vlm_demos__456__1/traj_0/0/img.jpg -------------------------------------------------------------------------------- /tests/datasets/mock_vlm_datasets/cover__vlm_demos__456__1/traj_0/0/state.p: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Learning-and-Intelligent-Systems/predicators/5bd3f5bd21cc01e171faf748edf53bcfd720f4d1/tests/datasets/mock_vlm_datasets/cover__vlm_demos__456__1/traj_0/0/state.p -------------------------------------------------------------------------------- /tests/datasets/mock_vlm_datasets/cover__vlm_demos__456__1/traj_0/1/img.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Learning-and-Intelligent-Systems/predicators/5bd3f5bd21cc01e171faf748edf53bcfd720f4d1/tests/datasets/mock_vlm_datasets/cover__vlm_demos__456__1/traj_0/1/img.jpg -------------------------------------------------------------------------------- /tests/datasets/mock_vlm_datasets/cover__vlm_demos__456__1/traj_0/1/state.p: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Learning-and-Intelligent-Systems/predicators/5bd3f5bd21cc01e171faf748edf53bcfd720f4d1/tests/datasets/mock_vlm_datasets/cover__vlm_demos__456__1/traj_0/1/state.p -------------------------------------------------------------------------------- /tests/datasets/mock_vlm_datasets/cover__vlm_demos__456__1/traj_0/2/img.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Learning-and-Intelligent-Systems/predicators/5bd3f5bd21cc01e171faf748edf53bcfd720f4d1/tests/datasets/mock_vlm_datasets/cover__vlm_demos__456__1/traj_0/2/img.jpg -------------------------------------------------------------------------------- /tests/datasets/mock_vlm_datasets/cover__vlm_demos__456__1/traj_0/2/state.p: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Learning-and-Intelligent-Systems/predicators/5bd3f5bd21cc01e171faf748edf53bcfd720f4d1/tests/datasets/mock_vlm_datasets/cover__vlm_demos__456__1/traj_0/2/state.p -------------------------------------------------------------------------------- /tests/datasets/mock_vlm_datasets/cover__vlm_demos__456__1/traj_0/options_traj.txt: -------------------------------------------------------------------------------- 1 | PickPlace()[0.6926419734954834] 2 | PickPlace()[0.6926419734954834] 3 | -------------------------------------------------------------------------------- /tests/datasets/mock_vlm_datasets/ice_tea_making__demo+labelled_atoms__manual__1.txt: -------------------------------------------------------------------------------- 1 | === 2 | {hand_grasping_spoon(hand, spoon): True. 3 | hand_grasping_teabag(hand, teabag): True. 4 | spoon_in_cup(spoon, cup): True. 5 | spoon_on_plate(spoon, plate): True. 6 | teabag_in_cup(teabag, cup): True. 7 | teabag_on_plate(teabag, plate): True.} -> 8 | 9 | pick(teabag, hand)[] -> 10 | 11 | {hand_grasping_spoon(hand, spoon): True. 12 | hand_grasping_teabag(hand, teabag): True. 13 | spoon_in_cup(spoon, cup): True. 14 | spoon_on_plate(spoon, plate): True. 15 | teabag_in_cup(teabag, cup): True. 16 | teabag_on_plate(teabag, plate): True.} -> 17 | 18 | place_in(teabag, cup)[] -> 19 | 20 | {hand_grasping_spoon(hand, spoon): True. 21 | hand_grasping_teabag(hand, teabag): True. 22 | spoon_in_cup(spoon, cup): True. 23 | spoon_on_plate(spoon, plate): True. 24 | teabag_in_cup(teabag, cup): True. 25 | teabag_on_plate(teabag, plate): True.} -> 26 | 27 | pick(spoon, hand)[] -> 28 | 29 | {hand_grasping_spoon(hand, spoon): True. 30 | hand_grasping_teabag(hand, teabag): True. 31 | spoon_in_cup(spoon, cup): True. 32 | spoon_on_plate(spoon, plate): True. 33 | teabag_in_cup(teabag, cup): True. 34 | teabag_on_plate(teabag, plate): True.} -> 35 | 36 | place_in(spoon, cup)[] -> 37 | 38 | {hand_grasping_spoon(hand, spoon): True. 39 | hand_grasping_teabag(hand, teabag): True. 40 | spoon_in_cup(spoon, cup): True. 41 | spoon_on_plate(spoon, plate): True. 42 | teabag_in_cup(teabag, cup): True. 43 | teabag_on_plate(teabag, plate): True.} 44 | === 45 | -------------------------------------------------------------------------------- /tests/datasets/mock_vlm_datasets/ice_tea_making__vlm_demos__456__1/traj_0/0/IMG_3779.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Learning-and-Intelligent-Systems/predicators/5bd3f5bd21cc01e171faf748edf53bcfd720f4d1/tests/datasets/mock_vlm_datasets/ice_tea_making__vlm_demos__456__1/traj_0/0/IMG_3779.jpg -------------------------------------------------------------------------------- /tests/datasets/mock_vlm_datasets/ice_tea_making__vlm_demos__456__1/traj_0/1/IMG_3780.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Learning-and-Intelligent-Systems/predicators/5bd3f5bd21cc01e171faf748edf53bcfd720f4d1/tests/datasets/mock_vlm_datasets/ice_tea_making__vlm_demos__456__1/traj_0/1/IMG_3780.jpg -------------------------------------------------------------------------------- /tests/datasets/mock_vlm_datasets/ice_tea_making__vlm_demos__456__1/traj_0/2/IMG_3781.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Learning-and-Intelligent-Systems/predicators/5bd3f5bd21cc01e171faf748edf53bcfd720f4d1/tests/datasets/mock_vlm_datasets/ice_tea_making__vlm_demos__456__1/traj_0/2/IMG_3781.jpg -------------------------------------------------------------------------------- /tests/datasets/mock_vlm_datasets/ice_tea_making__vlm_demos__456__1/traj_0/3/IMG_3782.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Learning-and-Intelligent-Systems/predicators/5bd3f5bd21cc01e171faf748edf53bcfd720f4d1/tests/datasets/mock_vlm_datasets/ice_tea_making__vlm_demos__456__1/traj_0/3/IMG_3782.jpg -------------------------------------------------------------------------------- /tests/datasets/mock_vlm_datasets/ice_tea_making__vlm_demos__456__1/traj_0/4/IMG_3783.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Learning-and-Intelligent-Systems/predicators/5bd3f5bd21cc01e171faf748edf53bcfd720f4d1/tests/datasets/mock_vlm_datasets/ice_tea_making__vlm_demos__456__1/traj_0/4/IMG_3783.jpg -------------------------------------------------------------------------------- /tests/datasets/mock_vlm_datasets/ice_tea_making__vlm_demos__456__1/traj_0/options_traj.txt: -------------------------------------------------------------------------------- 1 | pick(teabag, hand, []) 2 | place_in(teabag, cup, []) 3 | pick(spoon, hand, []) 4 | place_in(spoon, cup, []) 5 | -------------------------------------------------------------------------------- /tests/datasets/test_vlm_predicate_img.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Learning-and-Intelligent-Systems/predicators/5bd3f5bd21cc01e171faf748edf53bcfd720f4d1/tests/datasets/test_vlm_predicate_img.jpg -------------------------------------------------------------------------------- /tests/envs/test_vlm_envs.py: -------------------------------------------------------------------------------- 1 | """Tests for VLM predicate invention environments.""" 2 | 3 | import numpy as np 4 | import pytest 5 | 6 | from predicators import utils 7 | from predicators.envs.vlm_envs import IceTeaMakingEnv 8 | from predicators.structs import Action, DefaultState, Object, State 9 | 10 | 11 | def test_ice_tea_making(): 12 | """Tests for the Iced Tea Making environment.""" 13 | utils.reset_config({"num_train_tasks": 5, "num_test_tasks": 5}) 14 | env = IceTeaMakingEnv() 15 | assert env.get_name() == "ice_tea_making" 16 | assert len(env.types) == 7 17 | assert len(env.predicates) == 1 18 | assert len(env.goal_predicates) == 1 19 | assert len(env.get_train_tasks()) == 5 20 | assert len(env.get_test_tasks()) == 5 21 | assert env.action_space.shape == (0, ) 22 | with pytest.raises(ValueError): 23 | env.simulate(DefaultState, Action(np.zeros(0))) 24 | with pytest.raises(ValueError): 25 | env.render_state_plt(DefaultState, None, Action(np.zeros(0))) 26 | t_list = sorted(list(env.types)) 27 | goal_type_list = [t for t in t_list if t.name == 'goal_object'] 28 | goal_type = goal_type_list[0] 29 | goal_obj = Object("goal", goal_type) 30 | init_state = State({goal_obj: np.array([0.0])}) 31 | goal_preds_list = list(env.goal_predicates) 32 | goal_pred = goal_preds_list[0] 33 | assert not goal_pred.holds(init_state, [goal_obj]) 34 | -------------------------------------------------------------------------------- /tests/execution_monitoring/test_execution_monitoring.py: -------------------------------------------------------------------------------- 1 | """Tests for execution monitors.""" 2 | 3 | import pytest 4 | 5 | from predicators.execution_monitoring import create_execution_monitor 6 | from predicators.execution_monitoring.expected_atoms_monitor import \ 7 | ExpectedAtomsExecutionMonitor 8 | from predicators.execution_monitoring.mpc_execution_monitor import \ 9 | MpcExecutionMonitor 10 | from predicators.execution_monitoring.trivial_execution_monitor import \ 11 | TrivialExecutionMonitor 12 | 13 | 14 | def test_create_execution_monitor(): 15 | """Tests for create_execution_monitor().""" 16 | exec_monitor = create_execution_monitor("trivial") 17 | assert isinstance(exec_monitor, TrivialExecutionMonitor) 18 | 19 | exec_monitor = create_execution_monitor("mpc") 20 | assert isinstance(exec_monitor, MpcExecutionMonitor) 21 | 22 | exec_monitor = create_execution_monitor("expected_atoms") 23 | assert isinstance(exec_monitor, ExpectedAtomsExecutionMonitor) 24 | 25 | with pytest.raises(NotImplementedError) as e: 26 | create_execution_monitor("not a real monitor") 27 | assert "Unrecognized execution monitor" in str(e) 28 | -------------------------------------------------------------------------------- /tests/explorers/test_no_explore_explorer.py: -------------------------------------------------------------------------------- 1 | """Test cases for the no explore explorer class.""" 2 | import pytest 3 | 4 | from predicators import utils 5 | from predicators.envs.cover import CoverEnv 6 | from predicators.explorers import create_explorer 7 | from predicators.ground_truth_models import get_gt_options 8 | 9 | 10 | def test_no_explore_explorer(): 11 | """Tests for NoExploreExplorer class.""" 12 | utils.reset_config({ 13 | "env": "cover", 14 | "explorer": "no_explore", 15 | }) 16 | env = CoverEnv() 17 | train_tasks = [t.task for t in env.get_train_tasks()] 18 | task_idx = 0 19 | task = train_tasks[task_idx] 20 | explorer = create_explorer("no_explore", env.predicates, 21 | get_gt_options(env.get_name()), env.types, 22 | env.action_space, train_tasks) 23 | policy, termination_function = explorer.get_exploration_strategy( 24 | task_idx, 500) 25 | assert termination_function(task.init) 26 | with pytest.raises(RuntimeError) as e: 27 | policy(task.init) 28 | assert "The policy for no-explore shouldn't be used." in str(e) 29 | -------------------------------------------------------------------------------- /tests/explorers/test_random_actions_explorer.py: -------------------------------------------------------------------------------- 1 | """Test cases for the random actions explorer class.""" 2 | from predicators import utils 3 | from predicators.envs.cover import CoverEnv 4 | from predicators.explorers import create_explorer 5 | from predicators.ground_truth_models import get_gt_options 6 | 7 | 8 | def test_random_actions_explorer(): 9 | """Tests for RandomActionsExplorer class.""" 10 | utils.reset_config({ 11 | "env": "cover", 12 | "explorer": "random_actions", 13 | }) 14 | env = CoverEnv() 15 | train_tasks = [t.task for t in env.get_train_tasks()] 16 | task_idx = 0 17 | task = train_tasks[task_idx] 18 | explorer = create_explorer("random_actions", env.predicates, 19 | get_gt_options(env.get_name()), env.types, 20 | env.action_space, train_tasks) 21 | policy, termination_function = explorer.get_exploration_strategy( 22 | task_idx, 500) 23 | assert not termination_function(task.init) 24 | for _ in range(10): 25 | act = policy(task.init) 26 | assert env.action_space.contains(act.arr) 27 | -------------------------------------------------------------------------------- /tests/explorers/test_random_nsrts_explorer.py: -------------------------------------------------------------------------------- 1 | """Test cases for the random nsrts explorer class.""" 2 | import pytest 3 | 4 | from predicators import utils 5 | from predicators.envs.touch_point import TouchOpenEnv 6 | from predicators.explorers import create_explorer 7 | from predicators.ground_truth_models import get_gt_nsrts, get_gt_options 8 | 9 | 10 | def test_random_nsrts_explorer(): 11 | """Tests for RandomNSRTsExplorer class.""" 12 | utils.reset_config({ 13 | "env": "touch_open", 14 | "explorer": "random_nsrts", 15 | }) 16 | env = TouchOpenEnv() 17 | train_tasks = [t.task for t in env.get_train_tasks()] 18 | task_idx = 0 19 | task = train_tasks[task_idx] 20 | options = get_gt_options(env.get_name()) 21 | nsrts = get_gt_nsrts(env.get_name(), env.predicates, options) 22 | explorer = create_explorer("random_nsrts", env.predicates, options, 23 | env.types, env.action_space, train_tasks, nsrts) 24 | policy, termination_function = explorer.get_exploration_strategy( 25 | task_idx, 500) 26 | 27 | # Test the general use of the policy and termination function. 28 | assert not termination_function(task.init) 29 | state = task.init 30 | for _ in range(5): 31 | act = policy(state) 32 | state = env.simulate(state, act) 33 | assert env.action_space.contains(act.arr) 34 | 35 | # Test case where no applicable nsrt can be found. 36 | insufficient_nsrts = {sorted(nsrts)[1]} # OpenDoor 37 | explorer = create_explorer("random_nsrts", env.predicates, options, 38 | env.types, env.action_space, train_tasks, 39 | insufficient_nsrts) 40 | policy, _ = explorer.get_exploration_strategy(task_idx, 500) 41 | with pytest.raises(utils.RequestActPolicyFailure) as e: 42 | policy(task.init) 43 | assert "No applicable NSRT in this state!" in str(e) 44 | -------------------------------------------------------------------------------- /tests/explorers/test_random_options_explorer.py: -------------------------------------------------------------------------------- 1 | """Test cases for the random options explorer class.""" 2 | import pytest 3 | 4 | from predicators import utils 5 | from predicators.envs.cover import CoverEnv 6 | from predicators.explorers import create_explorer 7 | from predicators.ground_truth_models import get_gt_options 8 | from predicators.structs import ParameterizedOption 9 | 10 | 11 | def test_random_options_explorer(): 12 | """Tests for RandomOptionsExplorer class.""" 13 | utils.reset_config({ 14 | "env": "cover", 15 | "explorer": "random_options", 16 | }) 17 | env = CoverEnv() 18 | train_tasks = [t.task for t in env.get_train_tasks()] 19 | task_idx = 0 20 | task = train_tasks[task_idx] 21 | explorer = create_explorer("random_options", env.predicates, 22 | get_gt_options(env.get_name()), env.types, 23 | env.action_space, train_tasks) 24 | policy, termination_function = explorer.get_exploration_strategy( 25 | task_idx, 500) 26 | assert not termination_function(task.init) 27 | for _ in range(10): 28 | act = policy(task.init) 29 | assert env.action_space.contains(act.arr) 30 | # Test case where no applicable option can be found. 31 | opt = sorted(get_gt_options(env.get_name()))[0] 32 | dummy_opt = ParameterizedOption(opt.name, opt.types, opt.params_space, 33 | opt.policy, lambda _1, _2, _3, _4: False, 34 | opt.terminal) 35 | explorer = create_explorer("random_options", env.predicates, {dummy_opt}, 36 | env.types, env.action_space, train_tasks) 37 | policy, _ = explorer.get_exploration_strategy(task_idx, 500) 38 | with pytest.raises(utils.RequestActPolicyFailure) as e: 39 | policy(task.init) 40 | assert "Random option sampling failed!" in str(e) 41 | -------------------------------------------------------------------------------- /tests/perception/test_perception.py: -------------------------------------------------------------------------------- 1 | """Tests for perceivers.""" 2 | 3 | import pytest 4 | 5 | from predicators.perception import create_perceiver 6 | from predicators.perception.trivial_perceiver import TrivialPerceiver 7 | 8 | 9 | def test_create_perceiver(): 10 | """Tests for create_perceiver().""" 11 | perceiver = create_perceiver("trivial") 12 | assert isinstance(perceiver, TrivialPerceiver) 13 | 14 | with pytest.raises(NotImplementedError) as e: 15 | create_perceiver("not a real perceiver") 16 | assert "Unrecognized perceiver" in str(e) 17 | -------------------------------------------------------------------------------- /tests/pybullet_helpers/conftest.py: -------------------------------------------------------------------------------- 1 | """Common fixtures for the pybullet_helpers tests.""" 2 | 3 | import pybullet as p 4 | import pytest 5 | 6 | 7 | @pytest.fixture(scope="function", name="physics_client_id") 8 | def _connect_to_pybullet(): 9 | """Direct connect to PyBullet physics server, and disconnect when we're 10 | done. 11 | 12 | This fixture automatically disconnects the physics server, so we 13 | don't forget to do it ourselves. 14 | """ 15 | physics_client_id = p.connect(p.DIRECT) 16 | yield physics_client_id 17 | p.disconnect(physics_client_id) 18 | -------------------------------------------------------------------------------- /tests/pybullet_helpers/test_geometry.py: -------------------------------------------------------------------------------- 1 | """Tests for geometry PyBullet helper utilities.""" 2 | 3 | import numpy as np 4 | import pybullet as p 5 | 6 | from predicators.pybullet_helpers.geometry import Pose, get_pose, \ 7 | matrix_from_quat 8 | 9 | 10 | def test_pose(): 11 | """Tests for Pose().""" 12 | position = (5.0, 0.5, 1.0) 13 | orientation = (0.0, 0.0, 0.0, 1.0) 14 | pose = Pose(position, orientation) 15 | rpy = pose.rpy 16 | reconstructed_pose = Pose.from_rpy(position, rpy) 17 | assert pose.allclose(reconstructed_pose) 18 | unit_pose = Pose.identity() 19 | assert not pose.allclose(unit_pose) 20 | multiplied_pose = pose.multiply(unit_pose, unit_pose, unit_pose) 21 | assert pose.allclose(multiplied_pose) 22 | inverted_pose = pose.invert() 23 | assert not pose.allclose(inverted_pose) 24 | assert pose.allclose(inverted_pose.invert()) 25 | 26 | 27 | def test_matrix_from_quat(): 28 | """Tests for matrix_from_quat().""" 29 | mat = matrix_from_quat((0.0, 0.0, 0.0, 1.0)) 30 | assert np.allclose(mat, np.eye(3)) 31 | mat = matrix_from_quat((0.0, 0.0, 0.0, -1.0)) 32 | assert np.allclose(mat, np.eye(3)) 33 | mat = matrix_from_quat((1.0, 0.0, 0.0, 1.0)) 34 | expected_mat = np.array([ 35 | [1.0, 0.0, 0.0], 36 | [0.0, 0.0, -1.0], 37 | [0.0, 1.0, 0.0], 38 | ]) 39 | assert np.allclose(mat, expected_mat) 40 | 41 | 42 | def test_get_pose(physics_client_id): 43 | """Tests for get_pose().""" 44 | collision_id = p.createCollisionShape(p.GEOM_BOX, 45 | halfExtents=[1, 1, 1], 46 | physicsClientId=physics_client_id) 47 | mass = 0 48 | position = (1.0, 0.0, 3.0) 49 | orientation = (0.0, 1.0, 0.0, 0.0) 50 | expected_pose = Pose(position, orientation) 51 | body = p.createMultiBody(mass, 52 | collision_id, 53 | basePosition=position, 54 | baseOrientation=orientation, 55 | physicsClientId=physics_client_id) 56 | pose = get_pose(body, physics_client_id) 57 | assert pose.allclose(expected_pose) 58 | -------------------------------------------------------------------------------- /tests/refinement_estimators/test_base_refinement_estimator.py: -------------------------------------------------------------------------------- 1 | """Test cases for the base refinement estimator class.""" 2 | 3 | import os 4 | import shutil 5 | from pathlib import Path 6 | 7 | import pytest 8 | 9 | from predicators import utils 10 | from predicators.refinement_estimators import BaseRefinementEstimator, \ 11 | create_refinement_estimator 12 | 13 | # We don't run these tests for gnn because training on an empty dataset is 14 | # not possible 15 | ESTIMATOR_NAMES = ["oracle", "tabular", "cnn"] 16 | 17 | 18 | def test_refinement_estimator_creation(): 19 | """Tests for create_refinement_estimator().""" 20 | utils.reset_config({"env": "narrow_passage"}) 21 | # Create fake directory to test saving and loading model 22 | parent_dir = os.path.dirname(__file__) 23 | approach_dir = os.path.join(parent_dir, "_fake_approach") 24 | os.makedirs(approach_dir, exist_ok=True) 25 | test_approach_path = Path(approach_dir) / "test.estimator" 26 | for est_name in ESTIMATOR_NAMES: 27 | estimator = create_refinement_estimator(est_name) 28 | assert isinstance(estimator, BaseRefinementEstimator) 29 | assert estimator.get_name() == est_name 30 | estimator.train([]) 31 | estimator.save_model(test_approach_path) 32 | estimator.load_model(test_approach_path) 33 | shutil.rmtree(approach_dir) 34 | with pytest.raises(NotImplementedError): 35 | create_refinement_estimator("non-existent refinement estimator") 36 | -------------------------------------------------------------------------------- /tests/test_args.py: -------------------------------------------------------------------------------- 1 | """Tests for args.py.""" 2 | 3 | import sys 4 | 5 | from predicators import utils 6 | 7 | 8 | def test_args(): 9 | """Tests for args.py.""" 10 | sys.argv = [ 11 | "dummy", "--env", "my_env", "--approach", "my_approach", "--seed", 12 | "123" 13 | ] 14 | args = utils.parse_args() 15 | assert args["env"] == "my_env" 16 | assert args["approach"] == "my_approach" 17 | assert args["seed"] == 123 18 | -------------------------------------------------------------------------------- /tests/test_ground_truth_options.py: -------------------------------------------------------------------------------- 1 | """Tests for ground_truth_models.py.""" 2 | import pytest 3 | 4 | from predicators import utils 5 | from predicators.envs.cover import CoverMultistepOptions 6 | from predicators.ground_truth_models import get_gt_options, \ 7 | parse_config_included_options 8 | 9 | 10 | def test_parse_config_included_options(): 11 | """Tests for parse_config_included_options().""" 12 | # Test including nothing. 13 | utils.reset_config({ 14 | "env": "cover_multistep_options", 15 | "included_options": "", 16 | }) 17 | env = CoverMultistepOptions() 18 | included = parse_config_included_options(env) 19 | assert not included 20 | # Test including specific options. 21 | utils.reset_config({ 22 | "included_options": "Pick", 23 | }) 24 | Pick, Place = sorted(get_gt_options(env.get_name())) 25 | assert Pick.name == "Pick" 26 | assert Place.name == "Place" 27 | included = parse_config_included_options(env) 28 | assert included == {Pick} 29 | utils.reset_config({ 30 | "included_options": "Place", 31 | }) 32 | included = parse_config_included_options(env) 33 | assert included == {Place} 34 | utils.reset_config({ 35 | "included_options": "Pick,Place", 36 | }) 37 | included = parse_config_included_options(env) 38 | assert included == {Pick, Place} 39 | # Test including an unknown option. 40 | utils.reset_config({ 41 | "included_options": "Pick,NotReal", 42 | }) 43 | with pytest.raises(AssertionError) as e: 44 | parse_config_included_options(env) 45 | assert "Unrecognized option in included_options!" in str(e) 46 | -------------------------------------------------------------------------------- /tests/test_settings.py: -------------------------------------------------------------------------------- 1 | """Test cases for some parts of the settings.py file.""" 2 | 3 | from predicators import utils 4 | from predicators.settings import get_allowed_query_type_names 5 | 6 | 7 | def test_get_allowed_query_type_names(): 8 | """Test the get_allowed_query_type_names method.""" 9 | utils.reset_config() 10 | assert get_allowed_query_type_names() == set() 11 | utils.reset_config({ 12 | "option_learner": "direct_bc", 13 | }) 14 | assert get_allowed_query_type_names() == {"PathToStateQuery"} 15 | utils.reset_config({ 16 | "option_learner": "no_learning", 17 | "approach": "interactive_learning" 18 | }) 19 | assert get_allowed_query_type_names() == {"GroundAtomsHoldQuery"} 20 | utils.reset_config({ 21 | "option_learner": "no_learning", 22 | "approach": "unittest" 23 | }) 24 | assert get_allowed_query_type_names() == { 25 | "GroundAtomsHoldQuery", "DemonstrationQuery", "PathToStateQuery", 26 | "_MockQuery" 27 | } 28 | --------------------------------------------------------------------------------