├── .gitignore ├── LICENSE ├── README.md ├── _assets └── overview.png ├── bin ├── cdl-highlight ├── cdl-latex-format ├── cdl-lexer ├── cdl-plan ├── cdl-summary ├── concepts-update-assets ├── obj2urdf ├── pds-highlight └── pds-summary ├── concepts ├── .gitignore ├── .vim-template:.cc ├── .vim-template:.h ├── .vim-template:.py ├── __init__.py ├── algorithm │ ├── __init__.py │ ├── configuration_space.py │ ├── rrt │ │ ├── __init__.py │ │ └── rrt.py │ └── search │ │ ├── __init__.py │ │ └── heuristic_search.py ├── assets │ ├── .gitignore │ ├── sync-down.sh │ └── sync-up.sh ├── benchmark │ ├── __init__.py │ ├── algorithm_env │ │ ├── __init__.py │ │ ├── graph.py │ │ ├── graph_env.py │ │ ├── quickaccess.py │ │ └── sort_envs.py │ ├── blocksworld │ │ ├── __init__.py │ │ ├── blocksworld.py │ │ └── blocksworld_env.py │ ├── clevr │ │ ├── __init__.py │ │ ├── clevr_constants.py │ │ ├── dataset.py │ │ └── scene_generator │ │ │ ├── assets │ │ │ ├── base_scene.blend │ │ │ ├── materials │ │ │ │ ├── MyMetal.blend │ │ │ │ └── Rubber.blend │ │ │ ├── properties.json │ │ │ └── shapes │ │ │ │ ├── Cone.blend │ │ │ │ ├── SmoothCube_v2.blend │ │ │ │ ├── SmoothCylinder.blend │ │ │ │ └── Sphere.blend │ │ │ ├── clevr_blender_utils.py │ │ │ └── render.py │ ├── common │ │ ├── __init__.py │ │ ├── random_env.py │ │ └── vocab.py │ ├── continuous_1d │ │ ├── __init__.py │ │ └── continuous_1d_tk_visualizer.py │ ├── gridworld │ │ ├── __init__.py │ │ ├── crafting_world │ │ │ ├── __init__.py │ │ │ ├── assets │ │ │ │ ├── BlockCSS.png │ │ │ │ ├── EntityCSS.png │ │ │ │ ├── ItemCSS.png │ │ │ │ ├── Jungle_Tree.png │ │ │ │ └── Plains_Villager_Base.png │ │ │ ├── crafting_world_crow_gen │ │ │ │ ├── __init__.py │ │ │ │ └── cw_20230913_mixed.py │ │ │ ├── crafting_world_env.py │ │ │ ├── crafting_world_gen │ │ │ │ ├── __init__.py │ │ │ │ ├── cw_20230204_minining_only.py │ │ │ │ ├── cw_20230829_crafting_only.py │ │ │ │ ├── cw_20230913_mixed.py │ │ │ │ └── utils.py │ │ │ ├── crafting_world_pds_gen │ │ │ │ ├── __init__.py │ │ │ │ ├── cw_20230204_minining_only.py │ │ │ │ ├── cw_20230829_crafting_only.py │ │ │ │ └── cw_20230913_mixed.py │ │ │ ├── crafting_world_rules.py │ │ │ ├── crafting_world_teleport │ │ │ │ ├── __init__.py │ │ │ │ ├── domain-station-agnostic.pddl │ │ │ │ ├── domain.pddl │ │ │ │ ├── domain.pddl-template │ │ │ │ └── domain_gen.py │ │ │ ├── crow_domains │ │ │ │ ├── __init__.py │ │ │ │ ├── cdl_gen.py │ │ │ │ ├── crafting_world.cdl-template │ │ │ │ └── crafting_world_station_agnostic.cdl │ │ │ ├── pds_domains │ │ │ │ ├── __init__.py │ │ │ │ ├── crafting_world_pdsinterface.py │ │ │ │ ├── domain-station-agnostic.pddl │ │ │ │ ├── domain.pddl │ │ │ │ ├── domain.pddl-template │ │ │ │ └── domain_gen.py │ │ │ └── utils.py │ │ └── minigrid │ │ │ ├── __init__.py │ │ │ ├── gym_minigrid │ │ │ ├── __init__.py │ │ │ ├── minigrid.py │ │ │ ├── path_finding.py │ │ │ ├── rendering.py │ │ │ └── window.py │ │ │ ├── minigrid_v20220407.py │ │ │ └── pds_domains │ │ │ ├── __init__.py │ │ │ ├── minigrid-domain-v20220407-abskin.pdsketch │ │ │ ├── minigrid-domain-v20220407-basic.pdsketch │ │ │ ├── minigrid-domain-v20220407-full.pdsketch │ │ │ └── minigrid-domain-v20220407-robokin.pdsketch │ ├── logic_induction │ │ ├── __init__.py │ │ ├── boolean_normal_form.py │ │ ├── boolean_normal_form_dataset.py │ │ ├── family.py │ │ └── graph_dataset.py │ ├── manip_tabletop │ │ ├── __init__.py │ │ ├── bimanual_abc │ │ │ ├── __init__.py │ │ │ ├── bimanual_abc_env_base.py │ │ │ └── envs │ │ │ │ ├── __init__.py │ │ │ │ ├── bimanual_abc_lift.py │ │ │ │ └── bimanual_abc_pivot.py │ │ ├── paint_factory │ │ │ ├── __init__.py │ │ │ ├── crow_domains │ │ │ │ ├── __init__.py │ │ │ │ ├── paint-factory-v20231225.cdl │ │ │ │ └── paint_factory_crow_interface.py │ │ │ ├── paint-factory-domain-v20231225.pdsketch │ │ │ ├── paint_factory.py │ │ │ ├── paint_factory_policy.py │ │ │ └── pds_domains │ │ │ │ ├── __init__.py │ │ │ │ ├── paint-factory-domain-v20231225.pdsketch │ │ │ │ └── paint_factory_pdsinterface.py │ │ ├── pick_place_hierarchy │ │ │ ├── __init__.py │ │ │ ├── pick_place_hierarchy.py │ │ │ └── qddl_files │ │ │ │ ├── h0-simple.qddl │ │ │ │ ├── h1-pick-blocker.qddl │ │ │ │ ├── h1-pick-regrasp.qddl │ │ │ │ ├── h1-place-blocker.qddl │ │ │ │ ├── h2-pick-place-blocker.qddl │ │ │ │ └── pick-place-hierarchy-domain.qddl │ │ ├── pybullet_tabletop.py │ │ ├── pybullet_tabletop_base.pdsketch │ │ └── pybullet_tabletop_base │ │ │ ├── __init__.py │ │ │ ├── pds_domains │ │ │ ├── __init__.py │ │ │ ├── pybullet_tabletop_base.pdsketch │ │ │ └── pybullet_tabletop_pdsinterface.py │ │ │ └── pybullet_tabletop.py │ ├── namo │ │ ├── __init__.py │ │ └── namo_polygon │ │ │ ├── __init__.py │ │ │ ├── namo_polygon_env.py │ │ │ ├── namo_polygon_map_creator.py │ │ │ └── namo_polygon_primitives.py │ ├── nethack │ │ ├── __init__.py │ │ ├── language_utils.py │ │ └── screen_symbol_consts.py │ └── vision_language │ │ ├── __init__.py │ │ ├── babel_qa │ │ ├── __init__.py │ │ ├── dataset.py │ │ ├── humanmotion_constants.py │ │ └── utils.py │ │ ├── shapes │ │ ├── .gitignore │ │ ├── __init__.py │ │ ├── dataset.py │ │ ├── program_utils.py │ │ └── shapes_detection_utils.py │ │ └── shapes3 │ │ ├── __init__.py │ │ ├── dataset.py │ │ └── image_utils.py ├── cc │ ├── dsl │ │ ├── dsl_domain.h │ │ └── dsl_types.h │ └── main.cc ├── dm │ ├── __init__.py │ ├── crow │ │ ├── __init__.py │ │ ├── behavior.py │ │ ├── behavior_utils.py │ │ ├── controller.py │ │ ├── crow_domain.py │ │ ├── crow_expression_utils.py │ │ ├── crow_function.py │ │ ├── crow_generator.py │ │ ├── csp_solver │ │ │ ├── __init__.py │ │ │ ├── csp_utils.py │ │ │ └── dpll_sampling.py │ │ ├── executors │ │ │ ├── __init__.py │ │ │ ├── crow_executor.py │ │ │ ├── generator_executor.py │ │ │ └── python_function.py │ │ ├── interfaces │ │ │ ├── __init__.py │ │ │ ├── controller_interface.py │ │ │ ├── execution_manager.py │ │ │ └── perception_interface.py │ │ ├── parsers │ │ │ ├── __init__.py │ │ │ ├── cdl-keywords1.txt │ │ │ ├── cdl-keywords2.txt │ │ │ ├── cdl.grammar │ │ │ ├── cdl.vim │ │ │ ├── cdl_formatter.py │ │ │ ├── cdl_literal_parser.py │ │ │ ├── cdl_parser.py │ │ │ └── cdl_symbolic_execution.py │ │ └── planners │ │ │ ├── __init__.py │ │ │ ├── priority_impl │ │ │ ├── __init__.py │ │ │ └── priority_tree_priority_fns.py │ │ │ ├── regression_dependency.py │ │ │ ├── regression_planning.py │ │ │ ├── regression_planning_impl │ │ │ ├── __init__.py │ │ │ ├── crow_regression_planner_astar_v1.py │ │ │ ├── crow_regression_planner_bfs_v1.py │ │ │ ├── crow_regression_planner_dfs_v1.py │ │ │ ├── crow_regression_planner_dfs_v1_utils.py │ │ │ ├── crow_regression_planner_dfs_v2.py │ │ │ ├── crow_regression_planner_iddfs_v1.py │ │ │ └── crow_regression_planner_priority_tree_v1.py │ │ │ └── regression_utils.py │ ├── crowhat │ │ ├── __init__.py │ │ ├── domains │ │ │ ├── RWI-pp-simplified.cdl │ │ │ ├── RWI-pp.cdl │ │ │ ├── __init__.py │ │ │ └── pybullet_single_robot_rwi_pp_simplified.py │ │ ├── impl │ │ │ ├── __init__.py │ │ │ ├── franka │ │ │ │ ├── __init__.py │ │ │ │ ├── deoxys_crowhat_interface.py │ │ │ │ ├── fri_crowhat_interface.py │ │ │ │ └── panda_robot_controller.py │ │ │ ├── maniskill3 │ │ │ │ ├── __init__.py │ │ │ │ └── maniskill3_planning_world_interface.py │ │ │ └── pybullet │ │ │ │ ├── __init__.py │ │ │ │ ├── pybullet_manipulator_interface.py │ │ │ │ ├── pybullet_planning_world_interface.py │ │ │ │ └── pybullet_sim_interfaces.py │ │ ├── manipulation_utils │ │ │ ├── __init__.py │ │ │ ├── bimanual_path_generation_utils.py │ │ │ ├── contact_point_sampler.py │ │ │ ├── operation_space_trajectory.py │ │ │ ├── path_generation_utils.py │ │ │ ├── pick_place_sampler.py │ │ │ ├── pivot_sampler.py │ │ │ ├── plannar_push_sampler.py │ │ │ └── pose_utils.py │ │ └── world │ │ │ ├── __init__.py │ │ │ ├── manipulator_interface.py │ │ │ └── planning_world_interface.py │ └── pdsketch │ │ ├── __init__.py │ │ ├── crow │ │ ├── __init__.py │ │ ├── compat │ │ │ ├── __init__.py │ │ │ └── crow_planner_v1.py │ │ ├── crow_planner_execution.py │ │ ├── crow_planner_v2.py │ │ └── crow_state.py │ │ ├── csp_solvers │ │ ├── __init__.py │ │ ├── brute_force_sampling.py │ │ └── dpll_sampling.py │ │ ├── domain.py │ │ ├── execution_utils.py │ │ ├── executor.py │ │ ├── generator.py │ │ ├── nn_learning │ │ ├── __init__.py │ │ └── simple_offline_learning.py │ │ ├── operator.py │ │ ├── parsers │ │ ├── __init__.py │ │ ├── csp_parser.py │ │ ├── pdsketch-v2.grammar │ │ └── pdsketch_parser.py │ │ ├── planners │ │ ├── __init__.py │ │ ├── discrete_search.py │ │ ├── optimistic_search.py │ │ ├── optimistic_search_bilevel_legacy.py │ │ ├── optimistic_search_bilevel_utils.py │ │ ├── optimistic_search_with_simulation.py │ │ └── solution_score_tracker.py │ │ ├── predicate.py │ │ ├── regression_rule.py │ │ ├── regression_utils.py │ │ ├── simulator_interface.py │ │ └── strips │ │ ├── __init__.py │ │ ├── atomic_strips_domain.py │ │ ├── atomic_strips_onthefly_search.py │ │ ├── atomic_strips_regression_search.py │ │ ├── strips_expression.py │ │ ├── strips_grounded_expression.py │ │ ├── strips_grounding.py │ │ ├── strips_grounding_onthefly.py │ │ ├── strips_heuristics.py │ │ └── strips_search.py ├── dsl │ ├── __init__.py │ ├── all.py │ ├── constraint.py │ ├── dsl_domain.py │ ├── dsl_functions.py │ ├── dsl_types.py │ ├── executors │ │ ├── __init__.py │ │ ├── executor_base.py │ │ ├── function_domain_executor.py │ │ ├── tensor_value_eager_executor.py │ │ ├── tensor_value_executor.py │ │ └── value_quantizers.py │ ├── expression.py │ ├── expression_utils.py │ ├── expression_visitor.py │ ├── function_domain.py │ ├── learning │ │ ├── __init__.py │ │ └── function_domain_search.py │ ├── parsers │ │ ├── __init__.py │ │ ├── fol_python_parser.py │ │ ├── function_expression_parser.py │ │ └── parser_base.py │ ├── tensor_state.py │ ├── tensor_value.py │ ├── tensor_value_utils.py │ └── value.py ├── gui │ ├── __init__.py │ ├── open3d_gui │ │ ├── __init__.py │ │ ├── point_picker_3d.py │ │ └── trajectory_visualizer_3d.py │ ├── opencv │ │ ├── __init__.py │ │ ├── point_picker.py │ │ └── simple_text_visualizer.py │ └── tk │ │ ├── __init__.py │ │ ├── drawing_window.py │ │ └── point_picker.py ├── hw_interface │ ├── __init__.py │ ├── franka │ │ ├── __init__.py │ │ ├── deoxys_interfaces.py │ │ ├── deoxys_server.py │ │ ├── fri_client.py │ │ ├── fri_server.py │ │ ├── remote_client.py │ │ └── server.py │ ├── george_vision │ │ ├── __init__.py │ │ ├── object_centric_vision.py │ │ └── segmentation_models.py │ ├── k4a │ │ ├── __init__.py │ │ └── device.py │ ├── rby1a │ │ ├── __init__.py │ │ ├── client.py │ │ ├── client_utils.py │ │ ├── qr_gripper_controller.py │ │ └── server.py │ ├── realsense │ │ ├── __init__.py │ │ ├── device.py │ │ ├── device_f.py │ │ └── visualizer.py │ └── robot_state_visualizer │ │ ├── __init__.py │ │ ├── visualizer.py │ │ └── visualizer_multiproc.py ├── language │ ├── __init__.py │ ├── ccg │ │ ├── __init__.py │ │ ├── composition.py │ │ ├── grammar.py │ │ ├── learning.py │ │ ├── search.py │ │ ├── semantics.py │ │ └── syntax.py │ ├── gpt_parsing │ │ ├── __init__.py │ │ ├── caption_sng.py │ │ ├── prompts │ │ │ └── gpt-35-turbo-chat-caption.txt │ │ └── utils.py │ ├── gpt_vlm_query │ │ ├── __init__.py │ │ ├── gpt_image_query_utils.py │ │ └── gpt_object_naming.py │ ├── neural_ccg │ │ ├── __init__.py │ │ ├── ckyee.py │ │ ├── grammar.py │ │ ├── search.py │ │ └── tensorized_syntax.py │ └── openai_utils │ │ ├── __init__.py │ │ ├── default_client.py │ │ ├── llm_prompting.py │ │ └── llm_prompting_utils.py ├── math │ ├── __init__.py │ ├── cad │ │ ├── __init__.py │ │ └── mesh_utils.py │ ├── frame_utils_xyzw.py │ ├── interpolation_multi_utils.py │ ├── interpolation_utils.py │ ├── range.py │ ├── rotationlib_wxyz.py │ ├── rotationlib_xyzw.py │ └── rotationlib_xyzw_torch.py ├── nn │ ├── __init__.py │ ├── int_embedding.py │ └── vae1d.py ├── pdsketch │ ├── __init__.py │ ├── csp_solvers │ │ ├── __init__.py │ │ ├── brute_force_sampling.py │ │ └── dpll_sampling.py │ ├── domain.py │ ├── executor.py │ ├── generator.py │ ├── operator.py │ ├── parsers │ │ ├── __init__.py │ │ ├── pdsketch-v2.grammar │ │ └── pdsketch_parser.py │ ├── planners │ │ ├── __init__.py │ │ ├── discrete_search.py │ │ ├── optimistic_search.py │ │ ├── optimistic_search_bilevel_legacy.py │ │ ├── optimistic_search_bilevel_utils.py │ │ ├── optimistic_search_with_simulation.py │ │ ├── regression │ │ │ └── __init__.py │ │ └── search_utils.py │ ├── predicate.py │ ├── simulator_interface.py │ └── strips │ │ ├── __init__.py │ │ ├── atomic_strips_domain.py │ │ ├── atomic_strips_onthefly_search.py │ │ ├── atomic_strips_regression_search.py │ │ ├── strips_expression.py │ │ ├── strips_grounded_expression.py │ │ ├── strips_grounding.py │ │ ├── strips_grounding_onthefly.py │ │ ├── strips_heuristics.py │ │ └── strips_search.py ├── sandbox │ └── __init__.py ├── simulator │ ├── __init__.py │ ├── blender │ │ ├── __init__.py │ │ └── simple_render.py │ ├── cad_asset_utils │ │ ├── __init__.py │ │ ├── alphabet_arial.py │ │ ├── alphabet_dejavu.py │ │ ├── assets_base.py │ │ └── shapenet.py │ ├── ikfast │ │ ├── __init__.py │ │ ├── compile.py │ │ ├── franka_panda │ │ │ ├── __init__.py │ │ │ ├── ikfast.h │ │ │ ├── ikfast_panda_arm.cpp │ │ │ ├── setup.py │ │ │ └── travis.sh │ │ ├── ikfast.h │ │ ├── ikfast_common.py │ │ ├── quickaccess.py │ │ └── ur5 │ │ │ ├── __init__.py │ │ │ ├── ikfast.h │ │ │ ├── ikfast_ur5.cpp │ │ │ ├── ikfast_ur5.h │ │ │ ├── setup.py │ │ │ └── travis.sh │ ├── mplib │ │ ├── __init__.py │ │ └── client.py │ ├── pybullet │ │ ├── __init__.py │ │ ├── camera.py │ │ ├── client.py │ │ ├── components │ │ │ ├── __init__.py │ │ │ ├── asset_libraries │ │ │ │ ├── __init__.py │ │ │ │ ├── igibson.py │ │ │ │ └── shapenet.py │ │ │ ├── component_base.py │ │ │ ├── multi_robot_controller.py │ │ │ ├── panda │ │ │ │ ├── __init__.py │ │ │ │ └── panda_robot.py │ │ │ ├── rby1a │ │ │ │ ├── __init__.py │ │ │ │ └── rby1a_robot.py │ │ │ ├── robot_base.py │ │ │ └── ur5 │ │ │ │ ├── __init__.py │ │ │ │ ├── ur5_gripper.py │ │ │ │ └── ur5_robot.py │ │ ├── control_utils.py │ │ ├── cspace.py │ │ ├── default_env.py │ │ ├── ikfast │ │ │ ├── __init__.py │ │ │ ├── compile.py │ │ │ ├── franka_panda │ │ │ │ ├── __init__.py │ │ │ │ ├── ikfast.h │ │ │ │ ├── ikfast_panda_arm.cpp │ │ │ │ ├── setup.py │ │ │ │ └── travis.sh │ │ │ ├── ikfast.h │ │ │ ├── ikfast_common.py │ │ │ └── ur5 │ │ │ │ ├── __init__.py │ │ │ │ ├── ikfast.h │ │ │ │ ├── ikfast_ur5.cpp │ │ │ │ ├── ikfast_ur5.h │ │ │ │ ├── setup.py │ │ │ │ └── travis.sh │ │ ├── manipulation_utils │ │ │ ├── __init__.py │ │ │ ├── bimanual_path_generation_utils.py │ │ │ ├── contact_samplers.py │ │ │ ├── grasping_samplers.py │ │ │ └── path_generation_utils.py │ │ ├── mjcf_utils.py │ │ ├── pybullet_ikfast_utils.py │ │ ├── pybullet_mjcf_utils.py │ │ ├── qddl_interface.py │ │ ├── rotation_utils.py │ │ ├── rotation_utils_torch.py │ │ ├── urdf_utils │ │ │ ├── __init__.py │ │ │ ├── obj2urdf.py │ │ │ └── urdf_prototype.urdf │ │ └── world.py │ ├── pymunk │ │ ├── __init__.py │ │ ├── body_utils.py │ │ ├── collision.py │ │ ├── constants.py │ │ ├── default_env.py │ │ └── world.py │ ├── sapien │ │ ├── __init__.py │ │ ├── camera.py │ │ ├── controllers │ │ │ ├── __init__.py │ │ │ ├── base_cartesian_line_controller.py │ │ │ └── joint_trajectory_controller.py │ │ ├── manipulation_utils │ │ │ ├── __init__.py │ │ │ └── contact_samplers.py │ │ └── mesh_utils.py │ ├── sapien2 │ │ ├── __init__.py │ │ ├── camera.py │ │ ├── controllers │ │ │ ├── __init__.py │ │ │ ├── base_cartesian_line_controller.py │ │ │ └── joint_trajectory_controller.py │ │ ├── manipulation_utils │ │ │ ├── __init__.py │ │ │ └── contact_samplers.py │ │ ├── mesh_utils.py │ │ ├── sapien_utils.py │ │ ├── scene_base.py │ │ ├── srdf_exporter.py │ │ ├── table_top_scene.py │ │ ├── test_planning.py │ │ └── urdf_exporter.py │ ├── shapely_kinematics │ │ ├── __init__.py │ │ └── shapely_kinematics.py │ ├── tk │ │ ├── __init__.py │ │ ├── drawing_window.py │ │ └── toy_1drobot_visualizer.py │ ├── tracik_utils │ │ ├── __init__.py │ │ └── tracik_wrapper.py │ └── urdf_utils │ │ ├── __init__.py │ │ ├── obj2urdf.py │ │ ├── scene_builder.py │ │ ├── scipy_ik.py │ │ └── urdf_prototype.urdf ├── utils │ ├── __init__.py │ ├── interpolation_utils.py │ ├── range.py │ ├── rotationlib.py │ └── typing_utils.py └── vision │ ├── __init__.py │ ├── depth_smoother │ ├── __init__.py │ └── depth_anything_smoother.py │ ├── fm_match │ ├── __init__.py │ ├── diff3f │ │ ├── __init__.py │ │ ├── diff3f_mesh.py │ │ ├── diff3f_renderer.py │ │ ├── diff3f_utils.py │ │ ├── extractor_diff3f.py │ │ └── extractor_dino.py │ └── dino │ │ ├── __init__.py │ │ ├── dino_match.py │ │ ├── extractor_dino.py │ │ └── get_feature.py │ ├── franka_system_calibration │ ├── __init__.py │ ├── ar_detection.py │ └── calibration.py │ ├── george_vision_pipeline │ ├── __init__.py │ ├── object_centric_vision.py │ └── segmentation_models.py │ ├── shared │ └── __init__.py │ └── uncos │ ├── groundedsam.py │ ├── uncos.py │ └── uncos_utils.py ├── docs ├── .gitignore ├── Makefile ├── make.bat ├── requirements.txt └── source │ ├── _static │ ├── custom.css │ └── overview.png │ ├── _templates │ ├── base.rst │ └── class.rst │ ├── api.rst │ ├── conf.py │ ├── index.rst │ ├── tutorial │ └── tutorials.rst ├── examples ├── algorithm │ └── rrt │ │ └── birrt.py ├── benchmark │ ├── clevr │ │ └── scene_generator │ │ │ ├── .gitignore │ │ │ └── render_example_images.py │ └── manip_tabletop │ │ └── pybullet_tabletop_base │ │ ├── .gitignore │ │ ├── cliport-ocrtoc-blender.py │ │ ├── cliport-ocrtoc.py │ │ └── cliport-shapenet.py ├── dm │ └── crow │ │ ├── 00-language │ │ ├── 1-load-crow-domain.py │ │ ├── README.md │ │ ├── alternative-demo.cdl │ │ ├── condition-demo.cdl │ │ ├── crow-demo.cdl │ │ ├── dirty-feature-implementations.py │ │ ├── dirty-feature.cdl │ │ ├── foreach-loop.cdl │ │ ├── list-type-demo.cdl │ │ ├── mem-query-run.py │ │ ├── mem-query.cdl │ │ └── string-demo.cdl │ │ ├── 01-blocksworld │ │ ├── 1-load-crow-domain.py │ │ ├── 2-solve-blocksworld.py │ │ ├── README.md │ │ ├── blocksworld-breakdown.cdl │ │ ├── blocksworld-problem-sussman-with-custom-policy.cdl │ │ ├── blocksworld-problem-sussman-with-custom-policy2.cdl │ │ ├── blocksworld-problem-sussman-with-pachieve.cdl │ │ ├── blocksworld-problem-sussman-with-pragma.cdl │ │ ├── blocksworld-problem-sussman.cdl │ │ ├── blocksworld.cdl │ │ └── inspect-graph.py │ │ ├── 02-simple-pick-place │ │ ├── 1-load-crow-domain.py │ │ ├── 2-load-qddl-scene.py │ │ ├── 3-control-panda.py │ │ ├── 4-solve-pick-place.py │ │ ├── 5-solve-build-stack.py │ │ ├── README.md │ │ ├── simple-cube-in-box-domain.qddl │ │ ├── simple-cube-in-box-problem.qddl │ │ └── simple-cube-stack-problem.qddl │ │ ├── 03-crafting-world │ │ ├── 1-load-crow-domain.py │ │ ├── 2-solve-crafting-world.py │ │ ├── README.md │ │ ├── crafting-world-problem-example-with-pragma.cdl │ │ └── crafting-world-problem-example.cdl │ │ ├── 04-paint-factory │ │ ├── 1-load-crow-domain.py │ │ ├── 2-visualize-oracle-policy.py │ │ └── README.md │ │ ├── 05-pick-place-hierarchy │ │ ├── 1-visualize-env.py │ │ └── 2-solve-pick-place-hierarchy.py │ │ ├── 06-simple-belief │ │ ├── 1-test-simple-belief-update.py │ │ ├── 2-test-simple-belief-cost.py │ │ ├── 3-test-simple-belief-cost-plan.py │ │ ├── belief-example-1.cdl │ │ ├── belief-example-2.cdl │ │ ├── belief-example-3.cdl │ │ └── belief.cdl │ │ ├── 07-simple-csp │ │ ├── 1-bool-csp.cdl │ │ ├── 2-simple-float-csp.cdl │ │ ├── 2-simple-float-csp.py │ │ ├── 3-simple-float-csp2.cdl │ │ └── 3-simple-float-csp2.py │ │ ├── 08-simple-heuristic │ │ ├── __pycache__ │ │ │ └── simple_heuristic_lib.cpython-311.pyc │ │ ├── simple-heuristic-domain-without-heuristic.cdl │ │ ├── simple-heuristic-domain.cdl │ │ ├── simple-heuristic-prob1-without-heuristic.cdl │ │ ├── simple-heuristic-prob1.cdl │ │ └── simple_heuristic_lib.py │ │ ├── 09-simple-cost │ │ └── preference-demo.cdl │ │ ├── 10-crow-as-fol-language │ │ └── run.py │ │ ├── 11-simulation-interface-example │ │ ├── domain.cdl │ │ └── run.py │ │ ├── 12-harder-pick-place │ │ ├── cogman.py │ │ ├── franka_base.cdl │ │ ├── franka_base.py │ │ ├── franka_pick_place_push.cdl │ │ ├── franka_pick_place_push.py │ │ ├── franka_pick_place_push_old.cdl │ │ ├── pick-place-domain.qddl │ │ ├── pick-place-problem0.qddl │ │ ├── pick-place-problem1.qddl │ │ ├── pick-place-problem2.qddl │ │ ├── pick-place-problem3.qddl │ │ └── run.py │ │ └── lisdf-utils │ │ ├── README.md │ │ ├── pack_qddl.py │ │ └── vis_qddl.py ├── gui │ ├── infinite-corridor.jpg │ └── tk │ │ └── point_picker.py ├── hw_interface │ └── franka │ │ ├── run-deoxys-server.py │ │ └── test-deoxys-client.py ├── simulator │ └── pybullet │ │ └── panda_robot │ │ ├── test-panda-ikfast-fk.py │ │ └── visualize-panda-workspace.py └── vision │ ├── _assets │ ├── movo-rgbd-test.pkl │ └── realsense-hook-test.pkl │ ├── depth_smoother │ ├── encode-hook-data.py │ ├── run-depth-smoother.py │ └── test-depth-anything.py │ ├── franka_system_calibration │ ├── .gitignore │ ├── test-ar-tag-detection.py │ ├── test-realsense-det.py │ └── test-realsense-reconstruction.py │ ├── george_vision_pipeline │ └── object_centric_vision │ │ ├── .gitignore │ │ ├── install.sh │ │ ├── test-george-vision.py │ │ ├── test-sam-all.py │ │ └── test-sam.py │ ├── qr_pipeline │ ├── .gitignore │ ├── 1-visualize-data.py │ ├── 2-visualize-combined-pointcloud.py │ └── 3-visualize-smoothed-combined-pointcloud.py │ └── uncos │ ├── .gitignore │ └── run-uncos.py ├── jacinle.yml ├── pyproject.toml ├── setup.py └── tutorial ├── 1-dsl ├── 1-types-and-functions.ipynb ├── 2-execution.ipynb ├── 3-tensor-values.ipynb ├── 4-learning.ipynb └── 5-fol-python-parser.ipynb ├── 2-ccg ├── 1-parsing.ipynb ├── 2-learning.ipynb ├── 3-neural-ccg-basics.ipynb └── 4-neural-ccg-weights.ipynb ├── 3-pdsketch ├── 1-basic-pddl.ipynb ├── 2-optimistic-solve.ipynb ├── 3-translate-into-strips.ipynb ├── 4-search-with-strips.ipynb ├── 5-advanced-features.ipynb └── mini-behavior.pddl ├── 4-neural-logic └── 1-learning-family-relations.ipynb └── 5-neuro-symbolic-concept-learning └── 1-logic-enhanced-foundation-model.ipynb /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Jiayuan Mao 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 | -------------------------------------------------------------------------------- /_assets/overview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/concepts-ai/Concepts/13847828a1ecb8f0d8c43a420a2a1ad234cfe242/_assets/overview.png -------------------------------------------------------------------------------- /bin/cdl-lexer: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : cdl-highlight 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 07/13/2024 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | import os.path as osp 12 | import sys 13 | import jacinle 14 | 15 | logger = jacinle.get_logger(__file__) 16 | parser = jacinle.JacArgumentParser() 17 | parser.add_argument('inputfile', type='checked_file', help='Input CDL file') 18 | args = parser.parse_args() 19 | 20 | 21 | def main(): 22 | sys.path.insert(0, osp.join(osp.dirname(__file__), '..')) 23 | 24 | with open(args.inputfile) as f: 25 | string = f.read() 26 | 27 | from concepts.dm.crow.parsers.cdl_formatter import lex_cdl_string 28 | table = list() 29 | for token in lex_cdl_string(string): 30 | table.append((token.line, token.column, token.start_pos, token.end_pos, token.type, repr(token.value))) 31 | print(jacinle.tabulate(table, headers=['line', 'column', 'start', 'end', 'type', 'value'])) 32 | print() 33 | 34 | 35 | if __name__ == '__main__': 36 | main() 37 | 38 | -------------------------------------------------------------------------------- /bin/concepts-update-assets: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | # 3 | # concepts-update-assets.sh 4 | # Copyright (C) 2024 Jiayuan Mao 5 | # 6 | # Distributed under terms of the MIT license. 7 | # 8 | 9 | set -e 10 | 11 | cd "$(dirname "$0")" 12 | cd ../concepts/assets 13 | ./sync-down.sh 14 | 15 | -------------------------------------------------------------------------------- /bin/obj2urdf: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : obj2urdf.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 08/25/2022 7 | # 8 | # This file is part of HACL-PyTorch. 9 | # Distributed under terms of the MIT license. 10 | 11 | import os.path as osp 12 | import sys 13 | import jacinle 14 | 15 | sys.path.insert(0, osp.join(osp.dirname(__file__), '..')) 16 | 17 | from concepts.simulator.urdf_utils.obj2urdf import ObjectUrdfBuilder # noqa: E402 18 | 19 | center_options = ['mass', 'geometry', 'top', 'bottom', 'xy_pos', 'xy_neg', 'xz_pos', 'xz_neg', 'yz_pos', 'yz_neg'] 20 | 21 | logger = jacinle.get_logger(__file__) 22 | parser = jacinle.JacArgumentParser(description='Convert obj file to urdf file.') 23 | parser.add_argument('obj_file', help='obj file') 24 | parser.add_argument('--center', default='mass', choices=center_options, help='center of the object') 25 | parser.add_argument('--force-pybullet-vhacd', action='store_true', help='force to use pybullet vhacd for decomposition') 26 | args = parser.parse_args() 27 | 28 | 29 | def main(): 30 | if args.force_pybullet_vhacd: 31 | builder = ObjectUrdfBuilder(osp.dirname(args.obj_file), use_trimesh_vhacd=False, use_pybullet_vhacd=True) 32 | else: 33 | # Use the default setting: it will use trimesh vhacd if available, otherwise use pybullet vhacd. 34 | builder = ObjectUrdfBuilder(osp.dirname(args.obj_file)) 35 | 36 | builder.build_urdf(args.obj_file, force_overwrite=True, decompose_concave=True, force_decompose=False, center=args.center) 37 | 38 | 39 | if __name__ == '__main__': 40 | main() 41 | 42 | 43 | -------------------------------------------------------------------------------- /bin/pds-summary: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : pds-summary 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 02/04/2022 7 | # 8 | # This file is part of HACL-PyTorch. 9 | # Distributed under terms of the MIT license. 10 | 11 | import os.path as osp 12 | import sys 13 | import jacinle 14 | 15 | logger = jacinle.get_logger(__file__) 16 | parser = jacinle.JacArgumentParser() 17 | parser.add_argument('inputfile', type='checked_file', help='Input pdsketch file') 18 | args = parser.parse_args() 19 | 20 | 21 | def main(): 22 | sys.path.insert(0, osp.join(osp.dirname(__file__), '..')) 23 | import concepts.dm.pdsketch as pds 24 | 25 | domain = pds.load_domain_file(args.inputfile) 26 | domain.print_summary() 27 | 28 | 29 | if __name__ == '__main__': 30 | main() 31 | 32 | -------------------------------------------------------------------------------- /concepts/.vim-template:.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * File : %FFILE% 3 | * Author : %USER% 4 | * Email : %MAIL% 5 | * Date : %MONTH%/%DAY%/%YEAR% 6 | * 7 | * This file is part of Project Concepts. 8 | * Distributed under terms of the %LICENSE% license. 9 | */ 10 | 11 | #include "%FILE%.h" 12 | 13 | %HERE% 14 | -------------------------------------------------------------------------------- /concepts/.vim-template:.h: -------------------------------------------------------------------------------- 1 | /* 2 | * File : %FFILE% 3 | * Author : %USER% 4 | * Email : %MAIL% 5 | * Date : %MONTH%/%DAY%/%YEAR% 6 | * 7 | * This file is part of Project Concepts. 8 | * Distributed under terms of the %LICENSE% license. 9 | */ 10 | 11 | #pragma once 12 | 13 | %HERE% 14 | -------------------------------------------------------------------------------- /concepts/.vim-template:.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : %FFILE% 4 | # Author : %USER% 5 | # Email : %MAIL% 6 | # Date : %MONTH%/%DAY%/%YEAR% 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the %LICENSE% license. 10 | 11 | -------------------------------------------------------------------------------- /concepts/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 06/23/2022 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | -------------------------------------------------------------------------------- /concepts/algorithm/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 11/01/2022 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | """Generic implementation for a few basic algorithms, such as A* search.""" 12 | -------------------------------------------------------------------------------- /concepts/algorithm/rrt/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 06/14/2023 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | -------------------------------------------------------------------------------- /concepts/algorithm/search/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 12/03/2022 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | -------------------------------------------------------------------------------- /concepts/assets/.gitignore: -------------------------------------------------------------------------------- 1 | /* 2 | !.gitignore 3 | !/*.sh 4 | -------------------------------------------------------------------------------- /concepts/assets/sync-down.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | # 3 | # sync-down.sh 4 | # Copyright (C) 2023 Jiayuan Mao 5 | # 6 | # Distributed under terms of the MIT license. 7 | # 8 | 9 | set -e 10 | 11 | wget -O assets.tar https://concepts-ai.com/assets.tar 12 | 13 | # extract the assets and do overwrite 14 | tar -xvf assets.tar 15 | 16 | # remove the tar file 17 | rm assets.tar 18 | -------------------------------------------------------------------------------- /concepts/assets/sync-up.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | # 3 | # sync-up.sh 4 | # Copyright (C) 2023 Jiayuan Mao 5 | # 6 | # Distributed under terms of the MIT license. 7 | # 8 | 9 | set -e 10 | 11 | tar czvf assets.tar basic cliport objects robots visual_reasoning_datasets 12 | #rsync -avP assets.tar droplet.jiayuanm.com:~/concepts_docs/html 13 | rsync -avP assets.tar iris@droplet.jiayuanm.com:~/concepts_docs/html 14 | rm assets.tar 15 | 16 | -------------------------------------------------------------------------------- /concepts/benchmark/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 08/13/2022 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | """Data loaders for various datasets.""" 12 | 13 | -------------------------------------------------------------------------------- /concepts/benchmark/algorithm_env/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 06/13/2023 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | -------------------------------------------------------------------------------- /concepts/benchmark/blocksworld/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 06/13/2023 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | -------------------------------------------------------------------------------- /concepts/benchmark/clevr/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 02/26/2023 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | -------------------------------------------------------------------------------- /concepts/benchmark/clevr/clevr_constants.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : clevr_constants.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 09/29/2018 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | """Constants for the CLEVR dataset.""" 12 | 13 | from typing import Tuple, List 14 | 15 | __all__ = ['g_attribute_concepts', 'g_relational_concepts', 'g_synonyms', 'load_clevr_concepts'] 16 | 17 | 18 | g_attribute_concepts = { 19 | 'color': ['gray', 'red', 'blue', 'green', 'brown', 'purple', 'cyan', 'yellow'], 20 | 'material': ['rubber', 'metal'], 21 | 'shape': ['cube', 'sphere', 'cylinder'], 22 | 'size': ['small', 'large'] 23 | } 24 | 25 | g_relational_concepts = { 26 | 'spatial_relation': ['left', 'right', 'front', 'behind'] 27 | } 28 | 29 | g_synonyms = { 30 | "thing": ["thing", "object"], 31 | "sphere": ["sphere", "ball", "spheres", "balls"], 32 | "cube": ["cube", "block", "cubes", "blocks"], 33 | "cylinder": ["cylinder", "cylinders"], 34 | "large": ["large", "big"], 35 | "small": ["small", "tiny"], 36 | "metal": ["metallic", "metal", "shiny"], 37 | "rubber": ["rubber", "matte"], 38 | } 39 | 40 | 41 | def load_clevr_concepts() -> Tuple[List[str], List[str], List[str]]: 42 | """Return the concepts for CLEVR dataset. 43 | 44 | Returns: 45 | Tuple[List[str], List[str], List[str]]: attribute_concepts, relational_concepts, multi_relational_concepts 46 | """ 47 | 48 | attribute_concepts = [] 49 | for k in g_attribute_concepts.keys(): 50 | attribute_concepts.extend(g_attribute_concepts[k]) 51 | for k in g_synonyms.keys(): 52 | attribute_concepts.extend(g_synonyms[k]) 53 | attribute_concepts = list(set(attribute_concepts)) 54 | 55 | relational_concepts = g_relational_concepts['spatial_relation'] 56 | multi_relational_concepts = g_relational_concepts['spatial_relation'] 57 | 58 | return attribute_concepts, relational_concepts, multi_relational_concepts 59 | 60 | -------------------------------------------------------------------------------- /concepts/benchmark/clevr/scene_generator/assets/base_scene.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/concepts-ai/Concepts/13847828a1ecb8f0d8c43a420a2a1ad234cfe242/concepts/benchmark/clevr/scene_generator/assets/base_scene.blend -------------------------------------------------------------------------------- /concepts/benchmark/clevr/scene_generator/assets/materials/MyMetal.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/concepts-ai/Concepts/13847828a1ecb8f0d8c43a420a2a1ad234cfe242/concepts/benchmark/clevr/scene_generator/assets/materials/MyMetal.blend -------------------------------------------------------------------------------- /concepts/benchmark/clevr/scene_generator/assets/materials/Rubber.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/concepts-ai/Concepts/13847828a1ecb8f0d8c43a420a2a1ad234cfe242/concepts/benchmark/clevr/scene_generator/assets/materials/Rubber.blend -------------------------------------------------------------------------------- /concepts/benchmark/clevr/scene_generator/assets/properties.json: -------------------------------------------------------------------------------- 1 | { 2 | "shapes": { 3 | "cube": "SmoothCube_v2", 4 | "sphere": "Sphere", 5 | "cylinder": "SmoothCylinder", 6 | "cone": "Cone" 7 | }, 8 | "colors": { 9 | "gray": [87, 87, 87], 10 | "red": [173, 35, 35], 11 | "blue": [42, 75, 215], 12 | "green": [29, 105, 20], 13 | "brown": [129, 74, 25], 14 | "purple": [129, 38, 192], 15 | "cyan": [41, 208, 208], 16 | "yellow": [255, 238, 51] 17 | }, 18 | "materials": { 19 | "rubber": "Rubber", 20 | "metal": "MyMetal" 21 | }, 22 | "sizes": { 23 | "large": 1.5, 24 | "middle2": 1.0, 25 | "middle1": 0.8, 26 | "small": 0.5 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /concepts/benchmark/clevr/scene_generator/assets/shapes/Cone.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/concepts-ai/Concepts/13847828a1ecb8f0d8c43a420a2a1ad234cfe242/concepts/benchmark/clevr/scene_generator/assets/shapes/Cone.blend -------------------------------------------------------------------------------- /concepts/benchmark/clevr/scene_generator/assets/shapes/SmoothCube_v2.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/concepts-ai/Concepts/13847828a1ecb8f0d8c43a420a2a1ad234cfe242/concepts/benchmark/clevr/scene_generator/assets/shapes/SmoothCube_v2.blend -------------------------------------------------------------------------------- /concepts/benchmark/clevr/scene_generator/assets/shapes/SmoothCylinder.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/concepts-ai/Concepts/13847828a1ecb8f0d8c43a420a2a1ad234cfe242/concepts/benchmark/clevr/scene_generator/assets/shapes/SmoothCylinder.blend -------------------------------------------------------------------------------- /concepts/benchmark/clevr/scene_generator/assets/shapes/Sphere.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/concepts-ai/Concepts/13847828a1ecb8f0d8c43a420a2a1ad234cfe242/concepts/benchmark/clevr/scene_generator/assets/shapes/Sphere.blend -------------------------------------------------------------------------------- /concepts/benchmark/common/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 02/26/2023 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | -------------------------------------------------------------------------------- /concepts/benchmark/common/random_env.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : random_env.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 01/02/2024 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | from typing import Any, Optional, Tuple 12 | 13 | import numpy as np 14 | from gym.core import Env 15 | 16 | 17 | class RandomizedEnv(Env): 18 | def __init__(self, np_random: Optional[np.random.RandomState] = None, seed: Optional[int] = None): 19 | if np_random is None: 20 | if seed is None: 21 | self._np_random = np.random.RandomState() 22 | else: 23 | self._np_random = np.random.RandomState(seed) 24 | else: 25 | self._np_random = np_random 26 | 27 | _np_random: np.random.RandomState 28 | 29 | @property 30 | def np_random(self) -> np.random.RandomState: 31 | return self._np_random 32 | 33 | def seed(self, seed=None): 34 | self._np_random.seed(seed) 35 | 36 | @property 37 | def action_space(self): 38 | raise NotImplementedError 39 | 40 | @property 41 | def observation_space(self): 42 | raise NotImplementedError 43 | 44 | def step(self, action: Any) -> Tuple[Any, float, bool, dict]: 45 | """Run one timestep of the environment's dynamics. 46 | When end of episode is reached, you are responsible for calling `reset()` to reset this environment's state. 47 | 48 | Accepts an action and returns a tuple (observation, reward, done, info). 49 | 50 | Args: 51 | action: an action provided by the environment 52 | 53 | Returns: 54 | observation: agent's observation of the current environment 55 | reward: amount of reward returned after previous action 56 | done: whether the episode has ended, in which case further step() calls will return undefined results 57 | info: contains auxiliary diagnostic information (helpful for debugging, and sometimes learning) 58 | """ 59 | raise NotImplementedError 60 | 61 | -------------------------------------------------------------------------------- /concepts/benchmark/continuous_1d/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 07/04/2024 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | -------------------------------------------------------------------------------- /concepts/benchmark/gridworld/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 09/06/2023 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | -------------------------------------------------------------------------------- /concepts/benchmark/gridworld/crafting_world/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 09/06/2023 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | -------------------------------------------------------------------------------- /concepts/benchmark/gridworld/crafting_world/assets/BlockCSS.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/concepts-ai/Concepts/13847828a1ecb8f0d8c43a420a2a1ad234cfe242/concepts/benchmark/gridworld/crafting_world/assets/BlockCSS.png -------------------------------------------------------------------------------- /concepts/benchmark/gridworld/crafting_world/assets/EntityCSS.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/concepts-ai/Concepts/13847828a1ecb8f0d8c43a420a2a1ad234cfe242/concepts/benchmark/gridworld/crafting_world/assets/EntityCSS.png -------------------------------------------------------------------------------- /concepts/benchmark/gridworld/crafting_world/assets/ItemCSS.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/concepts-ai/Concepts/13847828a1ecb8f0d8c43a420a2a1ad234cfe242/concepts/benchmark/gridworld/crafting_world/assets/ItemCSS.png -------------------------------------------------------------------------------- /concepts/benchmark/gridworld/crafting_world/assets/Jungle_Tree.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/concepts-ai/Concepts/13847828a1ecb8f0d8c43a420a2a1ad234cfe242/concepts/benchmark/gridworld/crafting_world/assets/Jungle_Tree.png -------------------------------------------------------------------------------- /concepts/benchmark/gridworld/crafting_world/assets/Plains_Villager_Base.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/concepts-ai/Concepts/13847828a1ecb8f0d8c43a420a2a1ad234cfe242/concepts/benchmark/gridworld/crafting_world/assets/Plains_Villager_Base.png -------------------------------------------------------------------------------- /concepts/benchmark/gridworld/crafting_world/crafting_world_crow_gen/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 06/21/2024 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | -------------------------------------------------------------------------------- /concepts/benchmark/gridworld/crafting_world/crafting_world_gen/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | 5 | -------------------------------------------------------------------------------- /concepts/benchmark/gridworld/crafting_world/crafting_world_gen/utils.py: -------------------------------------------------------------------------------- 1 | def underline_to_pascal(s: str) -> str: 2 | """Converts a string from underlined to pascal case. 3 | 4 | Example: 5 | >>> underline_to_pascal("hello_world") 6 | "HelloWorld" 7 | 8 | Args: 9 | s: the string to convert. 10 | 11 | Returns: 12 | the converted string. 13 | """ 14 | return ''.join([w.capitalize() for w in s.split('_')]) 15 | 16 | 17 | def underline_to_space(s: str) -> str: 18 | """Converts a string from underlined to a space-separated and lower case string. 19 | 20 | Example: 21 | >>> underline_to_space("Hello_world") 22 | "hello world" 23 | """ 24 | return ' '.join([w.lower() for w in s.split('_')]) 25 | -------------------------------------------------------------------------------- /concepts/benchmark/gridworld/crafting_world/crafting_world_pds_gen/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 06/18/2024 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | 12 | -------------------------------------------------------------------------------- /concepts/benchmark/gridworld/crafting_world/crafting_world_teleport/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 09/06/2023 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | import os.path as osp 12 | 13 | __all__ = ['get_domain_filename', 'get_station_agnostic_domain_filename'] 14 | 15 | 16 | def get_domain_filename() -> str: 17 | """Get the domain filename of the crafting world (teleport).""" 18 | return osp.join(osp.dirname(__file__), 'domain.pddl') 19 | 20 | 21 | def get_station_agnostic_domain_filename() -> str: 22 | """Get the domain filename of the crafting world (teleport) with station-agnostic actions.""" 23 | return osp.join(osp.dirname(__file__), 'domain-station-agnostic.pddl') 24 | 25 | 26 | def _check_file_exists(): 27 | if not osp.isfile(get_domain_filename()) or not osp.isfile(get_station_agnostic_domain_filename()): 28 | import concepts.benchmark.gridworld.crafting_world.crafting_world_teleport.domain_gen as gen 29 | print('Generating the domain files for the crafting world (teleport)...') 30 | gen.main() 31 | gen.main_station_agnostic() 32 | 33 | 34 | _check_file_exists() -------------------------------------------------------------------------------- /concepts/benchmark/gridworld/crafting_world/crow_domains/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 05/05/2024 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | import os.path as osp 12 | 13 | __all__ = ['get_crafting_world_domain_filename'] 14 | 15 | 16 | def get_crafting_world_domain_filename(station_agnostic: bool = True, regenerate: bool = False) -> str: 17 | """Get the domain filename of the crafting world (teleport).""" 18 | 19 | if regenerate: 20 | from .cdl_gen import main_station_agnostic 21 | main_station_agnostic() 22 | 23 | if station_agnostic: 24 | return osp.join(osp.dirname(__file__), 'crafting_world_station_agnostic.cdl') 25 | else: 26 | return osp.join(osp.dirname(__file__), 'crafting_world.cdl') 27 | 28 | -------------------------------------------------------------------------------- /concepts/benchmark/gridworld/crafting_world/pds_domains/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 09/06/2023 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | import os.path as osp 12 | 13 | __all__ = ['get_crafting_world_domain_filename', 'get_crafting_world_station_agnostic_domain_filename'] 14 | 15 | 16 | def get_crafting_world_domain_filename() -> str: 17 | """Get the domain filename of the crafting world (teleport).""" 18 | return osp.join(osp.dirname(__file__), 'domain.pddl') 19 | 20 | 21 | def get_crafting_world_station_agnostic_domain_filename() -> str: 22 | """Get the domain filename of the crafting world (teleport) with station-agnostic actions.""" 23 | return osp.join(osp.dirname(__file__), 'domain-station-agnostic.pddl') 24 | 25 | 26 | def _check_file_exists(): 27 | if not osp.isfile(get_crafting_world_domain_filename()) or not osp.isfile(get_crafting_world_station_agnostic_domain_filename()): 28 | import concepts.benchmark.gridworld.crafting_world.pds_domains.domain_gen as gen 29 | print('Generating the domain files for the crafting world (teleport)...') 30 | gen.main() 31 | gen.main_station_agnostic() 32 | 33 | 34 | _check_file_exists() -------------------------------------------------------------------------------- /concepts/benchmark/gridworld/crafting_world/utils.py: -------------------------------------------------------------------------------- 1 | def underline_to_pascal(s: str) -> str: 2 | """Converts a string from underlined to pascal case. 3 | 4 | Example: 5 | >>> underline_to_pascal("hello_world") 6 | "HelloWorld" 7 | 8 | Args: 9 | s: the string to convert. 10 | 11 | Returns: 12 | the converted string. 13 | """ 14 | return ''.join([w.capitalize() for w in s.split('_')]) 15 | 16 | 17 | def underline_to_space(s: str) -> str: 18 | """Converts a string from underlined to a space-separated and lower case string. 19 | 20 | Example: 21 | >>> underline_to_space("Hello_world") 22 | "hello world" 23 | """ 24 | return ' '.join([w.lower() for w in s.split('_')]) 25 | -------------------------------------------------------------------------------- /concepts/benchmark/gridworld/minigrid/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 09/06/2023 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | -------------------------------------------------------------------------------- /concepts/benchmark/gridworld/minigrid/gym_minigrid/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 09/06/2023 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | from .minigrid import * 12 | from .path_finding import * 13 | -------------------------------------------------------------------------------- /concepts/benchmark/gridworld/minigrid/pds_domains/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 09/06/2023 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | import os.path as osp 12 | 13 | __all__ = ['get_minigrid_domain_filename'] 14 | 15 | 16 | def get_minigrid_domain_filename(encoding: str = 'full') -> str: 17 | """Get the domain filename of the crafting world.""" 18 | return osp.join(osp.dirname(__file__), f'minigrid-domain-v20220407-{encoding}.pdsketch') 19 | -------------------------------------------------------------------------------- /concepts/benchmark/logic_induction/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 06/13/2023 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | -------------------------------------------------------------------------------- /concepts/benchmark/manip_tabletop/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 08/01/2023 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | -------------------------------------------------------------------------------- /concepts/benchmark/manip_tabletop/bimanual_abc/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 07/07/2024 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | -------------------------------------------------------------------------------- /concepts/benchmark/manip_tabletop/bimanual_abc/envs/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 07/07/2024 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | -------------------------------------------------------------------------------- /concepts/benchmark/manip_tabletop/bimanual_abc/envs/bimanual_abc_pivot.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : bimanual_abc_pivot.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 07/07/2024 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | from concepts.benchmark.manip_tabletop.bimanual_abc.bimanual_abc_env_base import BimanualABCEnvBase 12 | 13 | 14 | class BimanualABCPickupPlateEnv(BimanualABCEnvBase): 15 | def _reset_objects(self, metainfo: dict): 16 | plate_id = self.add_plate(0.6, (0.5, 0.0)) 17 | self.metainfo['objects']['plate'] = {'id': plate_id, 'size': 0.3, 'position': (0.5, 0.0)} 18 | 19 | 20 | class BimanualABCPivotBoxEnv(BimanualABCEnvBase): 21 | def _reset_objects(self, metainfo: dict): 22 | box_id = self.add_box((0.1, 0.15, 0.1), location_2d=(0.5, 0.0)) 23 | self.metainfo['objects']['box'] = {'id': box_id} 24 | -------------------------------------------------------------------------------- /concepts/benchmark/manip_tabletop/paint_factory/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 12/22/2023 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | -------------------------------------------------------------------------------- /concepts/benchmark/manip_tabletop/paint_factory/crow_domains/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 05/05/2024 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | import os.path as osp 12 | 13 | 14 | def get_paint_factory_domain_filename(): 15 | return osp.join(osp.dirname(__file__), 'paint-factory-v20231225.cdl') 16 | 17 | -------------------------------------------------------------------------------- /concepts/benchmark/manip_tabletop/paint_factory/paint-factory-domain-v20231225.pdsketch: -------------------------------------------------------------------------------- 1 | (define 2 | (domain painting-factory-v20231225) 3 | (:requirements :pdsketch-v2-1) 4 | 5 | (:types 6 | item - object 7 | robot - object 8 | item-identifier - int64 9 | robot-identifier - int64 10 | qpos - vector[float32, 6] 11 | pose - vector[float32, 7] 12 | ) 13 | 14 | (:predicates 15 | (robot-identifier ?r - robot -> robot-identifier) 16 | (item-identifier ?o - item -> item-identifier) 17 | (robot-qpos ?r - robot -> qpos) 18 | (item-pose ?o - item -> pose) 19 | (moveable ?o - item) 20 | (item-image [observation=true, state=false] ?o - item -> vector[float32, 3]) 21 | (item-feature [state=true] ?o - item -> vector[float32, 64]) 22 | ) 23 | 24 | (:derived (is-red ?o - item) (??f (item-feature ?o))) 25 | (:derived (is-green ?o - item) (??f (item-feature ?o))) 26 | (:derived (is-yellow ?o - item) (??f (item-feature ?o))) 27 | (:derived (is-purple ?o - item) (??f (item-feature ?o))) 28 | (:derived (is-pink ?o - item) (??f (item-feature ?o))) 29 | (:derived (is-cyan ?o - item) (??f (item-feature ?o))) 30 | (:derived (is-brown ?o - item) (??f (item-feature ?o))) 31 | (:derived (is-orange ?o - item) (??f (item-feature ?o))) 32 | (:derived (is-target ?o - item) (and (??f (item-feature ?o)) (not (moveable ?o)) )) 33 | (:derived (is-left ?o1 - item ?o2 - item) (??f (item-pose ?o1) (item-pose ?o2))) 34 | (:derived (is-right ?o1 - item ?o2 - item) (??f (item-pose ?o1) (item-pose ?o2))) 35 | (:derived (is-on ?o1 - item ?o2 - item) (??f (item-pose ?o1) (item-pose ?o2))) 36 | (:derived (is-in ?o1 - item ?o2 - item) (??f (item-pose ?o1) (item-pose ?o2))) 37 | 38 | (:action move-into 39 | :parameters (?r - robot ?o - item ?c - item) 40 | :precondition (and ) 41 | :effect (and 42 | (item-pose::assign ?o (item-pose ?c)) 43 | (item-feature::cond-assign ?o 44 | (??g (item-feature ?c)) 45 | (??h (item-feature ?c)) 46 | ) 47 | ) 48 | ) 49 | 50 | (:action move-to 51 | :parameters (?o - item ?p - pose) 52 | :precondition (and ) 53 | :effect (and (item-pose::assign ?o ?p)) 54 | ) 55 | 56 | ) 57 | -------------------------------------------------------------------------------- /concepts/benchmark/manip_tabletop/paint_factory/pds_domains/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 05/05/2024 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | -------------------------------------------------------------------------------- /concepts/benchmark/manip_tabletop/pick_place_hierarchy/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 05/07/2024 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | -------------------------------------------------------------------------------- /concepts/benchmark/manip_tabletop/pick_place_hierarchy/pick_place_hierarchy.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : pick_place_hierarchy.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 05/07/2024 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | import os.path as osp 12 | from typing import Optional, Tuple 13 | 14 | from concepts.simulator.pybullet.client import BulletClient 15 | from concepts.simulator.pybullet.qddl_interface import PyBulletQDDLInterface, QDDLSceneMetainfo 16 | 17 | 18 | def get_available_tasks(): 19 | return [ 20 | 'h0-simple', 21 | 'h1-pick-blocker', 22 | 'h1-place-blocker', 23 | 'h1-pick-regrasp', 24 | 'h2-pick-place-blocker', 25 | ] 26 | 27 | 28 | def get_qddl_domain_filename(): 29 | return osp.join(osp.dirname(__file__), 'qddl_files', 'pick-place-hierarchy-domain.qddl') 30 | 31 | 32 | def get_qddl_problem_filename(identifier: str): 33 | return osp.join(osp.dirname(__file__), 'qddl_files', f'{identifier}.qddl') 34 | 35 | 36 | def create_environment(task_identifier: str, client: Optional[BulletClient] = None) -> Tuple[BulletClient, QDDLSceneMetainfo]: 37 | if client is None: 38 | client = BulletClient(is_gui=True) 39 | 40 | interface = PyBulletQDDLInterface(client) 41 | metainfo = interface.load_scene( 42 | get_qddl_domain_filename(), 43 | get_qddl_problem_filename(task_identifier) 44 | ) 45 | 46 | return client, metainfo 47 | -------------------------------------------------------------------------------- /concepts/benchmark/manip_tabletop/pick_place_hierarchy/qddl_files/pick-place-hierarchy-domain.qddl: -------------------------------------------------------------------------------- 1 | (define 2 | (domain pick_place_hierarchy) 3 | 4 | (:object-types 5 | (panda-type "package://concepts/robots/franka_description/robots/panda_arm_hand.urdf") 6 | (workspace-type "package://concepts/basic/plane/workspace.urdf") 7 | (table-type "package://concepts/basic/plane/plane.urdf") 8 | (cube-type "package://concepts/basic/box/box-template.urdf") 9 | ) 10 | 11 | (:predicates 12 | (on ?obj ?obj) 13 | ) 14 | ) 15 | -------------------------------------------------------------------------------- /concepts/benchmark/manip_tabletop/pybullet_tabletop_base.pdsketch: -------------------------------------------------------------------------------- 1 | (define (domain pybullet-tabletop-base) 2 | 3 | (:types 4 | item - object 5 | robot - object 6 | pose - vector[float32, 7] 7 | qpos - vector[float32, 7] 8 | ) 9 | 10 | (:predicates 11 | (moveable ?i - item) 12 | (robot-hands-free ?r - robot) ;; robot is not holding anything 13 | (robot-holding-item ?r - robot ?i - item) ;; robot is holding item 14 | (support ?i - item ?s - item) ;; i is supported by s 15 | 16 | (robot-qpos ?r - robot -> qpos) ;; robot's qpos 17 | (item-pose ?i - item -> pose) ;; item's pose 18 | 19 | (robot-identifier ?r - robot -> int64) ;; robot's identifier 20 | (item-identifier ?i - item -> int64) ;; robot's identifier 21 | ) 22 | ) 23 | -------------------------------------------------------------------------------- /concepts/benchmark/manip_tabletop/pybullet_tabletop_base/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 07/07/2024 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | -------------------------------------------------------------------------------- /concepts/benchmark/manip_tabletop/pybullet_tabletop_base/pds_domains/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 05/05/2024 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | -------------------------------------------------------------------------------- /concepts/benchmark/manip_tabletop/pybullet_tabletop_base/pds_domains/pybullet_tabletop_base.pdsketch: -------------------------------------------------------------------------------- 1 | (define (domain pybullet-tabletop-base) 2 | 3 | (:types 4 | item - object 5 | robot - object 6 | pose - vector[float32, 7] 7 | qpos - vector[float32, 7] 8 | ) 9 | 10 | (:predicates 11 | (moveable ?i - item) 12 | (robot-hands-free ?r - robot) ;; robot is not holding anything 13 | (robot-holding-item ?r - robot ?i - item) ;; robot is holding item 14 | (support ?i - item ?s - item) ;; i is supported by s 15 | 16 | (robot-qpos ?r - robot -> qpos) ;; robot's qpos 17 | (item-pose ?i - item -> pose) ;; item's pose 18 | 19 | (robot-identifier ?r - robot -> int64) ;; robot's identifier 20 | (item-identifier ?i - item -> int64) ;; robot's identifier 21 | ) 22 | ) 23 | -------------------------------------------------------------------------------- /concepts/benchmark/namo/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 05/26/2024 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | -------------------------------------------------------------------------------- /concepts/benchmark/namo/namo_polygon/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 05/26/2024 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | -------------------------------------------------------------------------------- /concepts/benchmark/nethack/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 07/09/2024 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | -------------------------------------------------------------------------------- /concepts/benchmark/vision_language/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 10/07/2023 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | -------------------------------------------------------------------------------- /concepts/benchmark/vision_language/babel_qa/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 02/26/2023 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | -------------------------------------------------------------------------------- /concepts/benchmark/vision_language/babel_qa/humanmotion_constants.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : humanmotion_constants.py 4 | # Author : Joy Hsu 5 | # Email : joycj@stanford.edu 6 | # Date : 04/04/2023 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | attribute_concepts_mapping = { 12 | 'Motion': ['cartwheel_Action', 'catch_Action', 'crawl_Action', 'crouch_Action', 'flip_Action', 'jog_Action', 'jump_Action', 'jumping_jacks_Action', 'kick_Action', 'kneel_Action', 'knock_Action', 'place_something_Action', 'run_Action', 'sit_Action', 'squat_Action', 'stand_up_Action', 'take_Action', 'throw_Action', 'walk_Action', 'wave_Action'], 13 | 'Part': ['left_arm_Action', 'left_foot_Action', 'left_hand_Action', 'left_leg_Action', 'right_arm_Action', 'right_foot_Action', 'right_hand_Action', 'right_leg_Action'], 14 | 'Direction': ['backwards_Action', 'forward_Action', 'left_Action', 'right_Action'] 15 | } 16 | -------------------------------------------------------------------------------- /concepts/benchmark/vision_language/shapes/.gitignore: -------------------------------------------------------------------------------- 1 | /shapes_datset.tar.gz 2 | /shapes_dataset 3 | -------------------------------------------------------------------------------- /concepts/benchmark/vision_language/shapes/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 10/07/2023 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | -------------------------------------------------------------------------------- /concepts/benchmark/vision_language/shapes3/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 10/18/2023 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | -------------------------------------------------------------------------------- /concepts/cc/dsl/dsl_domain.h: -------------------------------------------------------------------------------- 1 | /* 2 | * File : dsl_domain.h 3 | * Author : Jiayuan Mao 4 | * Email : maojiayuan@gmail.com 5 | * Date : 09/10/2023 6 | * 7 | * This file is part of Project Concepts. 8 | * Distributed under terms of the MIT license. 9 | */ 10 | 11 | #pragma once 12 | 13 | #include 14 | #include "dsl_types.h" 15 | 16 | namespace concepts { 17 | 18 | class Domain { 19 | public: 20 | Domain() {} 21 | virtual ~Domain() = default; 22 | 23 | void add_type(const TypeBase &type) { 24 | m_types.insert({type.name(), type}); 25 | } 26 | 27 | void add_function(const FunctionType &func) { 28 | m_functions.insert({func.name(), func}); 29 | } 30 | 31 | const TypeBase &get_type(const std::string &name) const { 32 | return m_types.at(name); 33 | } 34 | 35 | const FunctionType &get_function(const std::string &name) const { 36 | return m_functions.at(name); 37 | } 38 | 39 | private: 40 | std::hashmap m_types; 41 | std::hashmap m_functions; 42 | }; 43 | 44 | class ExecutorContext { 45 | public: 46 | ExecutorContext() {} 47 | virtual ~ExecutorContext() = default; 48 | 49 | void add_variable(const Variable &var) { 50 | m_variables.insert({var.name(), var}); 51 | } 52 | 53 | const Variable &get_variable(const std::string &name) const { 54 | return m_variables.at(name); 55 | } 56 | 57 | private: 58 | std::hashmap m_variables; 59 | }; 60 | 61 | } // namespace concepts 62 | -------------------------------------------------------------------------------- /concepts/cc/dsl/dsl_types.h: -------------------------------------------------------------------------------- 1 | /* 2 | * File : dsl_types.h 3 | * Author : Jiayuan Mao 4 | * Email : maojiayuan@gmail.com 5 | * Date : 09/09/2023 6 | * 7 | * This file is part of Project Concepts. 8 | * Distributed under terms of the MIT license. 9 | */ 10 | 11 | #pragma once 12 | 13 | #include 14 | 15 | namespace concepts { 16 | 17 | class TypeBase { 18 | public: 19 | TypeBase(const std::string &name) : m_name(name) {} 20 | virtual ~TypeBase() = default; 21 | 22 | const std::string &name() const { 23 | return m_name; 24 | } 25 | 26 | private: 27 | std::string m_name; 28 | }; 29 | 30 | class ObjectType: public TypeBase { 31 | }; 32 | 33 | class Variable { 34 | public: 35 | Variable(const std::string &name, const std::string &type) : m_name(name), m_type(type) {} 36 | 37 | const std::string &name() const { 38 | return m_name; 39 | } 40 | 41 | const std::string &type() const { 42 | return m_type; 43 | } 44 | 45 | private: 46 | std::string m_name; 47 | std::string m_type; 48 | }; 49 | 50 | class FunctionType { 51 | public: 52 | FunctionType(const std::string &return_type, const std::vector &arg_types) 53 | : m_return_type(return_type), m_arg_types(arg_types) {} 54 | virtual ~FunctionType() = default; 55 | 56 | const std::string &return_type() const { 57 | return m_return_type; 58 | } 59 | const std::vector &arg_types() const { 60 | return m_arg_types; 61 | } 62 | const std::string &arg_type(int i) const { 63 | return m_arg_types[i]; 64 | } 65 | 66 | private: 67 | std::string m_return_type; 68 | std::vector m_arg_types; 69 | }; 70 | 71 | class Function { 72 | public: 73 | Function(const std::string &name, const FunctionType &type) : m_name(name), m_type(type) {} 74 | virtual ~Function() = default; 75 | 76 | const std::string &name() const { 77 | return m_name; 78 | } 79 | 80 | const FunctionType &type() const { 81 | return m_type; 82 | } 83 | 84 | private: 85 | std::string m_name; 86 | FunctionType m_type; 87 | }; 88 | 89 | } // namespace concepts 90 | -------------------------------------------------------------------------------- /concepts/cc/main.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * File : main.cc 3 | * Author : Jiayuan Mao 4 | * Email : maojiayuan@gmail.com 5 | * Date : 09/09/2023 6 | * 7 | * Distributed under terms of the MIT license. 8 | */ 9 | 10 | #include 11 | 12 | #define STRINGIFY(x) #x 13 | #define MACRO_STRINGIFY(x) STRINGIFY(x) 14 | 15 | int add(int i, int j) { 16 | return i + j; 17 | } 18 | 19 | namespace py = pybind11; 20 | 21 | PYBIND11_MODULE(_C, m) { 22 | m.doc() = R"pbdoc( 23 | Pybind11 example plugin 24 | ----------------------- 25 | 26 | .. currentmodule:: concepts._C 27 | 28 | .. autosummary:: 29 | :toctree: _generate 30 | 31 | add 32 | subtract 33 | )pbdoc"; 34 | 35 | m.def("add", &add, R"pbdoc( 36 | Add two numbers 37 | )pbdoc"); 38 | 39 | m.def("subtract", [](int i, int j) { return i - j; }, R"pbdoc( 40 | Subtract two numbers 41 | )pbdoc"); 42 | 43 | #ifdef VERSION_INFO 44 | m.attr("__version__") = MACRO_STRINGIFY(VERSION_INFO); 45 | #else 46 | m.attr("__version__") = "dev"; 47 | #endif 48 | } 49 | 50 | -------------------------------------------------------------------------------- /concepts/dm/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 03/16/2024 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | """ 12 | Data structures for decision-making representation and algorithms. 13 | """ 14 | 15 | -------------------------------------------------------------------------------- /concepts/dm/crow/csp_solver/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 03/23/2024 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | -------------------------------------------------------------------------------- /concepts/dm/crow/executors/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 03/17/2024 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | -------------------------------------------------------------------------------- /concepts/dm/crow/interfaces/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 03/16/2024 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | -------------------------------------------------------------------------------- /concepts/dm/crow/parsers/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 03/16/2024 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | -------------------------------------------------------------------------------- /concepts/dm/crow/parsers/cdl-keywords1.txt: -------------------------------------------------------------------------------- 1 | achieve 2 | achieve_hold 3 | achieve_once 4 | action 5 | alternative 6 | assert 7 | assert_hold 8 | assert_once 9 | behavior 10 | bind 11 | body 12 | certifies 13 | commit 14 | controller 15 | critical 16 | def 17 | do 18 | domain 19 | eff 20 | else 21 | exists 22 | expr 23 | feature 24 | findall 25 | for 26 | forall 27 | foreach 28 | generator 29 | goal 30 | heuristic 31 | if 32 | in 33 | include 34 | init 35 | let 36 | local 37 | mem_query 38 | minimize 39 | objects 40 | out 41 | pass 42 | pragma 43 | pre 44 | preamble 45 | problem 46 | promotable 47 | return 48 | sequential 49 | typedef 50 | undirected_generator 51 | unordered 52 | untrack 53 | vector 54 | where 55 | while 56 | -------------------------------------------------------------------------------- /concepts/dm/crow/parsers/cdl-keywords2.txt: -------------------------------------------------------------------------------- 1 | False 2 | None 3 | True 4 | and 5 | bool 6 | float32 7 | int64 8 | not 9 | object 10 | or 11 | pyobject 12 | string -------------------------------------------------------------------------------- /concepts/dm/crow/parsers/cdl.vim: -------------------------------------------------------------------------------- 1 | " Vim syntax file 2 | " Language: CDL 3 | " Author: Jiayuan Mao 4 | " Description: Syntax highlighting for CDL 5 | " Usage: Put this file in ~/.vim/syntax/ and add the following line to ~/.vimrc: 6 | " au BufRead,BufNewFile *.cdl set filetype=cdl | set tabstop=2 shiftwidth=2 expandtab 7 | 8 | if exists("b:current_syntax") 9 | finish 10 | endif 11 | 12 | syn case match 13 | 14 | " Keywords 15 | syn keyword CDLKeyword #!pragma achieve achieve_hold achieve_once action alternative assert assert_hold assert_once behavior bind body certifies commit controller critical def do domain eff else exists expr feature findall for forall foreach generator goal heuristic include if in init let local mem_query minimize objects out pass pragma pre preamble problem promotable return sequential typedef undirected_generator unordered untrack vector where while 16 | 17 | syn keyword CDLSpecialKeyword False None True and bool float32 int64 not object or pyobject string 18 | 19 | " Numbers (integer and floating-point) 20 | syn match CDLNumber "\v\d+\.\d+|\d+" 21 | 22 | " Strings (double-quoted) 23 | syn match CDLString "\"[^\"]*\"" 24 | 25 | " Comments (starting with #) 26 | syn match CDLComment "#.*" 27 | 28 | " Highlighting groups 29 | hi def link CDLKeyword Keyword 30 | hi def link CDLSpecialKeyword Type 31 | hi def link CDLNumber Number 32 | hi def link CDLString String 33 | hi def link CDLComment Comment 34 | 35 | let b:current_syntax = "cdl" 36 | 37 | 38 | -------------------------------------------------------------------------------- /concepts/dm/crow/planners/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 03/16/2024 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | -------------------------------------------------------------------------------- /concepts/dm/crow/planners/priority_impl/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 08/25/2024 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | -------------------------------------------------------------------------------- /concepts/dm/crow/planners/regression_planning_impl/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 03/21/2024 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | -------------------------------------------------------------------------------- /concepts/dm/crowhat/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 03/23/2024 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | -------------------------------------------------------------------------------- /concepts/dm/crowhat/domains/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 03/27/2024 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | -------------------------------------------------------------------------------- /concepts/dm/crowhat/impl/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 08/28/2024 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | -------------------------------------------------------------------------------- /concepts/dm/crowhat/impl/franka/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/concepts-ai/Concepts/13847828a1ecb8f0d8c43a420a2a1ad234cfe242/concepts/dm/crowhat/impl/franka/__init__.py -------------------------------------------------------------------------------- /concepts/dm/crowhat/impl/franka/deoxys_crowhat_interface.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : deoxys_crowhat_interface.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 12/05/2024 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | -------------------------------------------------------------------------------- /concepts/dm/crowhat/impl/maniskill3/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/concepts-ai/Concepts/13847828a1ecb8f0d8c43a420a2a1ad234cfe242/concepts/dm/crowhat/impl/maniskill3/__init__.py -------------------------------------------------------------------------------- /concepts/dm/crowhat/impl/pybullet/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 03/27/2024 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | -------------------------------------------------------------------------------- /concepts/dm/crowhat/manipulation_utils/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 07/23/2024 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | -------------------------------------------------------------------------------- /concepts/dm/crowhat/world/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 08/28/2024 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | -------------------------------------------------------------------------------- /concepts/dm/pdsketch/crow/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 09/09/2023 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | # NB(Jiayuan Mao @ 2024/03/13): there is still some circular import issue, so we have to import the planner later. 12 | # from concepts.dm.pdsketch.crow.crow_planner_v2 import crow_recursive_v2 13 | # from concepts.dm.pdsketch.crow.crow_planner_execution import crow_recursive_simple_with_execution 14 | -------------------------------------------------------------------------------- /concepts/dm/pdsketch/crow/compat/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 03/12/2024 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | -------------------------------------------------------------------------------- /concepts/dm/pdsketch/csp_solvers/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 02/24/2022 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | """This module contains CSP solvers for PDSketch. 12 | These solvers will be primarily used in search-and-optimization problems in the task and motion planning problem, 13 | although some strategies and solvers can be used in general domains as well. 14 | 15 | Current solvers include: 16 | 17 | - Brute-force sampling-based CSP solver. See :mod:`concepts.dm.pdsketch.csp_solvers.brute_force_sampling`. 18 | - DPLL-sampling-based CSP solver (a generalization of the DPLL algorithm to mixed discrete-continuous CSPs). See :mod:`concepts.dm.pdsketch.csp_solvers.dpll_sampling`. 19 | """ 20 | 21 | from .dpll_sampling import csp_dpll_sampling_solve, csp_dpll_simplify 22 | 23 | -------------------------------------------------------------------------------- /concepts/dm/pdsketch/execution_utils.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : execution_utils.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 12/22/2023 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | """Utility functions for executing expressions for PDSketch.""" 12 | 13 | from concepts.dsl.dsl_types import QINDEX 14 | from concepts.dm.pdsketch.executor import PDSketchExecutor 15 | from concepts.dm.pdsketch.predicate import Predicate 16 | from concepts.dm.pdsketch.domain import State 17 | 18 | 19 | def recompute_state_variable_predicates_(executor: PDSketchExecutor, state: State): 20 | """Recompute the state variable predicates for a given state. 21 | 22 | Args: 23 | executor: the executor. 24 | state: the state. 25 | """ 26 | 27 | for predicate in executor.domain.functions.values(): 28 | predicate: Predicate 29 | if predicate.is_state_variable and not predicate.is_observation_variable: 30 | assert predicate.is_derived 31 | bounded_variables = {v: QINDEX for v in predicate.arguments} 32 | state.features[predicate.name] = executor.execute(predicate.derived_expression, state=state, bounded_variables=bounded_variables) 33 | 34 | 35 | def recompute_all_cacheable_predicates_(executor: PDSketchExecutor, state: State): 36 | """Recompute all cacheable predicates for a given state. 37 | 38 | Args: 39 | executor: the executor. 40 | state: the state. 41 | """ 42 | 43 | for predicate in executor.domain.functions.values(): 44 | predicate: Predicate 45 | if predicate.is_cacheable and predicate.is_derived and not predicate.is_state_variable: 46 | bounded_variables = {v: QINDEX for v in predicate.arguments} 47 | state.features[predicate.name] = executor.execute(predicate.derived_expression, state=state, bounded_variables=bounded_variables) 48 | 49 | -------------------------------------------------------------------------------- /concepts/dm/pdsketch/nn_learning/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 12/21/2023 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | -------------------------------------------------------------------------------- /concepts/dm/pdsketch/parsers/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 10/31/2022 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | -------------------------------------------------------------------------------- /concepts/dm/pdsketch/planners/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 11/17/2022 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | # from .discrete_search import validate_plan, brute_force_search 12 | # from .optimistic_search import construct_csp_from_optimistic_plan, solve_optimistic_plan, optimistic_search, optimistic_search_strips 13 | 14 | -------------------------------------------------------------------------------- /concepts/dm/pdsketch/planners/solution_score_tracker.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : solution_score_tracker.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 11/20/2022 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | """Utilities for PDSketch planners.""" 12 | 13 | from typing import Any 14 | 15 | __all__ = ['MostPromisingTrajectoryTracker'] 16 | 17 | 18 | class MostPromisingTrajectoryTracker(object): 19 | """This is a tracker for tracking the most promising next action, used in joint learning settings 20 | where we don't have knowledge about the actual transition function or the goal.""" 21 | 22 | def __init__(self, threshold: float): 23 | """Initialize the tracker. 24 | 25 | Args: 26 | threshold: the threshold for the score. 27 | """ 28 | 29 | self.threshold = threshold 30 | self.best_score = float('-inf') 31 | self.solution = None 32 | 33 | threshold: float 34 | """A score threshold.""" 35 | 36 | best_score: float 37 | """The best score achived so far.""" 38 | 39 | solution: Any 40 | """The solution associated with the `best_score`.""" 41 | 42 | def check(self, new_score: float) -> bool: 43 | """If the new score is better than the current best score, return True. 44 | 45 | Args: 46 | new_score: the new score. 47 | 48 | Returns: 49 | True if the new score is better than the current best score. 50 | """ 51 | return new_score > self.best_score 52 | 53 | def update(self, new_score: float, solution: Any): 54 | """Update the best score and the solution. 55 | 56 | Args: 57 | new_score: the new score. 58 | solution: the new solution. 59 | """ 60 | assert new_score > self.best_score 61 | self.best_score = new_score 62 | self.solution = solution 63 | 64 | -------------------------------------------------------------------------------- /concepts/dm/pdsketch/strips/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 03/19/2022 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | from .atomic_strips_domain import AtomicStripsOperator, AtomicStripsDomain, AtomicStripsOperatorApplier, AtomicStripsProblem, load_astrips_domain_file, load_astrips_domain_string, load_astrips_problem_file, load_astrips_problem_string 12 | from .strips_expression import * 13 | from .strips_grounded_expression import * 14 | from .strips_grounding import * 15 | from .strips_heuristics import * 16 | from .strips_search import * 17 | 18 | -------------------------------------------------------------------------------- /concepts/dsl/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 08/13/2022 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | """Basic data structures and utilities (e.g., parser, executor) for domain-specific languages.""" 12 | -------------------------------------------------------------------------------- /concepts/dsl/executors/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 10/25/2022 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | """The baseclass for all executors of domain-specific languages and a few implementations for simple function domains and tensor-based value representations.""" 12 | -------------------------------------------------------------------------------- /concepts/dsl/learning/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 12/10/2022 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | """Simple search-based algorithms for learning expressions in a DSL.""" 12 | 13 | -------------------------------------------------------------------------------- /concepts/dsl/parsers/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 10/25/2022 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | """Baseclass for all parsers of domain-specific languages and the implementation of a simple function domain parser.""" 12 | -------------------------------------------------------------------------------- /concepts/dsl/parsers/parser_base.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : parser_base.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 10/25/2022 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | """The baseclass for all parsers of domain-specific languages.""" 12 | 13 | from concepts.dsl.dsl_domain import DSLDomainBase 14 | from concepts.dsl.expression import Expression 15 | 16 | __all__ = ['ParserBase'] 17 | 18 | 19 | class ParserBase(object): 20 | """The baseclass for all parsers of domain-specific languages.""" 21 | 22 | def parse_domain_file(self, path: str) -> DSLDomainBase: 23 | """Parse a domain from a file. 24 | 25 | Args: 26 | path: the path to the file. 27 | 28 | Returns: 29 | the parsed domain. 30 | """ 31 | with open(path) as f: 32 | return self.parse_domain_string(f.read()) 33 | 34 | def parse_domain_string(self, string: str) -> DSLDomainBase: 35 | """Parse a domain from a string. 36 | 37 | Args: 38 | string: the string to parse. 39 | 40 | Returns: 41 | the parsed domain. 42 | """ 43 | raise NotImplementedError() 44 | 45 | def parse_expression(self, string: str, **kwargs) -> Expression: 46 | """Parse an expression from a string. 47 | 48 | Args: 49 | string: the string to parse. 50 | 51 | Returns: 52 | the parsed expression. 53 | """ 54 | raise NotImplementedError() 55 | 56 | -------------------------------------------------------------------------------- /concepts/gui/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 02/18/2024 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | -------------------------------------------------------------------------------- /concepts/gui/open3d_gui/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 09/13/2024 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | 12 | def pick_points(pcd): 13 | print("") 14 | print( 15 | "1) Please pick at least three correspondences using [shift + left click]" 16 | ) 17 | print(" Press [shift + right click] to undo point picking") 18 | print("2) After picking points, press 'Q' to close the window") 19 | vis = o3d.visualization.VisualizerWithEditing() 20 | vis.create_window() 21 | vis.add_geometry(pcd) 22 | vis.run() # user picks points 23 | vis.destroy_window() 24 | print("") 25 | return vis.get_picked_points() 26 | -------------------------------------------------------------------------------- /concepts/gui/open3d_gui/point_picker_3d.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : point_picker_3d.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 09/13/2024 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | import open3d as o3d 12 | 13 | __all__ = ['Open3DPointPicker', 'open3d_point_picker'] 14 | 15 | 16 | class Open3DPointPicker(object): 17 | def __init__(self): 18 | self.vis = o3d.visualization.VisualizerWithEditing() 19 | self.vis.create_window() 20 | self.registered_points = list() 21 | 22 | def run(self, geometry: o3d.geometry.PointCloud): 23 | self.print_help() 24 | self.vis.add_geometry(geometry) 25 | self.vis.run() 26 | self.vis.destroy_window() 27 | self.registered_points = self.vis.get_picked_points() 28 | return self.registered_points 29 | 30 | def print_help(self): 31 | print("") 32 | print('-' * 80) 33 | print("1) In order to pick a point, use [shift + left click]") 34 | print("2) To undo point picking, use [shift + right click]") 35 | print("3) After picking points, press 'q' to close the window") 36 | print('-' * 80) 37 | print("") 38 | 39 | 40 | def open3d_point_picker(pcd: o3d.geometry.PointCloud, **kwargs): 41 | picker = Open3DPointPicker() 42 | return picker.run(pcd, **kwargs) 43 | -------------------------------------------------------------------------------- /concepts/gui/opencv/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 02/21/2024 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | """A set of simple GUI tools using OpenCV. 12 | 13 | TODO:: 14 | 15 | - EllipsoidalSegmentationDrawer 16 | - Customized Text Visualizer 17 | """ -------------------------------------------------------------------------------- /concepts/gui/tk/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 04/29/2021 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | -------------------------------------------------------------------------------- /concepts/hw_interface/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 09/12/2022 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | """Interfaces for hardware devices such as robots and cameras.""" 12 | -------------------------------------------------------------------------------- /concepts/hw_interface/franka/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 09/11/2022 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | -------------------------------------------------------------------------------- /concepts/hw_interface/george_vision/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 08/05/2023 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | -------------------------------------------------------------------------------- /concepts/hw_interface/k4a/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 09/22/2024 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | -------------------------------------------------------------------------------- /concepts/hw_interface/rby1a/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 12/16/2024 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | -------------------------------------------------------------------------------- /concepts/hw_interface/rby1a/client_utils.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : client_utils.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 12/22/2024 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | 12 | -------------------------------------------------------------------------------- /concepts/hw_interface/realsense/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 09/12/2022 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | 12 | -------------------------------------------------------------------------------- /concepts/hw_interface/robot_state_visualizer/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 12/22/2024 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | -------------------------------------------------------------------------------- /concepts/language/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 08/13/2022 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | """Data structures for language semantics and tools for parsing. 12 | Most of this package are designed for neuro-symbolic representations of 13 | natrual language semantics and grammar-based language learning. 14 | 15 | See the following papers for more details: 16 | 17 | - The Neuro-Symbolic Concept Learner: Interpreting Scenes, Words, and Sentences From Natural Supervision (http://nscl.csail.mit.edu/) 18 | - Grammar-Based Grounded Lexicon Learning (https://g2l2.csail.mit.edu/) 19 | 20 | Here's a quick summary of the sub-modules: 21 | 22 | - :mod:`concepts.language.ccg` contains tools for parsing sentences with (purely symbolic) Combinatory Categorial Grammars (CCGs). 23 | """ 24 | -------------------------------------------------------------------------------- /concepts/language/ccg/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 01/04/2020 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | """Tools for parsing sentences with (purely symbolic) Combinatory Categorial Grammars.""" 12 | 13 | from . import learning 14 | from .composition import CCGCompositionDirection, CCGCompositionType, CCGCompositionContext, get_ccg_composition_context, CCGCompositionResult, CCGComposable, CCGCompositionSystem 15 | from .syntax import CCGSyntaxType, CCGPrimitiveSyntaxType, CCGConjSyntaxType, CCGComposedSyntaxType, CCGSyntaxSystem 16 | from .semantics import CCGSemanticsConjFunction, CCGSemanticsSimpleConjFunction, CCGSemanticsLazyValue, CCGSemantics 17 | from .grammar import Lexicon, LexiconUnion, CCGNode, compose_ccg_nodes, CCG 18 | 19 | __all__ = [ 20 | 'CCGCompositionDirection', 'CCGCompositionType', 21 | 'CCGCompositionContext', 'get_ccg_composition_context', 22 | 'CCGCompositionResult', 'CCGComposable', 23 | 'CCGCompositionSystem', 24 | 'CCGSyntaxType', 'CCGPrimitiveSyntaxType', 'CCGConjSyntaxType', 'CCGComposedSyntaxType', 25 | 'CCGSyntaxSystem', 26 | 'CCGSemanticsConjFunction', 'CCGSemanticsSimpleConjFunction', 27 | 'CCGSemanticsLazyValue', 'CCGSemantics', 28 | 'Lexicon', 'LexiconUnion', 'CCGNode', 'compose_ccg_nodes', 'CCG', 29 | 'learning' 30 | ] 31 | 32 | -------------------------------------------------------------------------------- /concepts/language/gpt_parsing/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 04/23/2023 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | -------------------------------------------------------------------------------- /concepts/language/gpt_parsing/prompts/gpt-35-turbo-chat-caption.txt: -------------------------------------------------------------------------------- 1 | Given a sentence, you need to output all the entities in the sentence and the relationship described in it. Be as comprehensive as possible. You need to use the following format: 2 | 3 | Given: A woman is playing the piano in the room. 4 | You should output: 5 | 6 | woman 7 | piano 8 | room 9 | womanpianoplay 10 | womanroomin 11 | pianoroomin 12 | -------------------------------------------------------------------------------- /concepts/language/gpt_parsing/utils.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : utils.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 04/23/2023 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | import re 12 | import os.path as osp 13 | from typing import Union, List, Dict 14 | 15 | 16 | class ParsingFailedError(Exception): 17 | pass 18 | 19 | 20 | def load_prompt(identifier) -> List[Dict[str, str]]: 21 | prompt_filename = osp.join(osp.dirname(__file__), 'prompts', identifier + '.txt') 22 | with open(prompt_filename, 'r') as f: 23 | content = f.read() 24 | return [ 25 | {'role': 'system', 'content': content}, 26 | ] 27 | 28 | 29 | class TagNotUniqueError(ParsingFailedError): 30 | pass 31 | 32 | 33 | def extract_tag(content: str, tag: str, unique: bool = False) -> Union[str, List[str]]: 34 | """Extract all matched content inside . 35 | 36 | Args: 37 | content: the input string. 38 | tag: the tag name. 39 | unique: if True, only return the first matched content and raises an error. 40 | """ 41 | 42 | pattern = r'<{}>(.*?)'.format(tag, tag) 43 | matches = re.findall(pattern, content, re.DOTALL) 44 | 45 | if unique: 46 | if len(matches) != 1: 47 | raise TagNotUniqueError('Tag "{}" is not unique. Content: {}'.format(tag, content)) 48 | return matches[0] 49 | else: 50 | return matches 51 | 52 | -------------------------------------------------------------------------------- /concepts/language/gpt_vlm_query/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 09/12/2024 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | -------------------------------------------------------------------------------- /concepts/language/neural_ccg/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 12/07/2022 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | """Data structures and algorithms for Neural CCG. 12 | This module is the core of paper [Grammar-Based Grounded Lexicon Learning](https://arxiv.org/abs/2202.08806). 13 | 14 | See the documentation for file ``grammar.py`` for more details. 15 | """ 16 | -------------------------------------------------------------------------------- /concepts/language/openai_utils/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 08/21/2024 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | -------------------------------------------------------------------------------- /concepts/language/openai_utils/default_client.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : default_client.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 08/21/2024 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | import os 12 | import openai 13 | 14 | __all__ = ['get_default_client', 'get_default_chat_model', 'set_default_chat_model'] 15 | 16 | 17 | _DEFAULT_CLIENT = None 18 | 19 | 20 | def get_default_client(): 21 | global _DEFAULT_CLIENT 22 | if _DEFAULT_CLIENT is None: 23 | if 'OPENAI_API_KEY' not in os.environ: 24 | raise ValueError('Please set the OPENAI_API_KEY environment variable') 25 | 26 | if 'OPENAI_ORGANIZATION_KEY' in os.environ: 27 | _DEFAULT_CLIENT = openai.OpenAI( 28 | organization=os.environ['OPENAI_ORGANIZATION_KEY'], 29 | project=os.environ.get('OPENAI_PROJECT_KEY', None), 30 | api_key=os.environ['OPENAI_API_KEY'] 31 | ) 32 | else: 33 | _DEFAULT_CLIENT = openai.OpenAI() 34 | return _DEFAULT_CLIENT 35 | 36 | 37 | _DEFAULT_CHAT_MODEL = "gpt-3.5-turbo" 38 | 39 | 40 | def get_default_chat_model(): 41 | return _DEFAULT_CHAT_MODEL 42 | 43 | 44 | def set_default_chat_model(model): 45 | global _DEFAULT_CHAT_MODEL 46 | _DEFAULT_CHAT_MODEL = model 47 | -------------------------------------------------------------------------------- /concepts/math/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 02/18/2024 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | -------------------------------------------------------------------------------- /concepts/math/cad/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 08/01/2024 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | -------------------------------------------------------------------------------- /concepts/nn/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 08/13/2022 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | """Neural network modules that are used in concept learning, such as logic rule modules.""" 12 | -------------------------------------------------------------------------------- /concepts/pdsketch/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 01/25/2022 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | """Data structures and algorithms for model learning and task and motion planning. 12 | 13 | The PDSketch is a sketch extension of PDDL. 14 | """ 15 | 16 | __all__ = [ 17 | 'Predicate', 'flatten_expression', 'get_used_state_variables', 18 | 'Precondition', 'Effect', 'Operator', 'OperatorApplier', 'gen_all_grounded_actions', 'gen_all_partially_grounded_actions', 19 | 'Domain', 'Problem', 'State', 20 | 'load_domain_file', 'load_domain_string', 'load_problem_file', 'load_problem_string', 'parse_expression', 21 | 'PDSketchExecutor', 'config_function_implementation', 'StateDefinitionHelper', 22 | 'csp_solvers', 'planners', 'strips' 23 | ] 24 | 25 | from .predicate import Predicate, flatten_expression, get_used_state_variables 26 | from .operator import Precondition, Effect, Operator, OperatorApplier, gen_all_grounded_actions, gen_all_partially_grounded_actions 27 | from .domain import Domain, Problem, State 28 | from .parsers.pdsketch_parser import PDSketchParser, load_domain_file, load_domain_string, load_problem_file, load_problem_string, parse_expression 29 | from .executor import PDSketchExecutor, config_function_implementation, StateDefinitionHelper, GeneratorManager 30 | from .simulator_interface import PDSketchSimulatorInterface 31 | 32 | from . import csp_solvers 33 | from . import planners 34 | from . import strips 35 | 36 | # from .value import * 37 | # from .optimistic import * 38 | # from .state import * 39 | # from .expr import * 40 | # from .operator import * 41 | # from .domain import * 42 | # from .session import * 43 | # from .ao_discretization import * 44 | # 45 | # from .parser import * 46 | # from .planners import * 47 | # from .csp_solvers import * 48 | # 49 | # from . import strips 50 | # from . import nn 51 | # from . import rl 52 | -------------------------------------------------------------------------------- /concepts/pdsketch/csp_solvers/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 02/24/2022 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | """This module contains CSP solvers for PDSketch. 12 | These solvers will be primarily used in search-and-optimization problems in the task and motion planning problem, 13 | although some strategies and solvers can be used in general domains as well. 14 | 15 | Current solvers include: 16 | 17 | - Brute-force sampling-based CSP solver. See :mod:`concepts.pdsketch.csp_solvers.brute_force_sampling`. 18 | - DPLL-sampling-based CSP solver (a generalization of the DPLL algorithm to mixed discrete-continuous CSPs). See :mod:`concepts.pdsketch.csp_solvers.dpll_sampling`. 19 | """ 20 | 21 | from .dpll_sampling import csp_dpll_sampling_solve, csp_dpll_simplify 22 | 23 | -------------------------------------------------------------------------------- /concepts/pdsketch/parsers/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 10/31/2022 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | -------------------------------------------------------------------------------- /concepts/pdsketch/planners/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 11/17/2022 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | # from .discrete_search import validate_plan, brute_force_search 12 | # from .optimistic_search import construct_csp_from_optimistic_plan, solve_optimistic_plan, optimistic_search, optimistic_search_strips 13 | 14 | -------------------------------------------------------------------------------- /concepts/pdsketch/planners/regression/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 09/09/2023 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | -------------------------------------------------------------------------------- /concepts/pdsketch/planners/search_utils.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : search_utils.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 11/20/2022 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | """Utilities for PDSketch planners.""" 12 | 13 | from typing import Any 14 | 15 | __all__ = ['MostPromisingTrajectoryTracker'] 16 | 17 | 18 | class MostPromisingTrajectoryTracker(object): 19 | """This is a tracker for tracking the most promising next action, used in joint learning settings 20 | where we don't have a knowledge about the actual transition function or the goal.""" 21 | 22 | def __init__(self, threshold: float): 23 | """Initialize the tracker. 24 | 25 | Args: 26 | threshold: the threshold for the score. 27 | """ 28 | 29 | self.threshold = threshold 30 | self.best_score = float('-inf') 31 | self.solution = None 32 | 33 | threshold: float 34 | """A score threshold.""" 35 | 36 | best_score: float 37 | """The best score achived so far.""" 38 | 39 | solution: Any 40 | """The solution associated with the `best_score`.""" 41 | 42 | def check(self, new_score: float) -> bool: 43 | """If the new score is better than the current best score, return True. 44 | 45 | Args: 46 | new_score: the new score. 47 | 48 | Returns: 49 | True if the new score is better than the current best score. 50 | """ 51 | return new_score > self.best_score 52 | 53 | def update(self, new_score: float, solution: Any): 54 | """Update the best score and the solution. 55 | 56 | Args: 57 | new_score: the new score. 58 | solution: the new solution. 59 | """ 60 | assert new_score > self.best_score 61 | self.best_score = new_score 62 | self.solution = solution 63 | 64 | -------------------------------------------------------------------------------- /concepts/pdsketch/strips/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 03/19/2022 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | from .atomic_strips_domain import AtomicStripsOperator, AtomicStripsDomain, AtomicStripsOperatorApplier, AtomicStripsProblem, load_astrips_domain_file, load_astrips_domain_string, load_astrips_problem_file, load_astrips_problem_string 12 | from .strips_expression import * 13 | from .strips_grounded_expression import * 14 | from .strips_grounding import * 15 | from .strips_heuristics import * 16 | from .strips_search import * 17 | 18 | -------------------------------------------------------------------------------- /concepts/sandbox/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 06/12/2023 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | -------------------------------------------------------------------------------- /concepts/simulator/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 12/14/2022 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | -------------------------------------------------------------------------------- /concepts/simulator/blender/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 01/25/2024 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | -------------------------------------------------------------------------------- /concepts/simulator/cad_asset_utils/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 08/01/2024 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | -------------------------------------------------------------------------------- /concepts/simulator/cad_asset_utils/assets_base.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : assets_base.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 08/01/2024 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | import os.path as osp 12 | 13 | from concepts.simulator.urdf_utils.obj2urdf import ObjectUrdfBuilder 14 | 15 | 16 | class CADAssetCollection(object): 17 | def get_concepts_assets_path(self) -> str: 18 | return osp.abspath(osp.join(osp.dirname(__file__), '..', '..', 'assets')) 19 | 20 | def get_assets_path(self, *subpath) -> str: 21 | return osp.join(self.get_concepts_assets_path(), *subpath) 22 | 23 | def make_urdf_builder(self, object_dir: str) -> ObjectUrdfBuilder: 24 | return ObjectUrdfBuilder(object_dir) 25 | -------------------------------------------------------------------------------- /concepts/simulator/ikfast/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 07/10/2023 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | -------------------------------------------------------------------------------- /concepts/simulator/ikfast/compile.py: -------------------------------------------------------------------------------- 1 | import fnmatch 2 | import importlib 3 | import os 4 | import shutil 5 | 6 | from distutils.core import setup 7 | from distutils.dir_util import copy_tree 8 | from distutils.extension import Extension 9 | 10 | # Build C++ extension by running: 'python setup.py build' 11 | # see: https://docs.python.org/3/extending/building.html 12 | 13 | # http://openrave.org/docs/0.8.2/openravepy/ikfast/ 14 | # https://github.com/rdiankov/openrave/blob/master/python/ikfast.py#L92 15 | # http://wiki.ros.org/Industrial/Tutorials/Create_a_Fast_IK_Solution 16 | 17 | # Yijiang 18 | # https://github.com/yijiangh/ikfast_pybind 19 | # https://github.com/yijiangh/conrob_pybullet/tree/master/utils/ikfast 20 | # https://github.com/yijiangh/choreo/blob/bc777069b8eb7283c74af26e5461532aec3d9e8a/framefab_robot/abb/framefab_irb6600/framefab_irb6600_support/doc/ikfast_tutorial.rst 21 | 22 | 23 | def compile_ikfast(module_name, cpp_filename, remove_build=False, link_lapack=False): 24 | ikfast_module = Extension(module_name, sources=[cpp_filename], extra_link_args=['-llapack'] if link_lapack else []) 25 | setup( 26 | name=module_name, 27 | version='1.0', 28 | description="ikfast module {}".format(module_name), 29 | ext_modules=[ikfast_module], 30 | script_args=['build'], 31 | ) 32 | 33 | build_lib_path = None 34 | for root, dirnames, filenames in os.walk(os.getcwd()): 35 | if fnmatch.fnmatch(root, os.path.join(os.getcwd(), "*build", "lib*")): 36 | build_lib_path = root 37 | break 38 | 39 | assert build_lib_path is not None 40 | 41 | copy_tree(build_lib_path, os.getcwd()) 42 | if remove_build: 43 | # TODO: error when compiling multiple arms for python2 44 | # 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' 45 | shutil.rmtree(os.path.join(os.getcwd(), 'build')) 46 | 47 | try: 48 | importlib.import_module(module_name) 49 | print('\nikfast module {} imported successful'.format(module_name)) 50 | except ImportError as e: 51 | print('\nikfast module {} imported failed'.format(module_name)) 52 | raise e 53 | 54 | return True 55 | 56 | -------------------------------------------------------------------------------- /concepts/simulator/ikfast/franka_panda/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 12/24/2022 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | from jacinle.jit.cext import auto_travis 12 | 13 | auto_travis(__file__, required_imports=['ikfast_panda_arm']) 14 | -------------------------------------------------------------------------------- /concepts/simulator/ikfast/franka_panda/setup.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : setup.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 12/24/2022 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | from concepts.simulator.ikfast.compile import compile_ikfast 12 | 13 | 14 | def main(): 15 | robot_name = 'panda_arm' 16 | compile_ikfast( 17 | module_name='ikfast_{}'.format(robot_name), 18 | cpp_filename='ikfast_{}.cpp'.format(robot_name), 19 | remove_build=True 20 | ) 21 | 22 | 23 | if __name__ == '__main__': 24 | main() 25 | 26 | -------------------------------------------------------------------------------- /concepts/simulator/ikfast/franka_panda/travis.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | # 3 | # travis.sh 4 | # Copyright (C) 2023 Jiayuan Mao 5 | # 6 | # Distributed under terms of the MIT license. 7 | # 8 | 9 | python3 setup.py 10 | 11 | -------------------------------------------------------------------------------- /concepts/simulator/ikfast/quickaccess.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : quickaccess.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 09/11/2024 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | import numpy as np 12 | import concepts.simulator.ikfast.franka_panda.ikfast_panda_arm as ikfast_module 13 | from concepts.simulator.ikfast.ikfast_common import IKFastWrapperBase 14 | from concepts.math.rotationlib_xyzw import quat_mul 15 | from concepts.math.frame_utils_xyzw import compose_transformation 16 | 17 | 18 | def get_franka_panda_ikfast(): 19 | ikfast_wrapper = IKFastWrapperBase( 20 | ikfast_module, 21 | joint_ids=[0, 1, 2, 3, 4, 5, 6], free_joint_ids=[6], use_xyzw=True, 22 | joints_lower=[-2.8973, -1.7628, -2.8973, -3.0718, -2.8973, -0.0175,-2.8973], 23 | joints_upper=[2.8963, 1.7628, 2.8973, -0.0698, 2.8973, 3.7525, 2.8973] 24 | ) 25 | return ikfast_wrapper 26 | 27 | 28 | def franka_panda_fk(wrapper: IKFastWrapperBase, q: np.ndarray, link_id: int = 8): 29 | pos, quat = wrapper.fk(q) 30 | if link_id == 8: 31 | pos, quat = np.array(pos), np.array(quat) 32 | dq = [0.00000000, 0.00000000, 0.38268343, -0.92387953] 33 | quat = quat_mul(quat, dq) 34 | return pos, quat 35 | elif link_id == 11: 36 | pos, quat = np.array(pos), np.array(quat) 37 | dp = [0, 0, 0.1] 38 | dq = [0.0, 0.0, 0.9238795325108381, 0.38268343236617297] 39 | return compose_transformation(pos, quat, dp, dq) 40 | else: 41 | raise ValueError(f'Unsupported link id: {link_id}') 42 | -------------------------------------------------------------------------------- /concepts/simulator/ikfast/ur5/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 12/24/2022 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | from jacinle.jit.cext import auto_travis 12 | 13 | auto_travis(__file__, required_imports=['ikfast_ur5']) 14 | -------------------------------------------------------------------------------- /concepts/simulator/ikfast/ur5/setup.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : setup.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 12/24/2022 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | from concepts.simulator.ikfast.compile import compile_ikfast 12 | 13 | 14 | def main(): 15 | robot_name = 'ur5' 16 | compile_ikfast( 17 | module_name='ikfast_{}'.format(robot_name), 18 | cpp_filename='ikfast_{}.cpp'.format(robot_name), 19 | remove_build=True, 20 | link_lapack=True 21 | ) 22 | 23 | 24 | if __name__ == '__main__': 25 | main() 26 | 27 | -------------------------------------------------------------------------------- /concepts/simulator/ikfast/ur5/travis.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | # 3 | # travis.sh 4 | # Copyright (C) 2023 Jiayuan Mao 5 | # 6 | # Distributed under terms of the MIT license. 7 | # 8 | 9 | python3 setup.py 10 | 11 | -------------------------------------------------------------------------------- /concepts/simulator/mplib/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 01/09/2025 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | -------------------------------------------------------------------------------- /concepts/simulator/pybullet/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 07/10/2023 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | -------------------------------------------------------------------------------- /concepts/simulator/pybullet/components/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 07/10/2023 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | -------------------------------------------------------------------------------- /concepts/simulator/pybullet/components/asset_libraries/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 01/10/2024 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | -------------------------------------------------------------------------------- /concepts/simulator/pybullet/components/asset_libraries/igibson.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : igibson.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 01/10/2024 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | # Implement IGibsonAssetLibrary 12 | -------------------------------------------------------------------------------- /concepts/simulator/pybullet/components/asset_libraries/shapenet.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : shapenet.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 01/10/2024 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | from typing import Optional 12 | 13 | from concepts.simulator.cad_asset_utils.shapenet import ShapeNetCoreCollection 14 | from concepts.simulator.pybullet.client import BulletClient 15 | from concepts.utils.typing_utils import Vec3f, Vec4f 16 | 17 | 18 | class ShapeNetCoreLoader(object): 19 | def __init__(self, client: BulletClient, shapenet_root: str): 20 | self.client = client 21 | self.asset_collection = ShapeNetCoreCollection(shapenet_root) 22 | 23 | def load_urdf( 24 | self, synset_identifier: str, model_identifier: str, location_3d: Vec3f, scale: float = 1.0, name: Optional[str] = None, *, 25 | static: bool = False, quat: Vec4f = (0, 0, 0, 1) 26 | ): 27 | urdf_file = self.asset_collection.get_urdf(synset_identifier, model_identifier) 28 | if name is None: 29 | name = synset_identifier 30 | 31 | return self.client.load_urdf(urdf_file, location_3d, quat, body_name=name, scale=scale, static=static) 32 | 33 | -------------------------------------------------------------------------------- /concepts/simulator/pybullet/components/component_base.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : component_base.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 08/24/2022 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | from concepts.simulator.pybullet.client import BulletClient 12 | 13 | 14 | class BulletComponent(object): 15 | def __init__(self, client: BulletClient): 16 | self.client = client 17 | 18 | @property 19 | def p(self): 20 | return self.client.p 21 | 22 | @property 23 | def world(self): 24 | return self.client.w 25 | 26 | @property 27 | def w(self): 28 | return self.client.w 29 | 30 | -------------------------------------------------------------------------------- /concepts/simulator/pybullet/components/panda/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 08/23/2022 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | 12 | -------------------------------------------------------------------------------- /concepts/simulator/pybullet/components/rby1a/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 12/17/2024 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | -------------------------------------------------------------------------------- /concepts/simulator/pybullet/components/ur5/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 08/23/2022 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | 12 | -------------------------------------------------------------------------------- /concepts/simulator/pybullet/cspace.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : cspace.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 02/17/2020 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | import numpy as np 12 | import contextlib 13 | from typing import List 14 | 15 | from concepts.simulator.pybullet.client import BulletClient 16 | 17 | __all__ = ['BulletConfigurationSpace'] 18 | 19 | 20 | class BulletConfigurationSpace(object): 21 | def __init__(self, client: BulletClient, cspace_names: List[str]): 22 | self.client = client 23 | self.cspace_names = cspace_names 24 | 25 | @property 26 | def world(self): 27 | return self.client.world 28 | 29 | def get_qpos(self): 30 | return np.array([self.world.get_qpos(name) for name in self.cspace_names]) 31 | 32 | def set_qpos(self, qpos, forward=False): 33 | for name, v in zip(self.cspace_names, qpos): 34 | self.world.set_qpos(name, v) 35 | if forward: 36 | self.client.p.stepSimulation() 37 | 38 | @contextlib.contextmanager 39 | def qpos_context(self, forward=False): 40 | backup = self.get_qpos() 41 | yield 42 | self.set_qpos(backup, forward=forward) 43 | 44 | def get_xpos(self, name, type=None): 45 | return self.world.get_xpos(name, type=type) 46 | 47 | def get_xquat(self, name, type=None): 48 | return self.world.get_xquat(name, type=type) 49 | 50 | def get_xmat(self, name, type=None): 51 | return self.world.get_xmat(name, type=type) 52 | 53 | def fk(self, end_effector_name, qpos): 54 | with self.qpos_context(): 55 | self.set_qpos(qpos) 56 | return self.get_xpos(end_effector_name), self.get_xmat(end_effector_name) 57 | 58 | def ik(self, end_effector_name, goal_xpos, goal_xquat=None): 59 | raise NotImplementedError() 60 | 61 | def get_collisions(self, qpos): 62 | raise NotImplementedError() 63 | 64 | -------------------------------------------------------------------------------- /concepts/simulator/pybullet/ikfast/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 07/10/2023 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | -------------------------------------------------------------------------------- /concepts/simulator/pybullet/ikfast/compile.py: -------------------------------------------------------------------------------- 1 | import fnmatch 2 | import importlib 3 | import os 4 | import shutil 5 | 6 | from distutils.core import setup 7 | from distutils.dir_util import copy_tree 8 | from distutils.extension import Extension 9 | 10 | # Build C++ extension by running: 'python setup.py build' 11 | # see: https://docs.python.org/3/extending/building.html 12 | 13 | # http://openrave.org/docs/0.8.2/openravepy/ikfast/ 14 | # https://github.com/rdiankov/openrave/blob/master/python/ikfast.py#L92 15 | # http://wiki.ros.org/Industrial/Tutorials/Create_a_Fast_IK_Solution 16 | 17 | # Yijiang 18 | # https://github.com/yijiangh/ikfast_pybind 19 | # https://github.com/yijiangh/conrob_pybullet/tree/master/utils/ikfast 20 | # https://github.com/yijiangh/choreo/blob/bc777069b8eb7283c74af26e5461532aec3d9e8a/framefab_robot/abb/framefab_irb6600/framefab_irb6600_support/doc/ikfast_tutorial.rst 21 | 22 | 23 | def compile_ikfast(module_name, cpp_filename, remove_build=False, link_lapack=False): 24 | ikfast_module = Extension(module_name, sources=[cpp_filename], extra_link_args=['-llapack'] if link_lapack else []) 25 | setup( 26 | name=module_name, 27 | version='1.0', 28 | description="ikfast module {}".format(module_name), 29 | ext_modules=[ikfast_module], 30 | script_args=['build'], 31 | ) 32 | 33 | build_lib_path = None 34 | for root, dirnames, filenames in os.walk(os.getcwd()): 35 | if fnmatch.fnmatch(root, os.path.join(os.getcwd(), "*build", "lib*")): 36 | build_lib_path = root 37 | break 38 | 39 | assert build_lib_path is not None 40 | 41 | copy_tree(build_lib_path, os.getcwd()) 42 | if remove_build: 43 | # TODO: error when compiling multiple arms for python2 44 | # 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' 45 | shutil.rmtree(os.path.join(os.getcwd(), 'build')) 46 | 47 | try: 48 | importlib.import_module(module_name) 49 | print('\nikfast module {} imported successful'.format(module_name)) 50 | except ImportError as e: 51 | print('\nikfast module {} imported failed'.format(module_name)) 52 | raise e 53 | 54 | return True 55 | 56 | -------------------------------------------------------------------------------- /concepts/simulator/pybullet/ikfast/franka_panda/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 12/24/2022 7 | # 8 | # This file is part of HACL-PyTorch. 9 | # Distributed under terms of the MIT license. 10 | 11 | from jacinle.jit.cext import auto_travis 12 | 13 | auto_travis(__file__, required_imports=['ikfast_panda_arm']) 14 | -------------------------------------------------------------------------------- /concepts/simulator/pybullet/ikfast/franka_panda/setup.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : setup.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 12/24/2022 7 | # 8 | # This file is part of HACL-PyTorch. 9 | # Distributed under terms of the MIT license. 10 | 11 | from concepts.simulator.pybullet.ikfast.compile import compile_ikfast 12 | 13 | 14 | def main(): 15 | robot_name = 'panda_arm' 16 | compile_ikfast( 17 | module_name='ikfast_{}'.format(robot_name), 18 | cpp_filename='ikfast_{}.cpp'.format(robot_name), 19 | remove_build=True 20 | ) 21 | 22 | 23 | if __name__ == '__main__': 24 | main() 25 | 26 | -------------------------------------------------------------------------------- /concepts/simulator/pybullet/ikfast/franka_panda/travis.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | # 3 | # travis.sh 4 | # Copyright (C) 2023 Jiayuan Mao 5 | # 6 | # Distributed under terms of the MIT license. 7 | # 8 | 9 | python3 setup.py 10 | 11 | -------------------------------------------------------------------------------- /concepts/simulator/pybullet/ikfast/ur5/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 12/24/2022 7 | # 8 | # This file is part of HACL-PyTorch. 9 | # Distributed under terms of the MIT license. 10 | 11 | from jacinle.jit.cext import auto_travis 12 | 13 | auto_travis(__file__, required_imports=['ikfast_ur5']) 14 | -------------------------------------------------------------------------------- /concepts/simulator/pybullet/ikfast/ur5/setup.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : setup.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 12/24/2022 7 | # 8 | # This file is part of HACL-PyTorch. 9 | # Distributed under terms of the MIT license. 10 | 11 | from concepts.simulator.pybullet.ikfast.compile import compile_ikfast 12 | 13 | 14 | def main(): 15 | robot_name = 'ur5' 16 | compile_ikfast( 17 | module_name='ikfast_{}'.format(robot_name), 18 | cpp_filename='ikfast_{}.cpp'.format(robot_name), 19 | remove_build=True, 20 | link_lapack=True 21 | ) 22 | 23 | 24 | if __name__ == '__main__': 25 | main() 26 | 27 | -------------------------------------------------------------------------------- /concepts/simulator/pybullet/ikfast/ur5/travis.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | # 3 | # travis.sh 4 | # Copyright (C) 2023 Jiayuan Mao 5 | # 6 | # Distributed under terms of the MIT license. 7 | # 8 | 9 | python3 setup.py 10 | 11 | -------------------------------------------------------------------------------- /concepts/simulator/pybullet/manipulation_utils/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 08/25/2022 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | 12 | -------------------------------------------------------------------------------- /concepts/simulator/pybullet/pybullet_ikfast_utils.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : pybullet_ikfast_utils.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 07/04/2024 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | import numpy as np 12 | from typing import List 13 | 14 | from concepts.simulator.pybullet.world import BulletWorld 15 | from concepts.simulator.ikfast.ikfast_common import IKFastWrapperBase 16 | 17 | 18 | class IKFastPyBulletWrapper(IKFastWrapperBase): 19 | def __init__( 20 | self, 21 | world: BulletWorld, module, 22 | body_id, joint_ids: List[int], free_joint_ids: List[int] = tuple(), 23 | use_xyzw: bool = True, # PyBullet uses xyzw. 24 | max_attempts: int = 1000, 25 | fix_free_joint_positions: bool = False, 26 | shuffle_solutions: bool = False, 27 | sort_closest_solution: bool = False 28 | ): 29 | self.world = world 30 | self.module = module 31 | self.body_id = body_id 32 | 33 | joint_info = [self.world.get_joint_info_by_id(self.body_id, joint_id) for joint_id in joint_ids] 34 | joints_lower = np.array([info.joint_lower_limit for info in joint_info]) 35 | joints_upper = np.array([info.joint_upper_limit for info in joint_info]) 36 | 37 | super().__init__( 38 | module, joint_ids, free_joint_ids, 39 | joints_lower, joints_upper, 40 | use_xyzw, max_attempts, 41 | fix_free_joint_positions, shuffle_solutions, sort_closest_solution 42 | ) 43 | 44 | # assert len(self.free_joint_ids) + 6 == len(self.joint_ids) 45 | 46 | def get_current_joint_positions(self) -> np.ndarray: 47 | return np.array([self.world.get_joint_state_by_id(self.body_id, joint_id).position for joint_id in self.joint_ids]) 48 | 49 | def get_current_free_joint_positions(self) -> np.ndarray: 50 | return np.array([self.world.get_joint_state_by_id(self.body_id, joint_id).position for joint_id in self.free_joint_ids]) 51 | -------------------------------------------------------------------------------- /concepts/simulator/pybullet/urdf_utils/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 07/10/2023 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | -------------------------------------------------------------------------------- /concepts/simulator/pybullet/urdf_utils/urdf_prototype.urdf: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /concepts/simulator/pymunk/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 06/21/2022 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | 12 | -------------------------------------------------------------------------------- /concepts/simulator/pymunk/constants.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : constants.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 06/21/2022 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | """Constants for pymunk. 12 | 13 | The following is a table of the constants defined in pymunk. 14 | 15 | .. csv-table:: 16 | :header: "Name", "Value", "Description" 17 | 18 | "color_consts.RED", "255, 32, 32, 255", "Red color." 19 | "color_consts.BLACK", "0, 0, 0, 255", "Black color." 20 | "color_consts.BLUE", "32, 128, 255, 255", "Blue color." 21 | """ 22 | 23 | import argparse 24 | 25 | color_consts = argparse.Namespace() 26 | color_consts.RED = (255, 32, 32, 255) 27 | color_consts.BLACK = (0, 0, 0, 255) 28 | color_consts.BLUE = (32, 128, 255, 255) 29 | color_consts.GRAY = (128, 128, 128, 255) 30 | 31 | -------------------------------------------------------------------------------- /concepts/simulator/sapien/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 07/29/2024 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | -------------------------------------------------------------------------------- /concepts/simulator/sapien/controllers/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 07/29/2024 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | -------------------------------------------------------------------------------- /concepts/simulator/sapien/manipulation_utils/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 07/29/2024 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | -------------------------------------------------------------------------------- /concepts/simulator/sapien2/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 07/29/2024 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | -------------------------------------------------------------------------------- /concepts/simulator/sapien2/controllers/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 07/29/2024 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | -------------------------------------------------------------------------------- /concepts/simulator/sapien2/manipulation_utils/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 07/29/2024 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | -------------------------------------------------------------------------------- /concepts/simulator/shapely_kinematics/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 05/28/2024 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | -------------------------------------------------------------------------------- /concepts/simulator/tk/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 04/29/2021 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | -------------------------------------------------------------------------------- /concepts/simulator/tracik_utils/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 12/19/2024 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | -------------------------------------------------------------------------------- /concepts/simulator/urdf_utils/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 07/10/2023 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | -------------------------------------------------------------------------------- /concepts/simulator/urdf_utils/urdf_prototype.urdf: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /concepts/utils/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 10/25/2022 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | -------------------------------------------------------------------------------- /concepts/vision/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 07/31/2024 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | """Data structures and algorithms for computer vision.""" -------------------------------------------------------------------------------- /concepts/vision/depth_smoother/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 07/31/2024 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | -------------------------------------------------------------------------------- /concepts/vision/fm_match/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 09/14/2024 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | -------------------------------------------------------------------------------- /concepts/vision/fm_match/diff3f/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 09/15/2024 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | -------------------------------------------------------------------------------- /concepts/vision/fm_match/dino/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/concepts-ai/Concepts/13847828a1ecb8f0d8c43a420a2a1ad234cfe242/concepts/vision/fm_match/dino/__init__.py -------------------------------------------------------------------------------- /concepts/vision/franka_system_calibration/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 09/01/2024 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | -------------------------------------------------------------------------------- /concepts/vision/george_vision_pipeline/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 08/05/2023 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | -------------------------------------------------------------------------------- /concepts/vision/shared/__init__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : __init__.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 08/05/2024 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | -------------------------------------------------------------------------------- /docs/.gitignore: -------------------------------------------------------------------------------- 1 | build/ 2 | source/reference/ 3 | -------------------------------------------------------------------------------- /docs/Makefile: -------------------------------------------------------------------------------- 1 | # Minimal makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line, and also 5 | # from the environment for the first two. 6 | SPHINXOPTS ?= 7 | SPHINXBUILD ?= sphinx-build 8 | SOURCEDIR = source 9 | BUILDDIR = build 10 | 11 | # Put it first so that "make" without argument is like "make help". 12 | help: 13 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 14 | 15 | .PHONY: clean help Makefile 16 | 17 | clean: 18 | rm -rf $(SOURCEDIR)/reference 19 | rm -rf $(BUILDDIR)/html/* 20 | 21 | # Catch-all target: route all unknown targets to Sphinx using the new 22 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). 23 | %: Makefile 24 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 25 | rsync -aP $(BUILDDIR)/html droplet.jiayuanm.com:~/concepts_docs/ 26 | -------------------------------------------------------------------------------- /docs/make.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | pushd %~dp0 4 | 5 | REM Command file for Sphinx documentation 6 | 7 | if "%SPHINXBUILD%" == "" ( 8 | set SPHINXBUILD=sphinx-build 9 | ) 10 | set SOURCEDIR=source 11 | set BUILDDIR=build 12 | 13 | %SPHINXBUILD% >NUL 2>NUL 14 | if errorlevel 9009 ( 15 | echo. 16 | echo.The 'sphinx-build' command was not found. Make sure you have Sphinx 17 | echo.installed, then set the SPHINXBUILD environment variable to point 18 | echo.to the full path of the 'sphinx-build' executable. Alternatively you 19 | echo.may add the Sphinx directory to PATH. 20 | echo. 21 | echo.If you don't have Sphinx installed, grab it from 22 | echo.https://www.sphinx-doc.org/ 23 | exit /b 1 24 | ) 25 | 26 | if "%1" == "" goto help 27 | 28 | %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% 29 | goto end 30 | 31 | :help 32 | %SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% 33 | 34 | :end 35 | popd 36 | -------------------------------------------------------------------------------- /docs/requirements.txt: -------------------------------------------------------------------------------- 1 | -r ../requirements.txt 2 | pydata_sphinx_theme 3 | -------------------------------------------------------------------------------- /docs/source/_static/custom.css: -------------------------------------------------------------------------------- 1 | /* 2 | * custom.css 3 | * Copyright (C) 2022 Jiayuan Mao 4 | * 5 | * Distributed under terms of the MIT license. 6 | */ 7 | 8 | .bd-sidebar a.reference { 9 | overflow-wrap: break-word; 10 | } 11 | 12 | h1 { 13 | overflow-wrap: break-word; 14 | } 15 | .bd-main .bd-content .bd-article-container { 16 | max-width: 100%; 17 | } 18 | .bd-page-width { 19 | max-width: 100%; 20 | } 21 | .readme-image { 22 | width: 100%; 23 | max-width: 1440px; 24 | } 25 | 26 | @media (min-width: 1200px) { 27 | .container, .container-lg, .container-md, .container-sm, .container-xl { 28 | max-width: 100%; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /docs/source/_static/overview.png: -------------------------------------------------------------------------------- 1 | ../../../_assets/overview.png -------------------------------------------------------------------------------- /docs/source/_templates/base.rst: -------------------------------------------------------------------------------- 1 | {{ fullname | escape | underline}} 2 | 3 | .. automodule:: {{ fullname }} 4 | 5 | {% block attributes %} 6 | {% if attributes %} 7 | .. rubric:: Module attributes 8 | 9 | .. autosummary:: 10 | :toctree: 11 | {% for item in attributes %} 12 | {{ item }} 13 | {%- endfor %} 14 | {% endif %} 15 | {% endblock %} 16 | 17 | {% block functions %} 18 | {% if functions %} 19 | .. rubric:: {{ _('Functions') }} 20 | 21 | .. autosummary:: 22 | :toctree: 23 | {% for item in functions %} 24 | {{ item }} 25 | {%- endfor %} 26 | {% endif %} 27 | {% endblock %} 28 | 29 | {% block classes %} 30 | {% if classes %} 31 | .. rubric:: {{ _('Classes') }} 32 | 33 | .. autosummary:: 34 | :toctree: 35 | :template: class.rst 36 | {% for item in classes %} 37 | {{ item }} 38 | {%- endfor %} 39 | {% endif %} 40 | {% endblock %} 41 | 42 | {% block exceptions %} 43 | {% if exceptions %} 44 | .. rubric:: {{ _('Exceptions') }} 45 | 46 | .. autosummary:: 47 | :toctree: 48 | {% for item in exceptions %} 49 | {{ item }} 50 | {%- endfor %} 51 | {% endif %} 52 | {% endblock %} 53 | 54 | {% block modules %} 55 | {% if modules %} 56 | .. autosummary:: 57 | :toctree: 58 | :template: base.rst 59 | :recursive: 60 | {% for item in modules %} 61 | {{ item }} 62 | {%- endfor %} 63 | {% endif %} 64 | {% endblock %} 65 | -------------------------------------------------------------------------------- /docs/source/_templates/class.rst: -------------------------------------------------------------------------------- 1 | {{ fullname | escape | underline}} 2 | 3 | .. currentmodule:: {{ module }} 4 | 5 | .. autoclass:: {{ objname }} 6 | :members: 7 | :show-inheritance: 8 | :inherited-members: str, list, set, frozenset, dict, Module 9 | :undoc-members: 10 | :special-members: __call__, __add__, __mul__, __div__, __floordiv__, __getitem__, __len__, __iter__ 11 | 12 | {% block methods %} 13 | {% if methods %} 14 | .. rubric:: {{ _('Methods') }} 15 | 16 | .. autosummary:: 17 | {% for item in methods %} 18 | {%- if not item.startswith('_') %} 19 | ~{{ name }}.{{ item }} 20 | {%- endif -%} 21 | {%- endfor %} 22 | {% endif %} 23 | {% endblock %} 24 | 25 | {% block attributes %} 26 | {% if attributes %} 27 | .. rubric:: {{ _('Attributes') }} 28 | 29 | .. autosummary:: 30 | {% for item in attributes %} 31 | ~{{ name }}.{{ item }} 32 | {%- endfor %} 33 | {% endif %} 34 | {% endblock %} 35 | -------------------------------------------------------------------------------- /docs/source/api.rst: -------------------------------------------------------------------------------- 1 | .. 2 | DO NOT DELETE THIS FILE! It contains the all-important `.. autosummary::` directive with `:recursive:` option, without 3 | which API documentation wouldn't get extracted from docstrings by the `sphinx.ext.autosummary` engine. It is hidden 4 | (not declared in any toctree) to remove an unnecessary intermediate page; index.rst instead points directly to the 5 | package page. DO NOT REMOVE THIS FILE! 6 | 7 | .. autosummary:: 8 | :toctree: reference 9 | :template: base.rst 10 | :recursive: 11 | 12 | concepts 13 | 14 | -------------------------------------------------------------------------------- /docs/source/tutorial: -------------------------------------------------------------------------------- 1 | ../../tutorial -------------------------------------------------------------------------------- /docs/source/tutorials.rst: -------------------------------------------------------------------------------- 1 | Tutorials 2 | ========= 3 | 4 | .. toctree:: 5 | :maxdepth: 1 6 | :caption: Defining Domain-Specific Languages 7 | 8 | tutorial/1-dsl/1-types-and-functions 9 | tutorial/1-dsl/2-execution 10 | tutorial/1-dsl/3-tensor-values 11 | tutorial/1-dsl/4-learning 12 | tutorial/1-dsl/5-fol-python-parser 13 | 14 | .. toctree:: 15 | :maxdepth: 1 16 | :caption: Defining and Using Combinatory Categorial Grammars 17 | 18 | tutorial/2-ccg/1-parsing 19 | tutorial/2-ccg/2-learning 20 | tutorial/2-ccg/3-neural-ccg-basics 21 | tutorial/2-ccg/4-neural-ccg-weights 22 | 23 | .. toctree:: 24 | :maxdepth: 1 25 | :caption: Defining and Using PDSketch for Planning 26 | 27 | tutorial/3-pdsketch/1-basic-pddl 28 | tutorial/3-pdsketch/2-optimistic-solve 29 | tutorial/3-pdsketch/3-translate-into-strips 30 | tutorial/3-pdsketch/4-search-with-strips 31 | tutorial/3-pdsketch/5-advanced-features 32 | 33 | .. toctree:: 34 | :maxdepth: 1 35 | :caption: Relational Features and Relational Neural Networks 36 | 37 | tutorial/4-neural-logic/1-learning-family-relations 38 | 39 | .. toctree:: 40 | :maxdepth: 1 41 | :caption: Neural Symbolic Concept Learning 42 | 43 | tutorial/5-neuro-symbolic-concept-learning/1-logic-enhanced-foundation-model 44 | 45 | -------------------------------------------------------------------------------- /examples/algorithm/rrt/birrt.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : birrt.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 08/28/2024 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | import numpy as np 12 | import matplotlib.pyplot as plt 13 | from concepts.algorithm.configuration_space import BoxConfigurationSpace, CollisionFreeProblemSpace 14 | from concepts.algorithm.rrt.rrt import birrt 15 | from concepts.math.range import Range 16 | from concepts.simulator.shapely_kinematics.shapely_kinematics import ShapelyKinematicsSimulator, ShapelyCustomCircle, Polygon 17 | 18 | 19 | def make_shapely_world(): 20 | world = ShapelyKinematicsSimulator() 21 | world.add_circle('robot', radius=0.5, center=(-3, -3)) 22 | world.add_polygon('obstacle1', vertices=[(-1, -1), (1, -1), (1, 1), (-1, 1)]) 23 | return world 24 | 25 | 26 | def main(): 27 | world = make_shapely_world() 28 | space = BoxConfigurationSpace([Range(-5, 5), Range(-5, 5)], 0.1) 29 | 30 | def is_colliding(q): 31 | pos = world.get_object_pose('robot')[0] 32 | world.set_object_pose('robot', center=q, rotation=0) 33 | rv = world.pairwise_collision() 34 | world.set_object_pose('robot', center=pos, rotation=0) 35 | 36 | return len(rv) > 0 37 | 38 | # Define the problem space. 39 | problem_space = CollisionFreeProblemSpace(space, is_colliding) 40 | 41 | # Define the start and goal configurations. 42 | start = (-3, -3) 43 | goal = (3, 3) 44 | 45 | # Solve the problem. 46 | path, _ = birrt(problem_space, start, goal, smooth_fine_path=True) 47 | print(path) 48 | 49 | # Visualize the result. 50 | fig, ax = plt.subplots(figsize=(6, 6)) 51 | world.plot(ax) 52 | ax.plot(*zip(*path), 'r-') 53 | ax.plot(*start, 'go') 54 | ax.plot(*goal, 'bo') 55 | ax.set_xlim(-5, 5) 56 | ax.set_ylim(-5, 5) 57 | plt.show() 58 | 59 | 60 | if __name__ == '__main__': 61 | main() 62 | 63 | -------------------------------------------------------------------------------- /examples/benchmark/clevr/scene_generator/.gitignore: -------------------------------------------------------------------------------- 1 | /generated 2 | -------------------------------------------------------------------------------- /examples/benchmark/manip_tabletop/pybullet_tabletop_base/.gitignore: -------------------------------------------------------------------------------- 1 | /generated 2 | -------------------------------------------------------------------------------- /examples/benchmark/manip_tabletop/pybullet_tabletop_base/cliport-shapenet.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : cliport-shapenet.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 01/08/2024 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | import os.path as osp 12 | import matplotlib.pyplot as plt 13 | from concepts.math.rotationlib_xyzw import rpy 14 | from concepts.simulator.pybullet.client import BulletClient 15 | from concepts.simulator.pybullet.camera import TopDownOracle 16 | from concepts.benchmark.manip_tabletop.pybullet_tabletop_base.pybullet_tabletop import TableTopEnv 17 | 18 | client = BulletClient(is_gui=True) 19 | env = TableTopEnv(client) 20 | 21 | env.initialize_shapenet_core_loader(osp.expanduser('~/Workspace/datasets/ShapeNetCore.v2')) 22 | 23 | with client.disable_rendering(suppress_stdout=True): 24 | env.add_cliport_workspace() 25 | env.add_shape_net_core_object('laptop', '10f18b49ae496b0109eaabd919821b8', (0.4, 0.0, 0.1), scale=0.3, quat=rpy(90, 90, 0)) 26 | env.set_default_debug_camera() 27 | 28 | # Step the simulation for 120 steps to let the objects fall down. 29 | client.step(120) 30 | 31 | camera_config = TopDownOracle.get_configs()[0] 32 | rgb, depth, segmentation = client.world.render_image(camera_config, image_size=(320, 640)) 33 | 34 | # show the three images in a row 35 | plt.figure(figsize=(12, 4)) 36 | plt.subplot(131) 37 | plt.imshow(rgb) 38 | plt.subplot(132) 39 | plt.imshow(depth) 40 | plt.subplot(133) 41 | plt.imshow(segmentation) 42 | plt.tight_layout() 43 | plt.show() 44 | 45 | -------------------------------------------------------------------------------- /examples/dm/crow/00-language/1-load-crow-domain.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : 1-load-crow-domain.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 03/17/2024 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | import jacinle 12 | import concepts.dm.crow as crow 13 | 14 | 15 | domain = crow.load_domain_file('crow-demo.cdl') 16 | 17 | 18 | print(domain.name) 19 | table = list() 20 | for k, v in domain.types.items(): 21 | table.append((f'Type::{k}', str(v))) 22 | for k, v in domain.features.items(): 23 | table.append((f'Feature::{k}', str(v))) 24 | for k, v in domain.functions.items(): 25 | table.append((f'Function::{k}', str(v))) 26 | for k, v in domain.controllers.items(): 27 | table.append((f'Controller::{k}', str(v))) 28 | for k, v in domain.behaviors.items(): 29 | table.append((f'Behavior::{k}', str(v))) 30 | 31 | print(jacinle.tabulate(table)) 32 | 33 | -------------------------------------------------------------------------------- /examples/dm/crow/00-language/README.md: -------------------------------------------------------------------------------- 1 | This folder provides an example of a CDL description for a domain, including types, functions, and behaviors. 2 | 3 | ### Overview 4 | 5 | Use the following commands to run the example: 6 | 7 | ```bash 8 | # Runs the example --- loads the domain and prints its content 9 | python3 1-load-crow-domain.py 10 | 11 | # Visualize the domain in the terminal 12 | cdl-highlight crow-demo.cdl 13 | 14 | # Visualize the domain in the browser. Useful for generating visualizations (e.g., to PowerPoint) 15 | cdl-highlight crow-demo.cdl --html 16 | 17 | # Load the domain and summarize its content. This is useful for checking syntax. 18 | cdl-summary crow-demo.cdl 19 | ``` 20 | 21 | ### Other Examples 22 | 23 | - Usage of string types: 24 | ```bash 25 | cdl-plan string-demo.cdl 26 | ``` 27 | - Usage of the `alternative` statements: 28 | ```bash 29 | cdl-plan alternative-demo.cdl 30 | ``` 31 | - Usage of list types. 32 | ```bash 33 | cdl-plan list-type-demo.cdl 34 | ``` 35 | 36 | -------------------------------------------------------------------------------- /examples/dm/crow/00-language/alternative-demo.cdl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env cdl-plan 2 | 3 | problem "alternative-demo" 4 | domain "__empty__" 5 | 6 | typedef Object: object 7 | 8 | feature p(x: Object) -> bool 9 | feature q(x: Object) -> bool 10 | feature r(x: Object) -> bool 11 | 12 | controller controller1(x: Object) 13 | controller controller2(x: Object) 14 | controller controller3(x: Object) 15 | 16 | behavior behavior_1(x: Object): 17 | body: 18 | assert q(x) 19 | do controller1(x) 20 | eff: 21 | p[x] = True 22 | 23 | behavior behavior_2(x: Object): 24 | body: 25 | do controller2(x) 26 | eff: 27 | r[x] = True 28 | 29 | behavior behavior_3(x: Object): 30 | body: 31 | assert r(x) 32 | do controller3(x) 33 | eff: 34 | p[x] = True 35 | 36 | behavior test_behavior(x: Object): 37 | goal: p(x) 38 | body: 39 | alternative: 40 | behavior_1(x) 41 | sequential: 42 | behavior_2(x) 43 | behavior_3(x) 44 | 45 | objects: 46 | A: Object 47 | 48 | init: 49 | # If you uncomment the following line, we should be able to find a plan that uses controller1 50 | # q[A] = True 51 | pass 52 | 53 | behavior __goal__(): 54 | body: 55 | achieve p(A) 56 | -------------------------------------------------------------------------------- /examples/dm/crow/00-language/condition-demo.cdl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env cdl-plan 2 | 3 | problem "condition-demo" 4 | domain "__empty__" 5 | 6 | controller print(x: float32) 7 | 8 | behavior __goal__(): 9 | body: 10 | if 1 + 1 == 2: 11 | print(1.0) 12 | else: 13 | print(2.0) 14 | 15 | -------------------------------------------------------------------------------- /examples/dm/crow/00-language/dirty-feature-implementations.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : dirty-feature-implementations.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 01/08/2025 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | import concepts.dm.crow as crow 12 | 13 | 14 | @crow.config_function_implementation() 15 | def is_okay(x): 16 | return False 17 | -------------------------------------------------------------------------------- /examples/dm/crow/00-language/dirty-feature.cdl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env cdl-plan 2 | 3 | problem "dirty-feature-demo" 4 | domain "__empty__" 5 | 6 | #!pragma planner_algo="priority_tree_v1" 7 | #!pragma load_implementation("dirty-feature-implementations.py") 8 | 9 | typedef Object: object 10 | typedef ObjectList: Object[] 11 | 12 | feature is_good(x: Object) -> bool 13 | def is_okay(x: Object) -> bool 14 | 15 | controller print(x: Object) 16 | 17 | objects: 18 | A, B, C: Object 19 | 20 | init: 21 | is_good[A] = True 22 | 23 | behavior do_okay(x: Object): 24 | goal: is_okay(x) 25 | body: 26 | print(x) 27 | eff: 28 | is_okay[x] = True # This is manually setting a function to be True. 29 | 30 | behavior __goal__(): 31 | body: 32 | let xl = findall x: Object: not is_good(x) 33 | foreach x in xl: 34 | achieve is_okay(x) 35 | 36 | -------------------------------------------------------------------------------- /examples/dm/crow/00-language/foreach-loop.cdl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env cdl-plan 2 | 3 | problem "foreach-loop-demo" 4 | domain "__empty__" 5 | 6 | typedef Object: object 7 | typedef ObjectList: Object[] 8 | 9 | controller print_bar() 10 | controller print(x: Object) 11 | 12 | objects: 13 | A, B, C: Object 14 | 15 | behavior __goal__(): 16 | body: 17 | foreach x in [A, B, C]: 18 | print(x) 19 | print_bar() 20 | foreach x in [A]: 21 | print(x) 22 | print_bar() 23 | foreach x in ObjectList([]): 24 | print(x) 25 | -------------------------------------------------------------------------------- /examples/dm/crow/00-language/list-type-demo.cdl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env cdl-plan 2 | 3 | problem "list-type-demo" 4 | domain "__empty__" # __empty__ is a built-in domain that does not contain any types or features or controllers. 5 | 6 | typedef Object: object 7 | typedef Pose: vector[float32, 3] 8 | typedef ObjectList: Object[] 9 | typedef PoseList: Pose[] 10 | typedef PoseListIndexedByObject: Pose[Object] 11 | 12 | feature pose_of(obj: Object) -> Pose 13 | 14 | controller print(p: Pose) 15 | controller print_list_of_poses_indexed_by_object_1(lst: PoseListIndexedByObject) 16 | controller print_separate_bar() 17 | 18 | behavior print_list(lst: ObjectList): 19 | body: 20 | foreach obj in lst: 21 | print(pose_of(obj)) 22 | 23 | behavior print_list_of_poses(lst: PoseList): 24 | body: 25 | foreach p in lst: 26 | print(p) 27 | 28 | behavior print_list_of_poses_indexed_by_object_2(lst: PoseListIndexedByObject): 29 | body: 30 | # We can also iterate over the PoseListIndexedByObject (a.k.a. Pose[Object]) directly. 31 | # But this is not recommended because it can be slow. 32 | foreach element in lst: 33 | print(element) 34 | 35 | objects: 36 | A, B, C: Object 37 | 38 | init: 39 | pose_of[A] = [1.0, 2.0, 3.0] 40 | pose_of[B] = [4.0, 5.0, 6.0] 41 | pose_of[C] = [7.0, 8.0, 9.0] 42 | 43 | behavior test(): 44 | body: 45 | foreach obj: Object: 46 | let p = pose_of(obj) 47 | print(p) 48 | print_separate_bar() 49 | 50 | print_list([A, B, C]) 51 | print_separate_bar() 52 | 53 | let lst1: ObjectList = [A, B, C] 54 | print_list(lst1) 55 | print_separate_bar() 56 | 57 | # lst2 is of type PoseList but not PoseListIndexedByObject because we are directly constructing it from several values. 58 | let lst2: PoseList = [pose_of(A), pose_of(B), pose_of(C)] 59 | print_list_of_poses(lst2) 60 | 61 | let lst3: ObjectList = [A, B, C] 62 | # Type Error: 63 | # let lst4: PoseList = pose_of[lst3] 64 | let lst4: PoseListIndexedByObject = pose_of[lst3] 65 | print_list_of_poses_indexed_by_object_1(lst4) 66 | print_list_of_poses_indexed_by_object_2(lst4) 67 | 68 | 69 | behavior __goal__(): 70 | body: 71 | test() 72 | -------------------------------------------------------------------------------- /examples/dm/crow/00-language/mem-query.cdl: -------------------------------------------------------------------------------- 1 | problem "mem-query-demo" 2 | domain "__empty__" 3 | 4 | #!pragma planner_algo="priority_tree_v1" 5 | 6 | typedef Object: object 7 | typedef ObjectList: Object[] 8 | 9 | feature is_good(x: Object) -> bool 10 | 11 | controller print(x: Object) 12 | 13 | objects: 14 | A, B, C: Object 15 | 16 | init: 17 | is_good[A] = True 18 | 19 | behavior __goal__(): 20 | body: 21 | mem_query findall x: Object: is_good(x) 22 | let xl = findall x: Object: is_good(x) 23 | foreach x in xl: 24 | print(x) 25 | -------------------------------------------------------------------------------- /examples/dm/crow/00-language/string-demo.cdl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env cdl-plan 2 | 3 | problem "string-demo" 4 | domain "__empty__" 5 | 6 | typedef Object: object 7 | typedef Color: string 8 | 9 | feature [[state]] color_of(o: Object) -> Color 10 | 11 | controller printb(b: bool) 12 | 13 | objects: 14 | A: Object 15 | B: Object 16 | C: Object 17 | 18 | init: 19 | color_of[A] = "red" 20 | color_of[B] = "green" 21 | color_of[C] = "blue" 22 | 23 | behavior __goal__(): 24 | body: 25 | printb(color_of[A] == "red") 26 | printb(color_of[A] != "red") 27 | 28 | -------------------------------------------------------------------------------- /examples/dm/crow/01-blocksworld/1-load-crow-domain.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : 1-load-crow-domain.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 03/17/2024 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | import jacinle 12 | import concepts.dm.crow as crow 13 | 14 | 15 | def main(): 16 | print('Loading the blocksworld domain...') 17 | domain = crow.load_domain_file('blocksworld.cdl') 18 | 19 | print(domain.name) 20 | table = list() 21 | for k, v in domain.types.items(): 22 | table.append((f'Type::{k}', str(v))) 23 | for k, v in domain.features.items(): 24 | table.append((f'Feature::{k}', str(v))) 25 | for k, v in domain.functions.items(): 26 | table.append((f'Function::{k}', str(v))) 27 | for k, v in domain.controllers.items(): 28 | table.append((f'Controller::{k}', str(v))) 29 | for k, v in domain.behaviors.items(): 30 | table.append((f'Behavior::{k}', str(v))) 31 | 32 | print(jacinle.tabulate(table)) 33 | 34 | print('Loading the blocksworld problem...') 35 | problem = crow.load_problem_file('blocksworld-problem-sussman.cdl') 36 | executor = domain.make_executor() 37 | 38 | print('Evaluating an expression on the initial state...') 39 | result = executor.execute( 40 | expression='on(A, B) and on(B, x)', 41 | state=problem.state, 42 | bounded_variables={'x': 'C'} 43 | ) 44 | 45 | print('Evaluation result:', result) 46 | 47 | 48 | if __name__ == '__main__': 49 | main() 50 | -------------------------------------------------------------------------------- /examples/dm/crow/01-blocksworld/2-solve-blocksworld.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : 2-solve-blocksworld.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 03/04/2024 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | import jacinle 12 | import concepts.dm.crow as crow 13 | 14 | parser = jacinle.JacArgumentParser() 15 | parser.add_argument('--domain', default='blocksworld.cdl') 16 | parser.add_argument('--verbose', action='store_true') 17 | args = parser.parse_args() 18 | 19 | 20 | def main(): 21 | domain = crow.load_domain_file(args.domain) 22 | problem = crow.load_problem_file('blocksworld-problem-sussman.cdl', domain=domain) 23 | 24 | state = problem.state 25 | print('=' * 80) 26 | print('Initial state:') 27 | print(state) 28 | 29 | plan(domain, problem, 'clear(A)') 30 | plan(domain, problem, 'clear(A) and clear(C)') 31 | plan(domain, problem, 'on(B, C) and holding(A)') 32 | plan(domain, problem, 'on(B, C) and on(A, B)') 33 | 34 | 35 | def plan(domain, problem, goal): 36 | candidate_plans, search_stat = crow.crow_regression( 37 | domain, problem, goal=goal, min_search_depth=5, max_search_depth=7, 38 | is_goal_ordered=True, is_goal_serializable=False, always_commit_skeleton=True 39 | ) 40 | table = list() 41 | for p in candidate_plans: 42 | table.append('; '.join(map(str, p))) 43 | print() 44 | print('=' * 80) 45 | print('Goal:', goal) 46 | for i, row in enumerate(table): 47 | print(f'Plan {i}:', row) 48 | print(search_stat) 49 | input('Press Enter to continue...') 50 | 51 | 52 | if __name__ == '__main__': 53 | main() 54 | 55 | -------------------------------------------------------------------------------- /examples/dm/crow/01-blocksworld/blocksworld-problem-sussman-with-custom-policy.cdl: -------------------------------------------------------------------------------- 1 | problem "blocksworld-sussman" 2 | domain "blocksworld-breakdown.cdl" 3 | 4 | #!pragma planner_is_goal_serializable=False 5 | #!pragma planner_is_goal_ordered=True 6 | #!pragma planner_always_commit_skeleton=True 7 | 8 | objects: 9 | A: block 10 | B: block 11 | C: block 12 | 13 | init: 14 | on_table[A] = True 15 | on_table[B] = True 16 | on[C, A] = True 17 | foreach x: block: 18 | clear[x] = True 19 | clear[A] = False 20 | handempty[...] = True 21 | 22 | 23 | behavior __goal__(): 24 | body: 25 | # Option 1 26 | foreach x: block: 27 | achieve_once on_table(x) 28 | 29 | # Option 2 30 | # foreach x: block: 31 | # if not on_table(x): 32 | # achieve_once on_table(x) 33 | 34 | # Option 3 35 | # achieve_once on_table(A) 36 | # achieve_once on_table(B) 37 | # achieve_once on_table(C) 38 | 39 | achieve_once handempty() 40 | 41 | achieve on(B, C) 42 | achieve on(A, B) 43 | -------------------------------------------------------------------------------- /examples/dm/crow/01-blocksworld/blocksworld-problem-sussman-with-custom-policy2.cdl: -------------------------------------------------------------------------------- 1 | problem "blocksworld-sussman" 2 | domain "blocksworld-breakdown.cdl" 3 | 4 | #!pragma planner_is_goal_serializable=False 5 | #!pragma planner_is_goal_ordered=True 6 | #!pragma planner_always_commit_skeleton=True 7 | 8 | objects: 9 | A: block 10 | B: block 11 | C: block 12 | 13 | init: 14 | on_table[A] = True 15 | on_table[B] = True 16 | on[C, A] = True 17 | foreach x: block: 18 | clear[x] = True 19 | clear[A] = False 20 | handempty[...] = True 21 | 22 | 23 | def bw_goal(x: block, y: block, z: block) -> bool: 24 | return on(x, y) and on(y, z) 25 | 26 | behavior solve(x: block, y: block, z: block): 27 | body: 28 | promotable sequential: 29 | achieve on(y, z) 30 | achieve on(x, y) 31 | assert on(y, z) and on(x, y) 32 | 33 | 34 | behavior b(x: block, y: block, z: block): 35 | goal: 36 | bw_goal(x, y, z) 37 | body: 38 | let blocks_not_on_table = findall t: block: not on_table(t) 39 | foreach t in blocks_not_on_table: 40 | achieve_once on_table(t) 41 | 42 | achieve_once handempty() 43 | solve(x, y, z) 44 | 45 | goal: 46 | bw_goal(A, B, C) 47 | -------------------------------------------------------------------------------- /examples/dm/crow/01-blocksworld/blocksworld-problem-sussman-with-pachieve.cdl: -------------------------------------------------------------------------------- 1 | problem "blocksworld-sussman" 2 | domain "blocksworld-breakdown.cdl" 3 | 4 | #!pragma planner_always_commit_skeleton=True 5 | # Note that we have to increase the minimum search depth to a large enough number. 6 | # If not, the planner will not be able to find a solution for solution under depth 6. 7 | # As a result, it will actually run SLOWER than having a larger minimum search depth. 8 | # Because it will keep trying all possible promotions of the subgoals under depth 5 or 6... 9 | #!pragma planner_min_search_depth=10 10 | 11 | objects: 12 | A: block 13 | B: block 14 | C: block 15 | 16 | init: 17 | on_table[A] = True 18 | on_table[B] = True 19 | on[C, A] = True 20 | foreach x: block: 21 | clear[x] = True 22 | clear[A] = False 23 | handempty[...] = True 24 | 25 | 26 | behavior make_stack(x: block, y: block, z: block): 27 | body: 28 | [[ordered=True, serializable=False]] 29 | pachieve on(y, z) and on(x, y) 30 | 31 | 32 | behavior __goal__(): 33 | body: 34 | make_stack(A, B, C) 35 | -------------------------------------------------------------------------------- /examples/dm/crow/01-blocksworld/blocksworld-problem-sussman-with-pragma.cdl: -------------------------------------------------------------------------------- 1 | problem "blocksworld-sussman" 2 | domain "blocksworld-breakdown.cdl" 3 | 4 | #!pragma planner_is_goal_serializable=False 5 | #!pragma planner_is_goal_ordered=True 6 | #!pragma planner_always_commit_skeleton=True 7 | 8 | objects: 9 | A: block 10 | B: block 11 | C: block 12 | 13 | init: 14 | on_table[A] = True 15 | on_table[B] = True 16 | on[C, A] = True 17 | foreach x: block: 18 | clear[x] = True 19 | clear[A] = False 20 | handempty[...] = True 21 | 22 | goal: 23 | on(B, C) and on(A, B) 24 | -------------------------------------------------------------------------------- /examples/dm/crow/01-blocksworld/blocksworld-problem-sussman.cdl: -------------------------------------------------------------------------------- 1 | problem "blocksworld-sussman" 2 | domain "blocksworld.cdl" 3 | 4 | objects: 5 | A: block 6 | B: block 7 | C: block 8 | 9 | init: 10 | on_table[A] = True 11 | on_table[B] = True 12 | on[C, A] = True 13 | foreach x: block: 14 | clear[x] = True 15 | clear[A] = False 16 | handempty[...] = True 17 | 18 | goal: 19 | on(B, C) and on(A, B) 20 | -------------------------------------------------------------------------------- /examples/dm/crow/01-blocksworld/inspect-graph.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : inspect-graph.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 03/19/2024 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | import jacinle 12 | 13 | parser = jacinle.JacArgumentParser() 14 | parser.add_argument('graph', type=str) 15 | args = parser.parse_args() 16 | 17 | 18 | def main(): 19 | graph = jacinle.load(args.graph) 20 | 21 | nodes = graph['nodes'] 22 | edges = graph['edges'] 23 | 24 | node_index2key = {i: key for i, key in enumerate(nodes.keys())} 25 | node_key2index = {key: i for i, key in enumerate(nodes.keys())} 26 | 27 | while True: 28 | node_id = input('Node ID: ') 29 | if node_id == 'q': 30 | break 31 | 32 | try: 33 | node_id = int(node_id) 34 | except: 35 | print('Invalid node ID.') 36 | continue 37 | 38 | key = node_index2key[node_id] 39 | print('Node:', key) 40 | print('Program:') 41 | print(nodes[key].state.print()) 42 | print('Edges:') 43 | for edge in edges: 44 | if edge[1] == key: 45 | print(' <-', node_key2index[edge[0]], edge[0]) 46 | if edge[0] == key: 47 | print(' ->', node_key2index[edge[1]], edge[1], edge[2] if len(edge) > 2 else '') 48 | 49 | 50 | if __name__ == '__main__': 51 | main() 52 | 53 | -------------------------------------------------------------------------------- /examples/dm/crow/02-simple-pick-place/1-load-crow-domain.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : 1-load-crow-domain.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 03/17/2024 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | import jacinle 12 | import concepts.dm.crow as crow 13 | from concepts.dm.crowhat.domains.pybullet_single_robot_rwi_pp_simplified import PyBulletSingleArmRWIPPSimplifiedDomain 14 | 15 | 16 | domain = crow.load_domain_file(PyBulletSingleArmRWIPPSimplifiedDomain.domain_filename) 17 | 18 | 19 | print(domain.name) 20 | table = list() 21 | for k, v in domain.types.items(): 22 | table.append((f'Type::{k}', str(v))) 23 | for k, v in domain.features.items(): 24 | table.append((f'Feature::{k}', str(v))) 25 | for k, v in domain.functions.items(): 26 | table.append((f'Function::{k}', str(v))) 27 | for k, v in domain.controllers.items(): 28 | table.append((f'Controller::{k}', str(v))) 29 | for k, v in domain.behaviors.items(): 30 | table.append((f'Behavior::{k}', v.long_str())) 31 | 32 | print(jacinle.tabulate(table)) 33 | 34 | -------------------------------------------------------------------------------- /examples/dm/crow/02-simple-pick-place/simple-cube-in-box-domain.qddl: -------------------------------------------------------------------------------- 1 | (define 2 | (domain tabletop) 3 | 4 | (:object-types 5 | (panda-type "package://concepts/robots/franka_description/robots/panda_arm_hand.urdf") 6 | (workspace-type "package://concepts/basic/plane/workspace.urdf") 7 | (table-type "package://concepts/basic/plane/plane.urdf") 8 | (cube-type "package://concepts/basic/box/box-template.urdf") 9 | (box-type "package://concepts/basic/container/container-template.urdf") 10 | ) 11 | 12 | (:predicates 13 | (in ?obj ?region) 14 | (on ?obj ?obj) 15 | ) 16 | ) 17 | -------------------------------------------------------------------------------- /examples/dm/crow/02-simple-pick-place/simple-cube-in-box-problem.qddl: -------------------------------------------------------------------------------- 1 | (define 2 | (problem simple-cube-in-box) 3 | (:domain tabletop) 4 | (:objects 5 | world - qr::world-type 6 | panda - panda-type 7 | workspace - workspace-type 8 | table - table-type 9 | cube - cube-type 10 | box - box-type 11 | ) 12 | (:init 13 | (weld world::world workspace (1, 0, 0, 0, 0, 0)) 14 | (weld world::world table (0, 0, -0.001, 0, 0, 0)) 15 | (weld world::world panda (0, 0, 0, 0, 0, 0)) 16 | (weld world::world box (0.5, -0.3, 0.05, 0, 0, 0)) 17 | 18 | ;; PANDA_JOINT_HOMES = np.array([-0.45105, -0.38886, 0.45533, -2.19163, 0.13169, 1.81720, 0.51563]) 19 | (joint-conf panda::panda_joint1 -0.45105) 20 | (joint-conf panda::panda_joint2 -0.38886) 21 | (joint-conf panda::panda_joint3 0.45533) 22 | (joint-conf panda::panda_joint4 -2.19163) 23 | (joint-conf panda::panda_joint5 0.13169) 24 | (joint-conf panda::panda_joint6 1.81720) 25 | (joint-conf panda::panda_joint7 0.51563) 26 | 27 | (body-pose cube (0.5, 0.3, 0.025, 0, 0, 0)) 28 | 29 | (urdf::prop box "DIM" (0.2, 0.2, 0.1)) 30 | (urdf::prop box "HALF" (0.1, 0.1, 0.05)) 31 | ;; rgba is directly set through the load_urdf function so we are listing it as a urdf-load-arg here 32 | (urdf::load-arg box "rgba" (0.5, 1.0, 0.5, 1.0)) 33 | (urdf::prop cube "DIM" (0.05, 0.05, 0.05)) 34 | (urdf::prop cube "HALF" (0.025, 0.025, 0.025)) 35 | (urdf::prop cube "MASS" 0.2) 36 | (urdf::prop cube "LATERAL_FRICTION" 1.0) 37 | ;; rgba is directly set through the load_urdf function so we are listing it as a urdf-load-arg here 38 | (urdf::load-arg cube "rgba" (1.0, 0.34, 0.34, 1.0)) 39 | 40 | (sim::camera-distance 1.5) 41 | (sim::camera-yaw 90) 42 | (sim::camera-pitch -25) 43 | (sim::camera-look-at (0, 0, 0)) 44 | ) 45 | (:goal (and 46 | (in cube box) 47 | )) 48 | ) -------------------------------------------------------------------------------- /examples/dm/crow/03-crafting-world/1-load-crow-domain.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : 1-load-crow-domain.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 03/17/2024 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | import jacinle 12 | import concepts.dm.crow as crow 13 | from concepts.benchmark.gridworld.crafting_world.crow_domains import get_crafting_world_domain_filename 14 | 15 | 16 | domain = crow.load_domain_file(get_crafting_world_domain_filename()) 17 | 18 | 19 | print(domain.name) 20 | table = list() 21 | for k, v in domain.types.items(): 22 | table.append((f'Type::{k}', str(v))) 23 | for k, v in domain.constants.items(): 24 | table.append((f'Constant::{k}', str(v))) 25 | for k, v in domain.features.items(): 26 | table.append((f'Feature::{k}', str(v))) 27 | for k, v in domain.functions.items(): 28 | table.append((f'Function::{k}', str(v))) 29 | for k, v in domain.controllers.items(): 30 | table.append((f'Controller::{k}', str(v))) 31 | for k, v in domain.behaviors.items(): 32 | table.append((f'Behavior::{k}', str(v))) 33 | 34 | print(jacinle.tabulate(table)) 35 | 36 | -------------------------------------------------------------------------------- /examples/dm/crow/03-crafting-world/README.md: -------------------------------------------------------------------------------- 1 | This folder provides an example of a CDL description for a Mini-Minecraft domain. 2 | 3 | The Mini-Minecraft domain is a simplified version of the Minecraft domain, where the agent can move in a 2D grid and interact with the environment by mining and crafting objects. 4 | In the default setup, the environments only begin with raw resources and two starting tools (axe and pickaxe). 5 | Agents may need to compose multiple skills to obtain other downstream resources. 6 | 7 | ### Overview 8 | 9 | Use the following commands to run the example: 10 | 11 | ```bash 12 | # Runs the example --- loads the domain and prints its content 13 | python3 1-load-crow-domain.py 14 | 15 | # Visualize the domain in the terminal 16 | cdl-highlight ../../../../concepts/benchmark/gridworld/crafting_world/crow_domains/crafting_world_station_agnostic.cdl 17 | ``` 18 | 19 | ```bash 20 | # Run the planner for the "crafting-world" problem 21 | python3 2-solve-crafting-world.py 22 | ``` 23 | 24 | You can specify additional `--target` arguments to run different scenarios. For example, to test "single-goal-item" tasks, run: 25 | 26 | ```bash 27 | python3 2-solve-crafting-world.py --target single-goal 28 | ``` 29 | 30 | To test "double-goal-item" tasks, run: 31 | 32 | ```bash 33 | python3 2-solve-crafting-world.py --target double-goal 34 | ``` 35 | 36 | To test a custom goal configuration, run: 37 | 38 | ```bash 39 | python3 2-solve-crafting-world.py --target custom 40 | ``` 41 | 42 | See the `2-solve-crafting-world.py` script for more details. 43 | 44 | You can also directly run the planner with the following command: 45 | 46 | ```bash 47 | cdl-plan crafting-world-problem-example.cdl --print-stat --is-goal-ordered=False --is-goal-serializable=True --always-commit-skeleton=True --min-search-depth=15 48 | cdl-plan crafting-world-problem-example-with-pragma.cdl --print-stat 49 | ``` 50 | 51 | -------------------------------------------------------------------------------- /examples/dm/crow/04-paint-factory/1-load-crow-domain.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : 1-load-crow-domain.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 03/17/2024 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | import jacinle 12 | import concepts.dm.crow as crow 13 | from concepts.benchmark.manip_tabletop.paint_factory.crow_domains import get_paint_factory_domain_filename 14 | 15 | 16 | domain = crow.load_domain_file(get_paint_factory_domain_filename()) 17 | 18 | 19 | print(domain.name) 20 | table = list() 21 | for k, v in domain.types.items(): 22 | table.append((f'Type::{k}', str(v))) 23 | for k, v in domain.features.items(): 24 | table.append((f'Feature::{k}', str(v))) 25 | for k, v in domain.functions.items(): 26 | table.append((f'Function::{k}', str(v))) 27 | for k, v in domain.controllers.items(): 28 | table.append((f'Controller::{k}', str(v))) 29 | for k, v in domain.behaviors.items(): 30 | table.append((f'Behavior::{k}', str(v))) 31 | 32 | print(jacinle.tabulate(table)) 33 | -------------------------------------------------------------------------------- /examples/dm/crow/04-paint-factory/README.md: -------------------------------------------------------------------------------- 1 | This folder provides an example of a CDL description for a robot paint factory domain. 2 | 3 | There are three zones, several bowls, and several blocks on the table. 4 | The robot can use its suction gripper to pick-and-place objects into a designated location. 5 | Blocks have 8 possible colors. Placing objects in a bowl will paint the object to be the same color as 6 | the bowl. The task is to paint the blocks and organize them in the target brown box. Our training-time 7 | goal requires the robot to paint-and-place two objects. The goal contains their colors and their 8 | relationship (e.g., a pink block is left of a yellow block. Demonstration are collected using handcrafted oracle policies. 9 | The offline dataset contains only successful trajectories. 10 | 11 | 12 | ### Overview 13 | 14 | Use the following commands to run the example: 15 | 16 | ```bash 17 | # Runs the example --- loads the domain and prints its content 18 | python3 1-load-crow-domain.py 19 | ``` 20 | -------------------------------------------------------------------------------- /examples/dm/crow/05-pick-place-hierarchy/1-visualize-env.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : 1-visualize-env.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 05/7/2024 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | import argparse 12 | from concepts.benchmark.manip_tabletop.pick_place_hierarchy.pick_place_hierarchy import create_environment, get_available_tasks 13 | 14 | 15 | parser = argparse.ArgumentParser() 16 | parser.add_argument('--task', type=str, default='h0-simple', choices=get_available_tasks()) 17 | args = parser.parse_args() 18 | 19 | client, metainfo = create_environment(args.task) 20 | client.wait_forever() 21 | -------------------------------------------------------------------------------- /examples/dm/crow/06-simple-belief/belief-example-1.cdl: -------------------------------------------------------------------------------- 1 | problem "belief-example-1" 2 | domain "belief.cdl" 3 | 4 | objects: 5 | R1, R2: Room 6 | 7 | def get_current_room(loc: prob[Room]) -> Room 8 | def get_next_room(x: Room) -> Room 9 | 10 | init: 11 | robot_at[R1] = 1.0 12 | 13 | behavior __goal__(): 14 | body: 15 | let target_room = get_next_room(get_current_room(robot_at[:])) 16 | achieve robot_at[target_room] >= 0.95 17 | -------------------------------------------------------------------------------- /examples/dm/crow/06-simple-belief/belief-example-2.cdl: -------------------------------------------------------------------------------- 1 | problem "belief-example-1" 2 | domain "belief.cdl" 3 | 4 | objects: 5 | R1, R2: Room 6 | O1, O2: Object 7 | 8 | init: 9 | object_at[O1, R1] = 0.5 10 | object_at[O1, R2] = 0.01 11 | object_at[O2, R1] = 0.01 12 | object_at[O2, R2] = 0.5 13 | robot_at[R1] = 1.0 14 | 15 | behavior __goal__(): 16 | body: 17 | do move(R2) 18 | do move(R2) 19 | do look_for(R2, O2) 20 | do pick(R2, O2) 21 | -------------------------------------------------------------------------------- /examples/dm/crow/06-simple-belief/belief-example-3.cdl: -------------------------------------------------------------------------------- 1 | problem "belief-example-1" 2 | domain "belief.cdl" 3 | 4 | objects: 5 | R1, R2: Room 6 | O1, O2: Object 7 | 8 | init: 9 | object_at[O1, R1] = 0.5 10 | object_at[O1, R2] = 0.01 11 | object_at[O2, R1] = 0.01 12 | object_at[O2, R2] = 0.5 13 | robot_at[R1] = 1.0 14 | 15 | behavior __goal__(): 16 | body: 17 | achieve holding[O2] >= 0.85 18 | -------------------------------------------------------------------------------- /examples/dm/crow/06-simple-belief/belief.cdl: -------------------------------------------------------------------------------- 1 | domain "crowbob" 2 | 3 | typedef Object: object 4 | typedef Room: object 5 | typedef prob: float32 6 | 7 | feature [[state]] robot_at(r: Room) -> prob 8 | feature [[state]] holding(x: Object) -> prob 9 | feature [[state]] object_at(x: Object, y: Room) -> prob 10 | feature [[state, default=0.0]] cost() -> float32 11 | 12 | def sqrt(x: prob) -> prob 13 | def log(x: prob) -> prob 14 | def move_to_target_belief_update(prior: prob[Room], r: Room) -> prob[Room] 15 | def look_to_find_belief_update(prior: prob, o: Object, r: Room) -> prob 16 | 17 | controller move(r: Room): 18 | eff: 19 | robot_at[:] = move_to_target_belief_update(robot_at[:], r) 20 | cost += 1.0 21 | 22 | controller look_for(r: Room, o: Object): 23 | eff: 24 | object_at[o, r] = look_to_find_belief_update(object_at[o, r], o, r) 25 | cost += -log(object_at[o, r]) - log(robot_at[r]) 26 | 27 | controller pick(r: Room, o: Object): 28 | eff: 29 | holding[o] = robot_at[r] * object_at[o, r] 30 | cost += 1.0 31 | 32 | behavior b_move(r: Room, posterior: prob): 33 | goal: 34 | robot_at(r) >= posterior 35 | body: 36 | while robot_at(r) < posterior: 37 | do move(r) 38 | 39 | behavior b_pick(o: Object, posterior: prob): 40 | goal: 41 | holding(o) >= posterior 42 | body: 43 | # For now, use a hard-coded posterior ratio between object_at and robot_at. 44 | let component_posterior = sqrt(posterior) 45 | achieve_once exists r: Room where: object_at(o, r) >= component_posterior 46 | bind r: Room where: object_at(o, r) >= component_posterior 47 | achieve robot_at(r) >= component_posterior 48 | do pick(r, o) 49 | 50 | behavior b_look_for(o: Object, posterior: prob): 51 | goal: 52 | exists r: Room where: object_at(o, r) >= posterior 53 | body: 54 | bind r: Room 55 | # Another hard-coded posterior for robot_at. 56 | achieve robot_at(r) >= 0.9 57 | while object_at(o, r) < posterior: 58 | do look_for(r, o) 59 | -------------------------------------------------------------------------------- /examples/dm/crow/07-simple-csp/1-bool-csp.cdl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env cdl-plan 2 | 3 | problem "csp" 4 | domain "__empty__" 5 | 6 | controller print(s: string, x: bool) 7 | 8 | behavior __goal__(): 9 | body: 10 | bind x: bool 11 | bind y: bool 12 | bind z: bool 13 | 14 | assert not x or not y 15 | assert y or not z 16 | assert z or not x 17 | 18 | print("x", x) 19 | print("y", y) 20 | print("z", z) 21 | 22 | init: 23 | # Empty state 24 | pass 25 | 26 | -------------------------------------------------------------------------------- /examples/dm/crow/07-simple-csp/2-simple-float-csp.cdl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env cdl-plan 2 | 3 | problem "simple-float-csp" 4 | domain "__empty__" 5 | 6 | # Load the implementation for these functions written in Python 7 | # The implementation is in the file 2-simple-float-csp.py 8 | # Now the plan can be generated directly using the CLI tool: 9 | # cdl-plan 2-simple-float-csp.cdl 10 | #!pragma load_implementation("2-simple-float-csp.py") 11 | 12 | def f(x: float32) -> float32 13 | 14 | generator inv_f(x: float32, y: float32): 15 | goal: f(x) == y 16 | in: y 17 | out: x 18 | 19 | generator inv_plus(x: float32, y: float32, z: float32): 20 | goal: x + y == z 21 | in: z 22 | out: x, y 23 | 24 | controller print(s: string, x: float32) 25 | 26 | behavior __goal__(): 27 | body: 28 | bind x: float32 29 | bind y: float32 30 | 31 | assert f(x) + f(y) == 7.0 32 | print("x", x) 33 | print("y", y) 34 | 35 | -------------------------------------------------------------------------------- /examples/dm/crow/07-simple-csp/2-simple-float-csp.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : 2-simple-float-csp.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 08/10/2024 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | import os.path as osp 12 | import jacinle 13 | import concepts.dm.crow as crow 14 | 15 | @crow.config_function_implementation 16 | def f(x): 17 | return x ** 3 18 | 19 | 20 | @crow.config_function_implementation 21 | def inv_f(y): 22 | return y ** (1 / 3) 23 | 24 | 25 | @crow.config_function_implementation(is_iterator=True) 26 | def inv_plus(z): 27 | yield z / 2, z / 2 28 | 29 | 30 | def main(): 31 | problem = crow.load_problem_file(osp.join(osp.dirname(__file__), '2-simple-float-csp.cdl')) 32 | executor = problem.domain.make_executor() 33 | executor.register_function_implementation('f', f) 34 | executor.register_function_implementation('inv_f', inv_f) 35 | executor.register_function_implementation('inv_plus', inv_plus) 36 | plans, _ = crow.crow_regression(executor, problem) 37 | for x in plans[0]: 38 | print(x) 39 | 40 | 41 | if __name__ == '__main__': 42 | main() 43 | -------------------------------------------------------------------------------- /examples/dm/crow/07-simple-csp/3-simple-float-csp2.cdl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env cdl-plan 2 | 3 | problem "simple-float-csp" 4 | domain "__empty__" 5 | 6 | #!pragma load_implementation("3-simple-float-csp2.py") 7 | 8 | def f(x: float32) -> float32 9 | 10 | generator inv_f(x: float32, y: float32): 11 | goal: f(x) == y 12 | in: y 13 | out: x 14 | 15 | generator inv_plus(x: float32, y: float32, z: float32): 16 | goal: x + y == z 17 | in: z, x 18 | out: y 19 | 20 | generator gen_float(x: float32): 21 | out: x 22 | 23 | controller print(s: string, x: float32) 24 | 25 | behavior __goal__(): 26 | body: 27 | bind x: float32 28 | bind y: float32 29 | 30 | assert f(x) + f(y) == 7.0 31 | print("x", x) 32 | print("y", y) 33 | 34 | -------------------------------------------------------------------------------- /examples/dm/crow/07-simple-csp/3-simple-float-csp2.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : 2-simple-float-csp.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 08/10/2024 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | import concepts.dm.crow as crow 12 | 13 | @crow.config_function_implementation 14 | def f(x): 15 | return x ** 3 16 | 17 | 18 | @crow.config_function_implementation 19 | def inv_f(y): 20 | return y ** (1 / 3) 21 | 22 | 23 | @crow.config_function_implementation(is_iterator=True) 24 | def inv_plus(z, y): 25 | yield z - y 26 | 27 | 28 | @crow.config_function_implementation(is_iterator=True) 29 | def gen_float(): 30 | for i in range(10): 31 | yield float(i) 32 | 33 | -------------------------------------------------------------------------------- /examples/dm/crow/08-simple-heuristic/__pycache__/simple_heuristic_lib.cpython-311.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/concepts-ai/Concepts/13847828a1ecb8f0d8c43a420a2a1ad234cfe242/examples/dm/crow/08-simple-heuristic/__pycache__/simple_heuristic_lib.cpython-311.pyc -------------------------------------------------------------------------------- /examples/dm/crow/08-simple-heuristic/simple-heuristic-domain-without-heuristic.cdl: -------------------------------------------------------------------------------- 1 | domain "grid" 2 | 3 | typedef delta: vector[int64, 2] 4 | typedef loc: vector[int64, 2] 5 | 6 | feature [[state]] robot_loc() -> loc 7 | 8 | def wall_at(l: loc) -> bool 9 | def l1_distance(a: loc, b: loc) -> float32 10 | 11 | def robot_at(l: loc) -> bool : 12 | return robot_loc() == l 13 | 14 | controller move(d: loc): 15 | eff: 16 | robot_loc = robot_loc + d 17 | 18 | behavior move_to(target: loc, d: loc) : # had to change type of d from delta 19 | body: 20 | preamble: 21 | assert not wall_at(target) 22 | let prev_loc : loc = target - d 23 | achieve_once robot_loc() == prev_loc 24 | move(d) 25 | 26 | behavior move_to_wrapper(target: loc): 27 | goal: robot_loc() == target 28 | body: 29 | alternative: 30 | move_to(target, loc([0, 1])) 31 | move_to(target, loc([0, -1])) 32 | move_to(target, loc([1, 0])) 33 | move_to(target, loc([-1, 0])) 34 | 35 | -------------------------------------------------------------------------------- /examples/dm/crow/08-simple-heuristic/simple-heuristic-domain.cdl: -------------------------------------------------------------------------------- 1 | domain "grid" 2 | 3 | typedef delta: vector[int64, 2] 4 | typedef loc: vector[int64, 2] 5 | 6 | feature [[state]] robot_loc() -> loc 7 | feature [[state]] cost() -> float32 8 | 9 | def wall_at(l: loc) -> bool 10 | def l1_distance(a: loc, b: loc) -> float32 11 | 12 | def robot_at(l: loc) -> bool : 13 | return robot_loc() == l 14 | 15 | controller move(d: loc): 16 | eff: 17 | robot_loc = robot_loc + d 18 | cost += 1.0 19 | 20 | behavior move_to(target: loc, d: loc) : # had to change type of d from delta 21 | body: 22 | preamble: 23 | assert not wall_at(target) 24 | let prev_loc : loc = target - d 25 | achieve_once robot_loc() == prev_loc 26 | move(d) 27 | 28 | behavior move_to_wrapper(target: loc): 29 | goal: robot_loc() == target 30 | body: 31 | alternative: 32 | move_to(target, loc([0, 1])) 33 | move_to(target, loc([0, -1])) 34 | move_to(target, loc([1, 0])) 35 | move_to(target, loc([-1, 0])) 36 | heuristic: 37 | cost += l1_distance(robot_loc(), target) 38 | 39 | -------------------------------------------------------------------------------- /examples/dm/crow/08-simple-heuristic/simple-heuristic-prob1-without-heuristic.cdl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env cdl-plan 2 | 3 | problem "grid-prob1" 4 | domain "simple-heuristic-domain-without-heuristic.cdl" 5 | 6 | #!pragma load_implementation("./simple_heuristic_lib.py") 7 | #!pragma planner_algo = "priority_tree_v1" 8 | #!pragma planner_enable_state_hash = False 9 | #!pragma planner_priority_fn = "unit_cost_astar" 10 | 11 | init: 12 | robot_loc[...] = loc([0, 1]) 13 | 14 | behavior __goal__(): 15 | body: 16 | achieve robot_loc() == loc([3, 3]) 17 | 18 | -------------------------------------------------------------------------------- /examples/dm/crow/08-simple-heuristic/simple-heuristic-prob1.cdl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env cdl-plan 2 | 3 | problem "grid-prob1" 4 | domain "simple-heuristic-domain.cdl" 5 | 6 | #!pragma load_implementation("./simple_heuristic_lib.py") 7 | #!pragma planner_algo = "priority_tree_v1" 8 | #!pragma planner_enable_state_hash = False 9 | #!pragma planner_priority_fn = "simple_additive_astar" 10 | 11 | init: 12 | robot_loc[...] = loc([0, 1]) 13 | 14 | behavior __goal__(): 15 | minimize: cost() 16 | body: 17 | achieve robot_loc() == loc([3, 3]) 18 | 19 | -------------------------------------------------------------------------------- /examples/dm/crow/08-simple-heuristic/simple_heuristic_lib.py: -------------------------------------------------------------------------------- 1 | import jacinle 2 | import torch 3 | import concepts.dm.crow as crow 4 | 5 | walls = {(1, 1)} 6 | 7 | 8 | @crow.config_function_implementation 9 | def l1_distance(loc1: torch.Tensor, loc2: torch.Tensor) -> float: 10 | return torch.sum(torch.abs(loc1 - loc2)) 11 | 12 | 13 | @crow.config_function_implementation 14 | def wall_at(loc: torch.Tensor) -> bool: 15 | x = tuple(loc.tolist()) 16 | 17 | if x[0] < 0 or x[0] > 3 or x[1] < 0 or x[1] > 3: 18 | return True 19 | 20 | if x in walls: 21 | return True 22 | 23 | return False 24 | 25 | -------------------------------------------------------------------------------- /examples/dm/crow/09-simple-cost/preference-demo.cdl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env cdl-plan 2 | 3 | # This example demonstrates how we can declare preferences between behaviors. 4 | # In this example, we have two behaviors, achieve_q1 and achieve_q2, that both 5 | # achieve the same goal, q(x). The difference between the two behaviors is that 6 | # achieve_q1 has a higher cost than achieve_q2. We want to prefer achieve_q2 7 | # over achieve_q1 because it has a lower cost. This essentially means that we 8 | # prefer achieve_q2 over achieve_q1. 9 | 10 | problem "preference-demo" 11 | domain "__empty__" 12 | 13 | #!pragma planner_algo="priority_tree_v1" 14 | #!pragma planner_priority_fn="simple_additive_astar" 15 | 16 | typedef Object: object 17 | 18 | feature p(x: Object) -> bool 19 | feature q(x: Object) -> bool 20 | feature cost() -> float32 21 | 22 | controller make_q1(x: Object) 23 | controller make_q2(x: Object, y: Object) 24 | 25 | behavior achieve_q1(x: Object): 26 | goal: q(x) 27 | body: 28 | do make_q1(x) 29 | eff: 30 | q[x] = True 31 | cost += 2. 32 | 33 | behavior achieve_q2(x: Object): 34 | goal: q(x) 35 | body: 36 | bind y: Object where: 37 | p(y) 38 | do make_q2(x, y) 39 | eff: 40 | q[x] = True 41 | p[y] = False 42 | cost += 1. 43 | 44 | objects: 45 | A, B, C: Object 46 | 47 | init: 48 | p[A] = True 49 | 50 | behavior __goal__(): 51 | minimize: cost() 52 | body: 53 | achieve q(C) 54 | -------------------------------------------------------------------------------- /examples/dm/crow/11-simulation-interface-example/domain.cdl: -------------------------------------------------------------------------------- 1 | domain "simulator-example" 2 | 3 | typedef Object: object 4 | 5 | feature f(x: Object) -> float32 6 | 7 | controller ctl(x: Object, a: float32) 8 | 9 | def [[simulation]] valid_goal_f(f: float32) -> bool 10 | def [[generator_placeholder]] valid_action(x: Object, a: float32) -> bool 11 | 12 | generator gen_valid_action(x: Object, a: float32): 13 | goal: valid_action(x, a) 14 | in: x 15 | out: a 16 | 17 | behavior b1(x: Object): 18 | goal: valid_goal_f(f(x)) 19 | body: 20 | bind a: float32 where: valid_action(x, a) 21 | ctl(x, a) 22 | eff: 23 | [[simulation]] f[x] = ... 24 | 25 | -------------------------------------------------------------------------------- /examples/dm/crow/12-harder-pick-place/franka_base.cdl: -------------------------------------------------------------------------------- 1 | domain "franka-base" 2 | 3 | typedef Object: object 4 | typedef Pose: vector[float32] # The 6D pose of an object. Internally represented as (x, y, z, qx, qy, qz, qw). 5 | typedef QPos: vector[float32] # The 7D joint configuration of a robot. 6 | 7 | feature qpos() -> QPos 8 | feature pose_of(object: Object) -> Pose 9 | feature holding(object: Object) -> bool 10 | 11 | typedef Trajectory: pyobject # Trajectory is of Python type RobotQPosPath 12 | 13 | controller move_ctl(trajectory: Trajectory) 14 | controller grasp_ctl(x: Object) 15 | controller open_gripper_ctl() 16 | controller close_gripper_ctl() 17 | -------------------------------------------------------------------------------- /examples/dm/crow/12-harder-pick-place/pick-place-domain.qddl: -------------------------------------------------------------------------------- 1 | (define 2 | (domain tabletop) 3 | 4 | (:object-types 5 | (panda-type "package://concepts/robots/franka_description/robots/panda_arm_hand.urdf") 6 | (workspace-type "package://concepts/basic/plane/workspace.urdf") 7 | (table-type "package://concepts/basic/plane/plane.urdf") 8 | (cube-type "package://concepts/basic/box/box-template.urdf") 9 | (box-type "package://concepts/basic/container/container-template.urdf") 10 | ) 11 | 12 | (:predicates 13 | (in ?obj ?region) 14 | (on ?obj ?obj) 15 | ) 16 | ) 17 | -------------------------------------------------------------------------------- /examples/dm/crow/12-harder-pick-place/pick-place-problem0.qddl: -------------------------------------------------------------------------------- 1 | (define 2 | (problem simple-cube-in-box) 3 | (:domain tabletop) 4 | (:objects 5 | world - qr::world-type 6 | panda - panda-type 7 | workspace - workspace-type 8 | table - table-type 9 | cube - cube-type 10 | box - box-type 11 | ) 12 | (:init 13 | (weld world::world workspace (1, 0, 0, 0, 0, 0)) 14 | (weld world::world table (0, 0, -0.001, 0, 0, 0)) 15 | (weld world::world panda (0, 0, 0, 0, 0, 0)) 16 | (weld world::world box (0.5, -0.3, 0.05, 0, 0, 0)) 17 | 18 | ;; PANDA_JOINT_HOMES = np.array([-0.45105, -0.38886, 0.45533, -2.19163, 0.13169, 1.81720, 0.51563]) 19 | (joint-conf panda::panda_joint1 -0.45105) 20 | (joint-conf panda::panda_joint2 -0.38886) 21 | (joint-conf panda::panda_joint3 0.45533) 22 | (joint-conf panda::panda_joint4 -2.19163) 23 | (joint-conf panda::panda_joint5 0.13169) 24 | (joint-conf panda::panda_joint6 1.81720) 25 | (joint-conf panda::panda_joint7 0.51563) 26 | 27 | (body-pose cube (0.5, 0.3, 0.025, 0, 0, 0)) 28 | 29 | (urdf::prop box "DIM" (0.2, 0.2, 0.1)) 30 | (urdf::prop box "HALF" (0.1, 0.1, 0.05)) 31 | ;; rgba is directly set through the load_urdf function so we are listing it as a urdf-load-arg here 32 | (urdf::load-arg box "rgba" (0.5, 1.0, 0.5, 1.0)) 33 | (urdf::prop cube "DIM" (0.05, 0.05, 0.05)) 34 | (urdf::prop cube "HALF" (0.025, 0.025, 0.025)) 35 | (urdf::prop cube "MASS" 0.2) 36 | (urdf::prop cube "LATERAL_FRICTION" 1.0) 37 | ;; rgba is directly set through the load_urdf function so we are listing it as a urdf-load-arg here 38 | (urdf::prop cube "COLOR" (1.0, 0.34, 0.34, 1.0)) 39 | 40 | (sim::camera-distance 1.5) 41 | (sim::camera-yaw 90) 42 | (sim::camera-pitch -25) 43 | (sim::camera-look-at (0, 0, 0)) 44 | ) 45 | (:goal (and 46 | (on cube box) 47 | )) 48 | ) -------------------------------------------------------------------------------- /examples/dm/crow/12-harder-pick-place/pick-place-problem1.qddl: -------------------------------------------------------------------------------- 1 | (define 2 | (problem simple-cube-in-box) 3 | (:domain tabletop) 4 | (:objects 5 | world - qr::world-type 6 | panda - panda-type 7 | workspace - workspace-type 8 | table - table-type 9 | box - box-type 10 | cube1 - cube-type 11 | cube2 - cube-type 12 | ) 13 | (:init 14 | (weld world::world workspace (1, 0, 0, 0, 0, 0)) 15 | (weld world::world table (0, 0, -0.001, 0, 0, 0)) 16 | (weld world::world panda (0, 0, 0, 0, 0, 0)) 17 | 18 | ;; PANDA_JOINT_HOMES = np.array([-0.45105, -0.38886, 0.45533, -2.19163, 0.13169, 1.81720, 0.51563]) 19 | (joint-conf panda::panda_joint1 -0.45105) 20 | (joint-conf panda::panda_joint2 -0.38886) 21 | (joint-conf panda::panda_joint3 0.45533) 22 | (joint-conf panda::panda_joint4 -2.19163) 23 | (joint-conf panda::panda_joint5 0.13169) 24 | (joint-conf panda::panda_joint6 1.81720) 25 | (joint-conf panda::panda_joint7 0.51563) 26 | 27 | (weld world::world box (0.5, -0.3, 0.05, 0, 0, 0)) 28 | (urdf::prop box "DIM" (0.2, 0.2, 0.1)) 29 | (urdf::prop box "HALF" (0.1, 0.1, 0.05)) 30 | ;; rgba is directly set through the load_urdf function so we are listing it as a urdf-load-arg here 31 | (urdf::load-arg box "rgba" (0.5, 1.0, 0.5, 1.0)) 32 | 33 | (body-pose cube1 (0.5, 0.3, 0.025, 0, 0, 0)) 34 | (urdf::prop cube1 "DIM" (0.05, 0.05, 0.05)) 35 | (urdf::prop cube1 "HALF" (0.025, 0.025, 0.025)) 36 | (urdf::prop cube1 "MASS" 0.2) 37 | (urdf::prop cube1 "LATERAL_FRICTION" 1.0) 38 | (urdf::prop cube1 "COLOR" (1.0, 0.34, 0.34, 1.0)) 39 | 40 | (body-pose cube2 (0.5, 0.3, 0.075, 0, 0, 0)) 41 | (urdf::prop cube2 "DIM" (0.05, 0.05, 0.05)) 42 | (urdf::prop cube2 "HALF" (0.025, 0.025, 0.025)) 43 | (urdf::prop cube2 "MASS" 0.2) 44 | (urdf::prop cube2 "LATERAL_FRICTION" 1.0) 45 | (urdf::prop cube2 "COLOR" (0.34, 1.0, 0.34, 1.0)) 46 | 47 | (sim::camera-distance 1.5) 48 | (sim::camera-yaw 90) 49 | (sim::camera-pitch -25) 50 | (sim::camera-look-at (0, 0, 0)) 51 | ) 52 | (:goal (and 53 | (on cube1 box) 54 | )) 55 | ) -------------------------------------------------------------------------------- /examples/dm/crow/12-harder-pick-place/pick-place-problem3.qddl: -------------------------------------------------------------------------------- 1 | (define 2 | (problem simple-cube-in-box) 3 | (:domain tabletop) 4 | (:objects 5 | world - qr::world-type 6 | panda - panda-type 7 | workspace - workspace-type 8 | table - table-type 9 | cube1 - cube-type 10 | cube2 - cube-type 11 | cube3 - cube-type 12 | ) 13 | (:init 14 | (weld world::world workspace (1, 0, 0, 0, 0, 0)) 15 | (weld world::world table (0, 0, -0.001, 0, 0, 0)) 16 | (weld world::world panda (0, 0, 0, 0, 0, 0)) 17 | 18 | ;; PANDA_JOINT_HOMES = np.array([-0.45105, -0.38886, 0.45533, -2.19163, 0.13169, 1.81720, 0.51563]) 19 | (joint-conf panda::panda_joint1 -0.45105) 20 | (joint-conf panda::panda_joint2 -0.38886) 21 | (joint-conf panda::panda_joint3 0.45533) 22 | (joint-conf panda::panda_joint4 -2.19163) 23 | (joint-conf panda::panda_joint5 0.13169) 24 | (joint-conf panda::panda_joint6 1.81720) 25 | (joint-conf panda::panda_joint7 0.51563) 26 | 27 | (body-pose cube1 (0.5, 0.3, 0.025, 0, 0, 0)) 28 | (urdf::prop cube1 "DIM" (0.05, 0.05, 0.05)) 29 | (urdf::prop cube1 "HALF" (0.025, 0.025, 0.025)) 30 | (urdf::prop cube1 "MASS" 0.2) 31 | (urdf::prop cube1 "LATERAL_FRICTION" 1.0) 32 | (urdf::prop cube1 "COLOR" (1.0, 0.34, 0.34, 1.0)) 33 | 34 | (body-pose cube2 (0.5, 0.3, 0.075, 0, 0, 0)) 35 | (urdf::prop cube2 "DIM" (0.05, 0.05, 0.05)) 36 | (urdf::prop cube2 "HALF" (0.025, 0.025, 0.025)) 37 | (urdf::prop cube2 "MASS" 0.2) 38 | (urdf::prop cube2 "LATERAL_FRICTION" 1.0) 39 | (urdf::prop cube2 "COLOR" (0.34, 1.0, 0.34, 1.0)) 40 | 41 | (body-pose cube3 (0.5, -0.3, 0.025, 0, 0, 0)) 42 | (urdf::prop cube3 "DIM" (0.05, 0.05, 0.05)) 43 | (urdf::prop cube3 "HALF" (0.025, 0.025, 0.025)) 44 | (urdf::prop cube3 "MASS" 0.2) 45 | (urdf::prop cube3 "LATERAL_FRICTION" 1.0) 46 | (urdf::prop cube3 "COLOR" (0.34, 0.34, 1.0, 1.0)) 47 | 48 | (sim::camera-distance 1.5) 49 | (sim::camera-yaw 90) 50 | (sim::camera-pitch -25) 51 | (sim::camera-look-at (0, 0, 0)) 52 | ) 53 | (:goal (and 54 | (on cube3 cube2) (on cube1 cube3) 55 | )) 56 | ) 57 | -------------------------------------------------------------------------------- /examples/dm/crow/lisdf-utils/README.md: -------------------------------------------------------------------------------- 1 | Example command: 2 | 3 | ```bash 4 | python3 tar-qddl.py ../12-harder-pick-place/pick-place-domain.qddl ../12-harder-pick-place/pick-place-problem1.qddl --output ./problem1 5 | ``` 6 | 7 | -------------------------------------------------------------------------------- /examples/dm/crow/lisdf-utils/vis_qddl.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : 2-load-qddl-scene.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 04/1/2024 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | import os.path as osp 12 | from concepts.simulator.pybullet.client import BulletClient 13 | from concepts.simulator.pybullet.qddl_interface import PyBulletQDDLInterface 14 | 15 | 16 | def build_env(args): 17 | client = BulletClient(is_gui=True, render_fps=120, additional_title=args.title) 18 | qddl_interface = PyBulletQDDLInterface(client) 19 | 20 | domain_qddl_filename = args.domain 21 | problem_qddl_filename = args.problem 22 | qddl_interface.load_scene(domain_qddl_filename, problem_qddl_filename) 23 | 24 | client.wait_forever() 25 | 26 | 27 | if __name__ == '__main__': 28 | import argparse 29 | 30 | parser = argparse.ArgumentParser() 31 | parser.add_argument('domain', type=str) 32 | parser.add_argument('problem', type=str) 33 | parser.add_argument('--title', type=str, default='QDDL Scene') 34 | args = parser.parse_args() 35 | 36 | build_env(args) 37 | 38 | -------------------------------------------------------------------------------- /examples/gui/infinite-corridor.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/concepts-ai/Concepts/13847828a1ecb8f0d8c43a420a2a1ad234cfe242/examples/gui/infinite-corridor.jpg -------------------------------------------------------------------------------- /examples/gui/tk/point_picker.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : point_picker.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 07/29/2024 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | import os.path as osp 12 | from typing import Tuple 13 | from concepts.gui.tk.point_picker import get_click_coordinates_from_image_path 14 | 15 | 16 | def main(): 17 | image_path = osp.join( 18 | osp.dirname(osp.dirname(__file__)), 19 | 'infinite-corridor.jpg' 20 | ) 21 | 22 | coords = get_click_coordinates_from_image_path(image_path, min_dimension=800) 23 | print('Clicked coordinates:', coords) 24 | 25 | 26 | if __name__ == '__main__': 27 | main() 28 | -------------------------------------------------------------------------------- /examples/hw_interface/franka/run-deoxys-server.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : run-deoxys-server.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 09/11/2024 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | from concepts.hw_interface.franka.deoxys_server import DeoxysService 12 | 13 | 14 | def main(): 15 | server = DeoxysService({}, mock=True) 16 | server.serve_socket() 17 | 18 | 19 | if __name__ == '__main__': 20 | main() 21 | 22 | -------------------------------------------------------------------------------- /examples/hw_interface/franka/test-deoxys-client.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : test-deoxys-client.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 09/11/2024 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | from concepts.hw_interface.franka.deoxys_server import DeoxysClient 12 | 13 | 14 | def main(): 15 | client = DeoxysClient('localhost') 16 | 17 | client.single_move_qpos(1, [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7]) 18 | 19 | 20 | if __name__ == '__main__': 21 | main() 22 | 23 | -------------------------------------------------------------------------------- /examples/simulator/pybullet/panda_robot/visualize-panda-workspace.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : visualize-panda-workspace.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 10/11/2024 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | from concepts.simulator.pybullet.client import BulletClient 12 | from concepts.benchmark.manip_tabletop.pybullet_tabletop_base.pybullet_tabletop import TableTopEnv 13 | from concepts.simulator.pybullet.components.panda.panda_robot import PandaRobot 14 | 15 | 16 | def main(): 17 | bclient = BulletClient(is_gui=True) 18 | env = TableTopEnv(bclient) 19 | env.add_workspace_boundary((-0.2, 2.0), (-1.0, 1.0), (-0.1, 1.5)) 20 | env.add_robot('panda', robot_kwargs={'version': 'soft_finger'}) 21 | 22 | print(env.world.link_names.int_to_string) 23 | 24 | bclient.wait_forever() 25 | 26 | 27 | if __name__ == '__main__': 28 | main() 29 | -------------------------------------------------------------------------------- /examples/vision/_assets/movo-rgbd-test.pkl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/concepts-ai/Concepts/13847828a1ecb8f0d8c43a420a2a1ad234cfe242/examples/vision/_assets/movo-rgbd-test.pkl -------------------------------------------------------------------------------- /examples/vision/_assets/realsense-hook-test.pkl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/concepts-ai/Concepts/13847828a1ecb8f0d8c43a420a2a1ad234cfe242/examples/vision/_assets/realsense-hook-test.pkl -------------------------------------------------------------------------------- /examples/vision/depth_smoother/encode-hook-data.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : encode-scooper-data.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 07/31/2024 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | import os.path as osp 12 | 13 | import cv2 14 | import numpy as np 15 | import PIL.Image as Image 16 | import jacinle.io as io 17 | 18 | 19 | def load_rgbd(base_path, index, camera_index=0): 20 | rgb = Image.open(osp.join(base_path, str(index), f'rgb_{camera_index}.png')) 21 | rgb = np.asarray(rgb)[..., :3][..., ::-1] 22 | depth = np.load(osp.join(base_path, str(index), f'depth_{camera_index}.npy')) 23 | return rgb, depth / 1000 24 | 25 | 26 | def load_intrinsics_and_extrinsics(base_path, camera_index=0): 27 | intrinsics = np.load(osp.join(base_path, f'intrinsics_{camera_index}.npy')) 28 | extrinsics = np.load(osp.join(base_path, f'extrinsics_{camera_index}.pkl'), allow_pickle=True) 29 | return intrinsics, extrinsics 30 | 31 | 32 | def main(): 33 | base_dir = '/Users/jiayuanm/Downloads/double_camera_hook/scooper' 34 | 35 | output = {'cameras': []} 36 | for j in range(2): 37 | i = 1 # Only read the first frame 38 | rgb, depth = load_rgbd(base_dir, i, j) 39 | intrinsics, extrinsics = load_intrinsics_and_extrinsics(base_dir, j) 40 | 41 | depth = (1000 * depth).astype(np.uint16) 42 | 43 | this_camera = { 44 | 'rgb': cv2.imencode('.png', rgb)[1], 45 | 'depth': cv2.imencode('.png', depth)[1], 46 | 'intrinsics': intrinsics, 47 | 'extrinsics': extrinsics 48 | } 49 | output['cameras'].append(this_camera) 50 | 51 | io.dump('./realsense-hook-test.pkl', output) 52 | 53 | 54 | if __name__ == '__main__': 55 | main() 56 | 57 | -------------------------------------------------------------------------------- /examples/vision/franka_system_calibration/.gitignore: -------------------------------------------------------------------------------- 1 | /realsense_data 2 | -------------------------------------------------------------------------------- /examples/vision/franka_system_calibration/test-ar-tag-detection.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : test-ar-tag-detection.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 09/01/2024 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | import cv2 12 | import numpy as np 13 | 14 | import jacinle 15 | from concepts.vision.franka_system_calibration.ar_detection import get_ar_tag_detections, visualize_ar_tag_detections, get_ar_tag_poses_from_camera_pose 16 | 17 | 18 | def test_ar_tag_detection(): 19 | parser = jacinle.JacArgumentParser() 20 | parser.add_argument('--image', required=True) 21 | args = parser.parse_args() 22 | 23 | img = cv2.imread(args.image) 24 | dets = get_ar_tag_detections(img) 25 | print(dets) 26 | 27 | visualize_ar_tag_detections(img, dets) 28 | 29 | 30 | def test_ar_tag_pose_estimation(): 31 | parser = jacinle.JacArgumentParser() 32 | parser.add_argument('--image', required=True) 33 | args = parser.parse_args() 34 | 35 | img = cv2.imread(args.image) 36 | dets = get_ar_tag_detections(img) 37 | print(dets) 38 | 39 | poses = get_ar_tag_poses_from_camera_pose(dets, camera_intrinsics=np.eye(3), camera_pose=np.eye(4)) 40 | print(poses) 41 | 42 | 43 | if __name__ == '__main__': 44 | # test_ar_tag_detection() 45 | test_ar_tag_pose_estimation() -------------------------------------------------------------------------------- /examples/vision/george_vision_pipeline/object_centric_vision/.gitignore: -------------------------------------------------------------------------------- 1 | /data 2 | /calibration* 3 | -------------------------------------------------------------------------------- /examples/vision/george_vision_pipeline/object_centric_vision/install.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | # 3 | # install.sh 4 | # Copyright (C) 2023 Jiayuan Mao 5 | # 6 | # Distributed under terms of the MIT license. 7 | # 8 | # 9 | # Iteratively parse the arguments 10 | while [[ $# -gt 0 ]]; do 11 | key="$1" 12 | case $key in 13 | -h|--help) 14 | echo "Usage: $0 [-h|--help] [--install-pytorch]" 15 | exit 0 16 | ;; 17 | --install-pytorch) 18 | echo 'Install pytorch' 19 | conda install pytorch torchvision -c pytorch 20 | shift 21 | ;; 22 | *) 23 | echo "Unknown option: $1" 24 | exit 1 25 | ;; 26 | esac 27 | done 28 | 29 | echo "Install neovim python bindings" 30 | conda install neovim 31 | echo "Install python LSP" 32 | pip install python-lsp-server 33 | echo "Install scipy scikit-learn pandas matplotlib numpy tqdm pyyaml ipdb" 34 | conda install scipy scikit-learn pandas matplotlib numpy tqdm pyyaml 35 | echo "Install Open3d" 36 | conda install open3d -c open3d-admin 37 | -------------------------------------------------------------------------------- /examples/vision/george_vision_pipeline/object_centric_vision/test-sam-all.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : 1.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 09/20/2023 7 | # 8 | # Distributed under terms of the MIT license. 9 | 10 | import cv2 11 | import sys 12 | import matplotlib.pyplot as plt 13 | import matplotlib.patches as patches 14 | import numpy as np 15 | from segment_anything import SamAutomaticMaskGenerator, sam_model_registry 16 | 17 | print('Usage: python3 test-sam-all.py ') 18 | 19 | if len(sys.argv) != 2: 20 | print('Invalid arguments.') 21 | exit(1) 22 | 23 | print('Loading the SAM model...') 24 | sam = sam_model_registry['default'](checkpoint="./data/sam_vit_h_4b8939.pth") 25 | mask_generator = SamAutomaticMaskGenerator(sam) 26 | 27 | print('Loading and segmenting the image...') 28 | img = cv2.imread(sys.argv[1]) 29 | masks = mask_generator.generate(img) 30 | 31 | segmentation_masks = list() 32 | for mask in masks: 33 | segmentation_masks.append(mask['segmentation']) 34 | 35 | # visualize the segmentation masks 36 | # each mask is a image 37 | for mask in segmentation_masks: 38 | # 1 x 2 plot, first is the original image, second is the mask 39 | fig, ax = plt.subplots(1, 2) 40 | ax[0].imshow(img) 41 | ax[1].imshow(mask) 42 | plt.show() 43 | 44 | 45 | # visualize the union of the all masks 46 | 47 | union_mask = np.zeros_like(segmentation_masks[0], dtype=np.uint8) 48 | for i, mask in enumerate(segmentation_masks[4:]): 49 | union_mask[mask > 0] = i 50 | 51 | fig, axes = plt.subplots(1, 2, figsize=(10, 5)) 52 | axes[0].imshow(img) 53 | axes[1].imshow(union_mask) 54 | plt.show() 55 | 56 | -------------------------------------------------------------------------------- /examples/vision/george_vision_pipeline/object_centric_vision/test-sam.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : test-sam.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 08/05/2023 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | import jacinle 12 | import numpy as np 13 | import cv2 14 | from segment_anything import SamPredictor, sam_model_registry 15 | 16 | pickle = jacinle.load('./data-000001.pkl') 17 | img = pickle['color_image'][..., ::-1] 18 | 19 | sam = sam_model_registry["default"](checkpoint="./sam_vit_h_4b8939.pth") 20 | predictor = SamPredictor(sam) 21 | predictor.set_image(img) 22 | 23 | pos = (1136, 471) 24 | 25 | def record_pos(event, x, y, flags, param): 26 | global pos 27 | if event == cv2.EVENT_LBUTTONDOWN: 28 | pos = (x, y) 29 | 30 | 31 | def remove_remains(img, interest_point): 32 | """ 33 | Remove remains which are not adjacent with interest_point 34 | :param img: Input image 35 | :param interest_point: Center point where we want to remain 36 | :return: Image which adjacent with interest_point 37 | """ 38 | img = img.astype(np.uint8) 39 | h, w = img.shape[:2] 40 | mask = np.zeros((h + 2, w + 2), np.uint8) 41 | 42 | img_inv = img.copy() 43 | cv2.floodFill(img_inv, mask, tuple(interest_point), 0) 44 | img -= img_inv 45 | 46 | return img 47 | 48 | 49 | while True: 50 | print('Runing at', pos) 51 | masks, _, _ = predictor.predict(point_coords=np.array([pos]), point_labels=np.array([1])) 52 | print('Number of masks:', len(masks)) 53 | visualize = img.copy()[..., ::-1] 54 | mask = masks[-2].astype(np.uint8) 55 | mask = remove_remains(mask, pos) 56 | 57 | overlay = (mask > 0).astype(np.uint8)[:, :, None] * np.array([0, 255, 0], dtype=np.uint8) 58 | visualize = cv2.addWeighted(visualize, 1, overlay.astype('uint8'), 0.5, 0) 59 | 60 | cv2.circle(visualize, pos, 10, (255, 255, 0), -1) 61 | cv2.imshow('image', visualize) 62 | cv2.imshow('mask', overlay.astype('uint8')) 63 | cv2.setMouseCallback('image', record_pos) 64 | if cv2.waitKey(-1) & 0xFF == ord('q'): 65 | break 66 | 67 | -------------------------------------------------------------------------------- /examples/vision/qr_pipeline/.gitignore: -------------------------------------------------------------------------------- 1 | /qr_data/**/*.pkl 2 | -------------------------------------------------------------------------------- /examples/vision/qr_pipeline/1-visualize-data.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # File : 1-visualize-data.py 4 | # Author : Jiayuan Mao 5 | # Email : maojiayuan@gmail.com 6 | # Date : 08/5/2024 7 | # 8 | # This file is part of Project Concepts. 9 | # Distributed under terms of the MIT license. 10 | 11 | import open3d as o3d 12 | import numpy as np 13 | import jacinle 14 | from concepts.vision.george_vision_pipeline.object_centric_vision import CameraTransformation 15 | 16 | parser = jacinle.JacArgumentParser() 17 | parser.add_argument('--data', required=True, type='checked_file') 18 | args = parser.parse_args() 19 | 20 | def patch_qr(): 21 | import os.path as osp 22 | import sys 23 | 24 | sys.path.insert(0, osp.expanduser('~/workspace/w-qr/QR/src')) 25 | 26 | 27 | def main(): 28 | patch_qr() 29 | data = jacinle.load(args.data) 30 | jacinle.stprint(data, indent_format=' ') 31 | 32 | while True: 33 | query = input('Input the index to visualize. Format : ') 34 | if query == 'exit': 35 | break 36 | try: 37 | camera_index = map(int, query) 38 | except: 39 | print('Invalid input.') 40 | continue 41 | 42 | image_capture = vars(data[0][camera_index]) 43 | 44 | rgb = image_capture['rgb_image'] 45 | depth = image_capture['default_depth_image'] 46 | intrinsics, extrinsics = image_capture['camera_intrinsics'], image_capture['camera_extrinsics'] 47 | 48 | camera_model = CameraTransformation(intrinsics=intrinsics, extrinsics=extrinsics) 49 | x, y = np.meshgrid(np.arange(depth.shape[0]), np.arange(depth.shape[1]), indexing='ij') 50 | x, y, z = camera_model.c2w( 51 | x, y, 52 | depth 53 | ) 54 | xyz = np.stack([x, y, z], axis=-1) 55 | 56 | pcd = o3d.geometry.PointCloud() 57 | pcd.points = o3d.utility.Vector3dVector(xyz) 58 | pcd.colors = o3d.utility.Vector3dVector(rgb.reshape(-1, 3) / 255) 59 | 60 | coordinate = o3d.geometry.TriangleMesh.create_coordinate_frame(size=0.1) 61 | o3d.visualization.draw_geometries([pcd, coordinate]) 62 | 63 | 64 | if __name__ == '__main__': 65 | main() 66 | -------------------------------------------------------------------------------- /examples/vision/uncos/.gitignore: -------------------------------------------------------------------------------- 1 | /*.pth 2 | -------------------------------------------------------------------------------- /jacinle.yml: -------------------------------------------------------------------------------- 1 | project_root: true 2 | -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | [build-system] 2 | requires = [ 3 | "setuptools>=42", 4 | "wheel" 5 | ] 6 | build-backend = "setuptools.build_meta" 7 | --------------------------------------------------------------------------------