load("//tools/install:install.bzl", "install")
load("//tools/install:install_data.bzl", "install_data")
load("//tools/lint:lint.bzl", "add_lint_tests")
load(
    "//tools/skylark:drake_cc.bzl",
    "drake_cc_binary",
    "drake_cc_googletest",
    "drake_cc_library",
)
load("//tools/skylark:drake_data.bzl", "models_filegroup")

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

models_filegroup(
    name = "models",
    visibility = ["//visibility:public"],
)

install_data(
    name = "install_data",
    data = [":models"],
    visibility = ["//visibility:public"],
)

drake_cc_library(
    name = "planar_gripper_common",
    srcs = ["planar_gripper_common.cc"],
    hdrs = ["planar_gripper_common.h"],
    deps = [
        "//common:find_resource",
        "//multibody/plant",
        "//systems/lcm:lcm_interface_system",
    ],
)

drake_cc_library(
    name = "planar_gripper_lcm",
    srcs = ["planar_gripper_lcm.cc"],
    hdrs = ["planar_gripper_lcm.h"],
    deps = [
        "//lcmtypes:planar_gripper",
        "//systems/framework:leaf_system",
    ],
)

drake_cc_library(
    name = "planar_manipuland_lcm",
    srcs = ["planar_manipuland_lcm.cc"],
    hdrs = ["planar_manipuland_lcm.h"],
    deps = [
        "//lcmtypes:planar_manipuland_status",
        "//systems/framework:event_collection",
        "//systems/framework:leaf_system",
    ],
)

drake_cc_library(
    name = "brick_static_equilibrium_constraint",
    srcs = ["brick_static_equilibrium_constraint.cc"],
    hdrs = ["brick_static_equilibrium_constraint.h"],
    deps = [
        ":gripper_brick",
        ":gripper_brick_planning_constraint_helper",
        "//math:autodiff",
        "//multibody/inverse_kinematics:kinematic_evaluators",
        "//multibody/plant",
        "//solvers:constraint",
        "//solvers:mathematical_program",
    ],
)

drake_cc_library(
    name = "gripper_brick",
    srcs = ["gripper_brick.cc"],
    hdrs = ["gripper_brick.h"],
    data = [
        ":models",
    ],
    deps = [
        "//examples/planar_gripper:planar_gripper_common",
        "//geometry:drake_visualizer",
        "//multibody/parsing",
        "//multibody/plant",
        "//systems/analysis:simulator",
        "//systems/framework:diagram",
    ],
)

drake_cc_binary(
    name = "run_planar_gripper_trajectory_publisher",
    srcs = ["run_planar_gripper_trajectory_publisher.cc"],
    data = [
        ":models",
        "//examples/planar_gripper:postures.txt",
    ],
    deps = [
        ":planar_gripper_common",
        ":planar_gripper_lcm",
        "//lcm",
        "//multibody/parsing",
        "//systems/analysis:simulator",
        "//systems/lcm:lcm_pubsub_system",
        "//systems/primitives:constant_vector_source",
        "//systems/primitives:trajectory_source",
        "@gflags",
    ],
)

drake_cc_binary(
    name = "planar_gripper_simulation",
    srcs = ["planar_gripper_simulation.cc"],
    add_test_rule = 1,
    data = [
        ":models",
        "//examples/planar_gripper:postures.txt",
    ],
    test_rule_args = [
        "--simulation_time=0.1",
        "--target_realtime_rate=0",
    ],
    deps = [
        ":planar_gripper_common",
        ":planar_gripper_lcm",
        "//geometry:drake_visualizer",
        "//multibody/parsing",
        "//multibody/plant",
        "//multibody/plant:contact_results_to_lcm",
        "//systems/analysis:simulator",
        "//systems/controllers:inverse_dynamics_controller",
        "//systems/framework:diagram",
        "@gflags",
    ],
)

drake_cc_library(
    name = "gripper_brick_planning_constraint_helper",
    srcs = ["gripper_brick_planning_constraint_helper.cc"],
    hdrs = ["gripper_brick_planning_constraint_helper.h"],
    deps = [
        ":gripper_brick",
        "//multibody/inverse_kinematics:kinematic_evaluators",
        "//solvers:mathematical_program",
    ],
)

drake_cc_googletest(
    name = "gripper_brick_test",
    deps = [
        ":gripper_brick",
        "//common/test_utilities:eigen_matrix_compare",
    ],
)

drake_cc_googletest(
    name = "brick_static_equilibrium_constraint_test",
    deps = [
        ":brick_static_equilibrium_constraint",
        "//common/test_utilities:eigen_matrix_compare",
        "//math:compute_numerical_gradient",
    ],
)

drake_cc_googletest(
    name = "gripper_brick_planning_constraint_helper_test",
    deps = [
        ":gripper_brick_planning_constraint_helper",
        "//solvers:solve",
    ],
)

drake_cc_googletest(
    name = "planar_manipuland_lcm_test",
    deps = [
        ":planar_manipuland_lcm",
        "//systems/framework:diagram",
        "//systems/framework:diagram_builder",
    ],
)

drake_cc_googletest(
    name = "planar_gripper_lcm_test",
    deps = [
        ":planar_gripper_lcm",
        "//systems/framework:diagram",
        "//systems/framework:diagram_builder",
    ],
)

drake_cc_googletest(
    name = "planar_gripper_common_test",
    data = [
        ":models",
    ],
    deps = [
        ":planar_gripper_common",
        "//common/test_utilities:eigen_matrix_compare",
        "//multibody/parsing",
        "//multibody/plant",
    ],
)

add_lint_tests(enable_clang_format_lint = False)
