load("//tools/lint:lint.bzl", "add_lint_tests")
load(
    "//tools/skylark:drake_cc.bzl",
    "drake_cc_googletest",
    "drake_cc_library",
    "drake_cc_package_library",
)
load("//tools/skylark:test_tags.bzl", "gurobi_test_tags", "mosek_test_tags")

package(default_visibility = ["//visibility:public"])

drake_cc_package_library(
    name = "iris",
    visibility = ["//visibility:public"],
    deps = [
        ":iris_from_clique_cover",
    ],
)

drake_cc_library(
    name = "iris_from_clique_cover",
    srcs = ["iris_from_clique_cover.cc"],
    hdrs = ["iris_from_clique_cover.h"],
    interface_deps = [
        "//geometry/optimization:convex_set",
        "//geometry/optimization:iris",
        "//geometry:meshcat",
        "//planning/graph_algorithms:max_clique_solver_via_greedy",
        "//planning/graph_algorithms:max_clique_solver_base",
        "//solvers:gurobi_solver",
        "//solvers:mosek_solver",
        "//planning:scene_graph_collision_checker",
        "//planning:visibility_graph",
    ],
    deps = [
        "@common_robotics_utilities",
    ],
)

drake_cc_googletest(
    name = "iris_from_clique_cover_test",
    timeout = "moderate",
    data = [
        "//examples/pendulum:models",
        "//multibody/parsing:test_models",
    ],
    # Running with multiple threads is an essential part of our test coverage.
    num_threads = 4,
    shard_count = 4,
    # Most of these tests take an exceptionally long time under
    # instrumentation, resulting in timeouts, and so are excluded.
    # These test also can only be run with either mosek or gurobi enabled.
    tags = [
        "no_asan",
        "no_memcheck",
        # IPOPT is exceptionally slow with IRIS so only test with snopt.
        "snopt",
    ],
    deps = [
        ":iris_from_clique_cover",
        "//common/test_utilities:expect_throws_message",
        "//common/test_utilities:maybe_pause_for_user",
        "//geometry/test_utilities:meshcat_environment",
        "//multibody/parsing:parser",
        "//planning:robot_diagram_builder",
        "//planning:scene_graph_collision_checker",
        "//planning/graph_algorithms:max_clique_solver_via_mip",
        "//systems/framework:diagram_builder",
    ],
)

add_lint_tests()
