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

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

drake_cc_package_library(
    name = "schunk_wsg",
    visibility = ["//visibility:public"],
    deps = [
        ":build_schunk_wsg_control",
        ":schunk_wsg_constants",
        ":schunk_wsg_controller",
        ":schunk_wsg_driver",
        ":schunk_wsg_driver_functions",
        ":schunk_wsg_lcm",
        ":schunk_wsg_plain_controller",
        ":schunk_wsg_position_controller",
        ":schunk_wsg_trajectory_generator",
        ":schunk_wsg_trajectory_generator_state_vector",
    ],
)

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

drake_cc_library(
    name = "schunk_wsg_lcm",
    srcs = ["schunk_wsg_lcm.cc"],
    hdrs = ["schunk_wsg_lcm.h"],
    deps = [
        "//lcm:lcm_messages",
        "//lcmtypes:schunk",
        "//systems/framework:leaf_system",
        "//systems/primitives:matrix_gain",
    ],
)

drake_cc_library(
    name = "schunk_wsg_trajectory_generator_state_vector",
    srcs = [
        "schunk_wsg_trajectory_generator_state_vector.cc",
    ],
    hdrs = [
        "gen/schunk_wsg_trajectory_generator_state_vector.h",
        "schunk_wsg_trajectory_generator_state_vector.h",
    ],
    visibility = [":__subpackages__"],
    deps = [
        "//common:dummy_value",
        "//common:essential",
        "//common:name_value",
        "//common/symbolic:expression",
        "//systems/framework:vector",
    ],
)

drake_cc_library(
    name = "schunk_wsg_trajectory_generator",
    srcs = ["schunk_wsg_trajectory_generator.cc"],
    hdrs = ["schunk_wsg_trajectory_generator.h"],
    deps = [
        ":schunk_wsg_trajectory_generator_state_vector",
        "//common/trajectories:piecewise_polynomial",
        "//common/trajectories:trajectory",
        "//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_position_controller",
    srcs = ["schunk_wsg_position_controller.cc"],
    hdrs = ["schunk_wsg_position_controller.h"],
    deps = [
        "//systems/framework:leaf_system",
        "//systems/primitives:discrete_derivative",
    ],
)

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",
        ":schunk_wsg_trajectory_generator",
        "//common:essential",
        "//systems/framework:diagram",
        "//systems/framework:diagram_builder",
    ],
)

drake_cc_library(
    name = "build_schunk_wsg_control",
    srcs = ["build_schunk_wsg_control.cc"],
    hdrs = ["build_schunk_wsg_control.h"],
    deps = [
        ":schunk_wsg_constants",
        ":schunk_wsg_controller",
        ":schunk_wsg_lcm",
        "//common:essential",
        "//multibody/plant",
        "//systems/framework:diagram_builder",
        "//systems/lcm",
        "@eigen",
    ],
)

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

drake_cc_library(
    name = "schunk_wsg_driver_functions",
    srcs = ["schunk_wsg_driver_functions.cc"],
    hdrs = ["schunk_wsg_driver_functions.h"],
    deps = [
        ":build_schunk_wsg_control",
        ":schunk_wsg_driver",
        "//common:essential",
        "//multibody/parsing:model_instance_info",
        "//multibody/plant",
        "//systems/framework:diagram_builder",
        "//systems/lcm:lcm_buses",
    ],
)

# === test/ ===

drake_cc_googletest(
    name = "schunk_wsg_constants_test",
    data = [
        "@drake_models//:wsg_50_description",
    ],
    deps = [
        ":schunk_wsg_constants",
        "//multibody/parsing",
        "//multibody/plant",
    ],
)

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

drake_cc_googletest(
    name = "schunk_wsg_position_controller_test",
    data = [
        "@drake_models//:wsg_50_description",
    ],
    deps = [
        ":schunk_wsg_position_controller",
        "//common/test_utilities:eigen_matrix_compare",
        "//multibody/parsing",
        "//multibody/plant",
        "//systems/analysis:simulator",
    ],
)

drake_cc_googletest(
    name = "schunk_wsg_lcm_test",
    data = [
        "@drake_models//:wsg_50_description",
    ],
    deps = [
        ":schunk_wsg_lcm",
        "//common/test_utilities:eigen_matrix_compare",
        "//systems/analysis:simulator",
    ],
)

drake_cc_googletest(
    name = "schunk_wsg_trajectory_generator_test",
    data = [
        "@drake_models//:wsg_50_description",
    ],
    deps = [
        ":schunk_wsg_trajectory_generator",
        "//systems/analysis:simulator",
    ],
)

drake_cc_googletest(
    name = "build_schunk_wsg_control_test",
    data = [
        "@drake_models//:wsg_50_description",
    ],
    deps = [
        ":build_schunk_wsg_control",
        ":schunk_wsg_lcm",
        "//lcm",
        "//multibody/parsing:parser",
        "//multibody/plant",
        "//systems/analysis:simulator",
        "//systems/framework:diagram_builder",
        "//systems/lcm",
    ],
)

drake_cc_googletest(
    name = "schunk_wsg_driver_functions_test",
    data = [
        "@drake_models//:wsg_50_description",
    ],
    deps = [
        ":schunk_wsg_driver_functions",
        "//lcm:drake_lcm_params",
        "//multibody/parsing:parser",
        "//multibody/plant",
        "//systems/analysis:simulator",
        "//systems/framework:diagram_builder",
        "//systems/lcm:lcm_config_functions",
    ],
)

add_lint_tests()
