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

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

drake_cc_package_library(
    name = "util",
    visibility = ["//visibility:public"],
    deps = [
        ":apply_driver_configs",
        ":make_arm_controller_model",
        ":move_ik_demo_base",
        ":moving_average_filter",
        ":robot_plan_interpolator",
        ":robot_plan_utils",
        ":zero_force_driver",
        ":zero_force_driver_functions",
    ],
)

drake_cc_library(
    name = "move_ik_demo_base",
    srcs = [
        "move_ik_demo_base.cc",
    ],
    hdrs = [
        "move_ik_demo_base.h",
    ],
    deps = [
        ":robot_plan_utils",
        "//lcmtypes:robot_plan",
        "//multibody/inverse_kinematics:constraint_relaxing_ik",
        "//multibody/parsing",
        "//multibody/plant",
    ],
)

drake_cc_library(
    name = "robot_plan_utils",
    srcs = [
        "robot_plan_utils.cc",
    ],
    hdrs = [
        "robot_plan_utils.h",
    ],
    deps = [
        "//common:default_scalars",
        "//lcmtypes:robot_plan",
        "//multibody/plant",
    ],
)

# TODO(naveenoid) : Move the moving_average_filter to within drake/perception.
drake_cc_library(
    name = "moving_average_filter",
    srcs = ["moving_average_filter.cc"],
    hdrs = ["moving_average_filter.h"],
    deps = ["//common:essential"],
)

drake_cc_library(
    name = "apply_driver_configs",
    hdrs = ["apply_driver_configs.h"],
)

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

drake_cc_library(
    name = "zero_force_driver_functions",
    srcs = ["zero_force_driver_functions.cc"],
    hdrs = ["zero_force_driver_functions.h"],
    interface_deps = [
        ":zero_force_driver",
        "//multibody/parsing:model_instance_info",
        "//multibody/plant",
        "//systems/framework:diagram_builder",
        "//systems/lcm:lcm_buses",
    ],
    deps = [
        "//systems/primitives:constant_vector_source",
    ],
)

drake_cc_library(
    name = "make_arm_controller_model",
    srcs = ["make_arm_controller_model.cc"],
    hdrs = ["make_arm_controller_model.h"],
    deps = [
        "//math:geometric_transform",
        "//multibody/parsing",
        "//multibody/plant",
    ],
)

drake_cc_library(
    name = "robot_plan_interpolator",
    srcs = ["robot_plan_interpolator.cc"],
    hdrs = ["robot_plan_interpolator.h"],
    deps = [
        "//common/trajectories:piecewise_polynomial",
        "//lcmtypes:robot_plan",
        "//multibody/parsing",
        "//systems/framework:leaf_system",
    ],
)

drake_py_binary(
    name = "show_model",
    srcs = ["show_model.py"],
    deps = ["//bindings/pydrake"],
)

drake_py_binary(
    name = "meshlab_to_sdf",
    srcs = ["meshlab_to_sdf.py"],
)

drake_cc_binary(
    name = "stl2obj",
    srcs = ["stl2obj.cc"],
    visibility = ["//:__subpackages__"],
    deps = [
        "//common:add_text_logging_gflags",
        "//common:essential",
        "@gflags",
        "@vtk_internal//:vtkFiltersCore",
        "@vtk_internal//:vtkIOGeometry",
    ],
)

# === test/ ===

drake_cc_googletest(
    name = "move_ik_demo_base_test",
    data = [
        "@drake_models//:iiwa_description",
    ],
    deps = [
        ":move_ik_demo_base",
        "//manipulation/kuka_iiwa:iiwa_constants",
    ],
)

drake_cc_googletest(
    name = "robot_plan_utils_test",
    data = [
        "@drake_models//:iiwa_description",
    ],
    deps = [
        ":robot_plan_utils",
        "//multibody/parsing",
    ],
)

drake_cc_googletest(
    name = "moving_average_filter_test",
    srcs = ["test/moving_average_filter_test.cc"],
    deps = [
        ":moving_average_filter",
        "//common:essential",
        "//common/test_utilities:eigen_matrix_compare",
        "//common/test_utilities:expect_no_throw",
    ],
)

drake_cc_googletest(
    name = "zero_force_driver_functions_test",
    data = [
        "@drake_models//:wsg_50_description",
    ],
    deps = [
        ":zero_force_driver_functions",
        "//multibody/parsing",
        "//systems/analysis:simulator",
    ],
)

filegroup(
    name = "panda_arm_and_hand_test_model",
    testonly = 1,
    srcs = [
        ":test/panda_arm_and_hand.dmd.yaml",
        "@drake_models//:franka_description",
    ],
    visibility = ["//multibody/parsing:__pkg__"],
)

drake_cc_googletest(
    name = "make_arm_controller_model_test",
    data = [
        ":test/fake_camera.sdf",
        ":test/iiwa7_wsg.dmd.yaml",
        ":test/iiwa7_wsg_cameras.dmd.yaml",
        "@drake_models//:iiwa_description",
        "@drake_models//:wsg_50_description",
    ],
    deps = [
        ":make_arm_controller_model",
        "//common:find_resource",
        "//common/test_utilities:eigen_matrix_compare",
        "//math:geometric_transform",
        "//multibody/parsing:parser",
        "//multibody/parsing:process_model_directives",
        "//multibody/plant",
        "//systems/framework:diagram_builder",
        "//systems/primitives:shared_pointer_system",
    ],
)

drake_cc_googletest(
    name = "robot_plan_interpolator_test",
    data = [
        "//examples/kuka_iiwa_arm:models",
        "@drake_models//:iiwa_description",
    ],
    deps = [
        ":robot_plan_interpolator",
        "//systems/framework",
    ],
)

filegroup(
    name = "test_directives",
    testonly = True,
    srcs = [
        ":test/iiwa7_wsg.dmd.yaml",
    ],
)

filegroup(
    name = "test_models",
    testonly = True,
    srcs = [
        ":test/simple_nested_model.sdf",
        ":test/simple_world_with_two_models.sdf",
    ],
)

add_lint_tests()
