# -*- python -*-

load(
    "//tools:drake.bzl",
    "drake_cc_binary",
    "drake_cc_googletest",
    "drake_cc_library",
)
load("//tools/lint:lint.bzl", "add_lint_tests")

drake_cc_library(
    name = "simulated_schunk_wsg_system",
    srcs = ["simulated_schunk_wsg_system.cc"],
    hdrs = ["simulated_schunk_wsg_system.h"],
    deps = [
        "//attic/multibody/parsers",
        "//attic/multibody/rigid_body_plant",
        "//common:find_resource",
        "//manipulation/schunk_wsg",
    ],
)

drake_cc_binary(
    name = "schunk_wsg_simulation",
    srcs = ["schunk_wsg_simulation.cc"],
    add_test_rule = 1,
    data = [
        "//manipulation/models/wsg_50_description:models",
    ],
    test_rule_args = ["--simulation_sec=0.1"],
    # Flaky because LCM self-test can fail (PR #7311)
    test_rule_flaky = 1,
    deps = [
        ":simulated_schunk_wsg_system",
        "//attic/multibody/rigid_body_plant",
        "//attic/multibody/rigid_body_plant:drake_visualizer",
        "//lcm",
        "//lcmtypes:schunk",
        "//manipulation/schunk_wsg:schunk_wsg_constants",
        "//manipulation/schunk_wsg:schunk_wsg_controller",
        "//manipulation/schunk_wsg:schunk_wsg_lcm",
        "//systems/analysis:simulator",
        "//systems/framework",
        "//systems/lcm:lcm_pubsub_system",
        "@gflags",
    ],
)

# === test/ ===

drake_cc_googletest(
    name = "schunk_wsg_lift_test",
    timeout = "moderate",
    data = [
        "test/test_lifter.sdf",
        "//manipulation/models/wsg_50_description:models",
        "//multibody:models",
    ],
    # This test is prohibitively slow with --compilation_mode=dbg.
    disable_in_compilation_mode_dbg = True,
    # TODO(betsymcphail): Re-enable this test when it no longer
    # causes timeouts in kcov.
    tags = ["no_kcov"],
    deps = [
        "//attic/multibody/parsers",
        "//attic/multibody/rigid_body_plant",
        "//attic/multibody/rigid_body_plant:contact_results_to_lcm",
        "//attic/multibody/rigid_body_plant:drake_visualizer",
        "//common:essential",
        "//common:find_resource",
        "//common/trajectories:piecewise_polynomial",
        "//common/trajectories:trajectory",
        "//lcm",
        "//manipulation/schunk_wsg",
        "//multibody:rigid_body_tree",
        "//multibody:rigid_body_tree_construction",
        "//systems/analysis",
        "//systems/controllers:pid_controlled_system",
        "//systems/framework:diagram_builder",
        "//systems/primitives:constant_vector_source",
        "//systems/primitives:demultiplexer",
        "//systems/primitives:multiplexer",
        "//systems/primitives:trajectory_source",
    ],
)

drake_cc_googletest(
    name = "simulated_schunk_wsg_system_test",
    timeout = "moderate",
    data = [
        "//manipulation/models/wsg_50_description:models",
    ],
    deps = [
        ":simulated_schunk_wsg_system",
        "//attic/multibody/rigid_body_plant:drake_visualizer",
        "//lcm",
        "//systems/analysis:simulator",
        "//systems/framework:diagram",
        "//systems/primitives:constant_vector_source",
    ],
)

add_lint_tests()
