# -*- python -*-

load(
    "@drake//tools/skylark:drake_cc.bzl",
    "drake_cc_googletest",
    "drake_cc_library",
    "drake_cc_package_library",
)
load(
    "@drake//tools/vector_gen:vector_gen.bzl",
    "drake_cc_vector_gen_library",
)
load("//tools/lint:lint.bzl", "add_lint_tests")

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

drake_cc_package_library(
    name = "schunk_wsg",
    deps = [
        ":schunk_wsg_constants",
        ":schunk_wsg_controller",
        ":schunk_wsg_lcm",
        ":schunk_wsg_plain_controller",
        ":schunk_wsg_trajectory_generator_state_vector",
    ],
)

drake_cc_library(
    name = "schunk_wsg_constants",
    hdrs = ["schunk_wsg_constants.h"],
    deps = [
        "//common:essential",
    ],
)

drake_cc_vector_gen_library(
    name = "schunk_wsg_trajectory_generator_state_vector",
    srcs = ["schunk_wsg_trajectory_generator_state_vector.named_vector"],
    visibility = [":__subpackages__"],
)

drake_cc_library(
    name = "schunk_wsg_lcm",
    srcs = ["schunk_wsg_lcm.cc"],
    hdrs = ["schunk_wsg_lcm.h"],
    deps = [
        ":schunk_wsg_trajectory_generator_state_vector",
        "//common/trajectories:piecewise_polynomial",
        "//common/trajectories:trajectory",
        "//lcmtypes:schunk",
        "//systems/framework:leaf_system",
    ],
)

drake_cc_library(
    name = "schunk_wsg_plain_controller",
    srcs = ["schunk_wsg_plain_controller.cc"],
    hdrs = ["schunk_wsg_plain_controller.h"],
    deps = [
        ":schunk_wsg_constants",
        ":schunk_wsg_lcm",
        "//common:essential",
        "//systems/controllers:pid_controller",
        "//systems/framework:diagram",
        "//systems/framework:diagram_builder",
        "//systems/primitives",
    ],
)

drake_cc_library(
    name = "schunk_wsg_controller",
    srcs = ["schunk_wsg_controller.cc"],
    hdrs = ["schunk_wsg_controller.h"],
    deps = [
        ":schunk_wsg_constants",
        ":schunk_wsg_lcm",
        ":schunk_wsg_plain_controller",
        "//common:essential",
        "//systems/framework:diagram",
        "//systems/framework:diagram_builder",
    ],
)

# === test/ ===

drake_cc_googletest(
    name = "schunk_wsg_constants_test",
    data = [
        "//manipulation/models/wsg_50_description:models",
    ],
    deps = [
        ":schunk_wsg_constants",
        "//attic/multibody/parsers",
        "//common:find_resource",
        "//common/test_utilities:eigen_matrix_compare",
        "//multibody:rigid_body_tree",
    ],
)

drake_cc_googletest(
    name = "schunk_wsg_controller_test",
    deps = [
        ":schunk_wsg_constants",
        ":schunk_wsg_controller",
        "//systems/analysis:simulator",
    ],
)

drake_cc_googletest(
    name = "schunk_wsg_lcm_test",
    data = [
        "//manipulation/models/wsg_50_description:models",
    ],
    deps = [
        ":schunk_wsg_lcm",
        "//systems/analysis:simulator",
    ],
)

add_lint_tests()
