From d3f087c4de05a3151331db9977cbc12a3c7db0c9 Mon Sep 17 00:00:00 2001 From: Aditya Pande Date: Tue, 16 Apr 2024 12:48:15 -0700 Subject: [PATCH] Upgrade to Drake 1.28 (#340) - Adjust CI to force GCC 11. - Run the latest buildifier for lint fixes. - Work around parser collision filter group design gap. Co-authored-by: Jeremy Nimmer --- .github/workflows/bazelized_drake_ros.yml | 3 +++ .../ros2/resources/templates/prologue.bazel | 7 +++---- bazel_ros2_rules/ros2/ros_cc.bzl | 10 ++++----- bazel_ros2_rules/ros2/ros_py.bzl | 8 +++---- bazel_ros2_rules/ros2/rosidl.bzl | 8 +++---- drake_ros/WORKSPACE | 7 +++++-- drake_ros/drake.bzl | 6 +++--- drake_ros/drake_ros/BUILD.bazel | 2 +- drake_ros_examples/WORKSPACE | 2 +- .../examples/hydroelastic/BUILD.bazel | 3 +-- .../examples/iiwa_manipulator/BUILD.bazel | 3 +-- .../examples/multirobot/BUILD.bazel | 7 +++---- .../examples/multirobot/multirobot.cc | 11 +++++----- .../examples/multirobot/multirobot.py | 9 ++++---- .../examples/rs_flip_flop/BUILD.bazel | 3 +-- ros2_example_bazel_installed/WORKSPACE | 21 +++++++++++-------- .../ros2_example_apps/BUILD.bazel | 3 +-- .../tools/BUILD.bazel | 4 ++-- 18 files changed, 60 insertions(+), 57 deletions(-) diff --git a/.github/workflows/bazelized_drake_ros.yml b/.github/workflows/bazelized_drake_ros.yml index 038aa9b6..574b5bcd 100755 --- a/.github/workflows/bazelized_drake_ros.yml +++ b/.github/workflows/bazelized_drake_ros.yml @@ -48,6 +48,9 @@ jobs: run: | sudo apt install python3 python3-toposort sudo rm -rf /var/lib/apt/lists/* + - name: Use GCC 11, until GCC 13 works with drake's clang + run: sudo apt purge gcc-13 libgcc-13-dev g++-13 libstdc++-13-dev gcc-12 libgcc-12-dev g++-12 libstdc++-12-dev && sudo apt install gcc-11 g++-11 && sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 100 --slave /usr/bin/g++ g++ /usr/bin/g++-11 + working-directory: drake_ros - name: Download Drake run: bazel build @drake//:module_py working-directory: drake_ros diff --git a/bazel_ros2_rules/ros2/resources/templates/prologue.bazel b/bazel_ros2_rules/ros2/resources/templates/prologue.bazel index c46b6dea..b1a27eae 100644 --- a/bazel_ros2_rules/ros2/resources/templates/prologue.bazel +++ b/bazel_ros2_rules/ros2/resources/templates/prologue.bazel @@ -1,10 +1,9 @@ # -*- python -*- # vi: set ft=python : -package(default_visibility = ["//visibility:public"]) - -load("//tools:common.bzl", "interfaces_filegroup") -load("//tools:common.bzl", "share_filegroup") +load("//tools:common.bzl", "interfaces_filegroup", "share_filegroup") load(":ros_py.bzl", "ros_import_binary") +package(default_visibility = ["//visibility:public"]) + exports_files(["system-rosdep-keys.txt"]) diff --git a/bazel_ros2_rules/ros2/ros_cc.bzl b/bazel_ros2_rules/ros2/ros_cc.bzl index fbc7ffdc..c549579a 100644 --- a/bazel_ros2_rules/ros2/ros_cc.bzl +++ b/bazel_ros2_rules/ros2/ros_cc.bzl @@ -1,5 +1,10 @@ # -*- python -*- +load("//tools:ament_index.bzl", "AmentIndex") +load( + "//tools:common.bzl", + "incorporate_rmw_implementation", +) load( "//tools:dload_cc.bzl", "dload_cc_ldwrap", @@ -10,11 +15,6 @@ load( "filter_to_only_common_kwargs", "remove_test_specific_kwargs", ) -load( - "//tools:common.bzl", - "incorporate_rmw_implementation", -) -load("//tools:ament_index.bzl", "AmentIndex") load( ":distro.bzl", "RUNTIME_ENVIRONMENT", diff --git a/bazel_ros2_rules/ros2/ros_py.bzl b/bazel_ros2_rules/ros2/ros_py.bzl index 5184c8f3..619d7ae0 100644 --- a/bazel_ros2_rules/ros2/ros_py.bzl +++ b/bazel_ros2_rules/ros2/ros_py.bzl @@ -1,5 +1,9 @@ # -*- python -*- +load( + "//tools:common.bzl", + "incorporate_rmw_implementation", +) load( "//tools:dload_py.bzl", "dload_py_shim", @@ -9,10 +13,6 @@ load( "filter_to_only_common_kwargs", "remove_test_specific_kwargs", ) -load( - "//tools:common.bzl", - "incorporate_rmw_implementation", -) load( ":distro.bzl", "RUNTIME_ENVIRONMENT", diff --git a/bazel_ros2_rules/ros2/rosidl.bzl b/bazel_ros2_rules/ros2/rosidl.bzl index 5fb90f11..d432e4b7 100644 --- a/bazel_ros2_rules/ros2/rosidl.bzl +++ b/bazel_ros2_rules/ros2/rosidl.bzl @@ -3,15 +3,15 @@ load("@bazel_skylib//lib:paths.bzl", "paths") load("@python_dev//:version.bzl", "PYTHON_EXTENSION_SUFFIX") load("//tools:ament_index.bzl", "AmentIndex") +load( + ":_calculate_rosidl_capitalization.bzl", + "calculate_rosidl_capitalization", +) load( ":distro.bzl", "AVAILABLE_TYPESUPPORT_LIST", "REPOSITORY_ROOT", ) -load( - ":_calculate_rosidl_capitalization.bzl", - "calculate_rosidl_capitalization", -) RosInterfaces = provider( fields = ["interfaces"], diff --git a/drake_ros/WORKSPACE b/drake_ros/WORKSPACE index 2a47749a..7158e306 100644 --- a/drake_ros/WORKSPACE +++ b/drake_ros/WORKSPACE @@ -22,8 +22,11 @@ load("@bazel_ros2_rules//deps:defs.bzl", "add_bazel_ros2_rules_dependencies") add_bazel_ros2_rules_dependencies() load("@bazel_ros2_rules//ros2:defs.bzl", "ros2_local_repository") -load("//:required_packages.bzl", "DRAKE_ROS_REQUIRED_PACKAGES") -load("//:required_packages.bzl", "DRAKE_ROS_TEST_DEPENDENCIES") +load( + "//:required_packages.bzl", + "DRAKE_ROS_REQUIRED_PACKAGES", + "DRAKE_ROS_TEST_DEPENDENCIES", +) DRAKE_ROS_ALL_DEPENDENCIES = \ DRAKE_ROS_REQUIRED_PACKAGES + DRAKE_ROS_TEST_DEPENDENCIES diff --git a/drake_ros/drake.bzl b/drake_ros/drake.bzl index e1835620..f8684c25 100644 --- a/drake_ros/drake.bzl +++ b/drake_ros/drake.bzl @@ -1,5 +1,5 @@ DRAKE_SUGGESTED_VERSION = struct( - url = "https://github.com/RobotLocomotion/drake/archive/refs/tags/v1.26.0.tar.gz", # noqa - sha256 = "f10b50b695ea29430cc291d1019b4cc1aceedcebec3290110b24b7e48c5f5588", # noqa, - strip_prefix = "drake-1.26.0", + url = "https://github.com/RobotLocomotion/drake/archive/refs/tags/v1.28.0.tar.gz", # noqa + sha256 = "6ff298d7fbc33cb17963509f86fcd9cb6816d455b97b3fd589e1085e0548c2fe", # noqa, + strip_prefix = "drake-1.28.0", ) diff --git a/drake_ros/drake_ros/BUILD.bazel b/drake_ros/drake_ros/BUILD.bazel index f9cfa6c4..64255fe3 100644 --- a/drake_ros/drake_ros/BUILD.bazel +++ b/drake_ros/drake_ros/BUILD.bazel @@ -1,8 +1,8 @@ -load("@ros2//:ros_py.bzl", "ros_py_test") load( "@drake//tools/skylark:pybind.bzl", "pybind_py_library", ) +load("@ros2//:ros_py.bzl", "ros_py_test") # TODO(Aditya): Add focused unittest for qos_pybind.h cc_library( diff --git a/drake_ros_examples/WORKSPACE b/drake_ros_examples/WORKSPACE index e659c47b..07d95daa 100644 --- a/drake_ros_examples/WORKSPACE +++ b/drake_ros_examples/WORKSPACE @@ -32,9 +32,9 @@ local_repository( path = "../drake_ros", ) -load("@drake_ros_repo//:required_packages.bzl", "DRAKE_ROS_REQUIRED_PACKAGES") load( "@drake_ros_repo//:required_packages.bzl", + "DRAKE_ROS_REQUIRED_PACKAGES", "drake_ros_fail_if_missing_required_packages", ) diff --git a/drake_ros_examples/examples/hydroelastic/BUILD.bazel b/drake_ros_examples/examples/hydroelastic/BUILD.bazel index bb40ad69..9281f22e 100644 --- a/drake_ros_examples/examples/hydroelastic/BUILD.bazel +++ b/drake_ros_examples/examples/hydroelastic/BUILD.bazel @@ -3,8 +3,7 @@ load("@ros2//:ament_index.bzl", "ament_index_share_files") load("@ros2//:ros_cc.bzl", "ros_cc_binary") -load("@ros2//:ros_py.bzl", "ros_py_binary") -load("@ros2//:ros_py.bzl", "ros_py_test") +load("@ros2//:ros_py.bzl", "ros_py_binary", "ros_py_test") # We use `ament_index_share_files` so we can write code that can find # resources both when built by CMake and by Bazel. diff --git a/drake_ros_examples/examples/iiwa_manipulator/BUILD.bazel b/drake_ros_examples/examples/iiwa_manipulator/BUILD.bazel index 6abc6765..5a2f6b0e 100644 --- a/drake_ros_examples/examples/iiwa_manipulator/BUILD.bazel +++ b/drake_ros_examples/examples/iiwa_manipulator/BUILD.bazel @@ -2,8 +2,7 @@ # vi: set ft=python : load("@ros2//:ros_cc.bzl", "ros_cc_binary") -load("@ros2//:ros_py.bzl", "ros_py_binary") -load("@ros2//:ros_py.bzl", "ros_py_test") +load("@ros2//:ros_py.bzl", "ros_py_binary", "ros_py_test") ros_cc_binary( name = "iiwa_manipulator", diff --git a/drake_ros_examples/examples/multirobot/BUILD.bazel b/drake_ros_examples/examples/multirobot/BUILD.bazel index 53ce8df3..609ddc73 100644 --- a/drake_ros_examples/examples/multirobot/BUILD.bazel +++ b/drake_ros_examples/examples/multirobot/BUILD.bazel @@ -2,14 +2,13 @@ # vi: set ft=python : load("@ros2//:ros_cc.bzl", "ros_cc_binary") -load("@ros2//:ros_py.bzl", "ros_py_binary") -load("@ros2//:ros_py.bzl", "ros_py_test") +load("@ros2//:ros_py.bzl", "ros_py_binary", "ros_py_test") ros_cc_binary( name = "multirobot", srcs = ["multirobot.cc"], data = [ - "@drake//manipulation/models/iiwa_description:models", + "@drake_models//:iiwa_description", ], rmw_implementation = "rmw_cyclonedds_cpp", visibility = ["//visibility:public"], @@ -32,7 +31,7 @@ ros_py_binary( name = "multirobot_py", srcs = ["multirobot.py"], data = [ - "@drake//manipulation/models/iiwa_description:models", + "@drake_models//:iiwa_description", ], main = "multirobot.py", rmw_implementation = "rmw_cyclonedds_cpp", diff --git a/drake_ros_examples/examples/multirobot/multirobot.cc b/drake_ros_examples/examples/multirobot/multirobot.cc index e01529dd..65d986e3 100644 --- a/drake_ros_examples/examples/multirobot/multirobot.cc +++ b/drake_ros_examples/examples/multirobot/multirobot.cc @@ -67,10 +67,9 @@ int main(int argc, char** argv) { scene_visualizer->get_graph_query_input_port()); // Prepare to load the robot model - auto parser = drake::multibody::Parser(&plant); - auto model_file_path = drake::FindResourceOrThrow( - "drake/manipulation/models/iiwa_description/urdf/" - "iiwa14_polytope_collision.urdf"); + auto model_file_url = + "package://drake_models/iiwa_description/urdf/" + "iiwa14_polytope_collision.urdf"; const std::string model_name = "kuka_iiwa"; // Create a 5x5 array of manipulators @@ -84,9 +83,9 @@ int main(int argc, char** argv) { // coordinates in the array std::stringstream model_instance_name; model_instance_name << model_name << xx << '_' << yy; + auto parser = drake::multibody::Parser(&plant); parser.SetAutoRenaming(true); - auto model_instance = parser.AddModels(model_file_path)[0]; - + auto model_instance = parser.AddModelsFromUrl(model_file_url)[0]; plant.RenameModelInstance(model_instance, model_instance_name.str()); // Weld the robot to the world so it doesn't fall through the floor diff --git a/drake_ros_examples/examples/multirobot/multirobot.py b/drake_ros_examples/examples/multirobot/multirobot.py index 58322771..91c08445 100755 --- a/drake_ros_examples/examples/multirobot/multirobot.py +++ b/drake_ros_examples/examples/multirobot/multirobot.py @@ -81,9 +81,9 @@ def main(): scene_visualizer.get_graph_query_input_port()) # Prepare to load the robot model - parser = Parser(plant) - model_file_path = FindResourceOrThrow( - 'drake/manipulation/models/iiwa_description/urdf/iiwa14_polytope_collision.urdf') + model_file_url = ( + 'package://drake_models/iiwa_description/urdf/' + 'iiwa14_polytope_collision.urdf') model_name = "kuka_iiwa" # Create a 5x5 array of manipulators @@ -95,7 +95,8 @@ def main(): for y in range(NUM_COLS): # Load the model from the file and give it a name based on its X # and Y coordinates in the array - (iiwa,) = parser.AddModels(model_file_path) + parser = Parser(plant) + (iiwa,) = parser.AddModels(url=model_file_url) models[x].append(iiwa) plant.RenameModelInstance(model_instance=iiwa, name=model_name + str(x) + '_' + str(y)) diff --git a/drake_ros_examples/examples/rs_flip_flop/BUILD.bazel b/drake_ros_examples/examples/rs_flip_flop/BUILD.bazel index 718da224..a8e9ded0 100644 --- a/drake_ros_examples/examples/rs_flip_flop/BUILD.bazel +++ b/drake_ros_examples/examples/rs_flip_flop/BUILD.bazel @@ -2,8 +2,7 @@ # vi: set ft=python : load("@ros2//:ros_cc.bzl", "ros_cc_binary") -load("@ros2//:ros_py.bzl", "ros_py_binary") -load("@ros2//:ros_py.bzl", "ros_py_test") +load("@ros2//:ros_py.bzl", "ros_py_binary", "ros_py_test") ros_cc_binary( name = "rs_flip_flop", diff --git a/ros2_example_bazel_installed/WORKSPACE b/ros2_example_bazel_installed/WORKSPACE index eb32431b..83ea9b93 100644 --- a/ros2_example_bazel_installed/WORKSPACE +++ b/ros2_example_bazel_installed/WORKSPACE @@ -1,19 +1,12 @@ workspace(name = "ros2_example_bazel_installed") load("//tools:environ.bzl", "environment_repository") -load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") environment_repository( name = "ros2_example_bazel_installed_environ", envvars = ["ROS2_DISTRO_PREFIX"], ) -load( - "@ros2_example_bazel_installed_environ//:environ.bzl", - "ROS2_DISTRO_PREFIX", -) - -# Skylib workspace boilerplate load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") http_archive( @@ -45,8 +38,11 @@ load("@bazel_ros2_rules//deps:defs.bzl", "add_bazel_ros2_rules_dependencies") add_bazel_ros2_rules_dependencies() -load("@bazel_ros2_rules//ros2:defs.bzl", "ros2_archive") -load("@bazel_ros2_rules//ros2:defs.bzl", "ros2_local_repository") +load( + "@bazel_ros2_rules//ros2:defs.bzl", + "ros2_archive", + "ros2_local_repository", +) # TODO(Aditya): Replace with a proper rule later. new_local_repository( @@ -56,12 +52,19 @@ new_local_repository( visibility = ["//visibility:public"])""", ) +load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") + git_repository( name = "com_github_gflags_gflags", tag = "v2.2.2", remote = "https://github.com/gflags/gflags.git", ) +load( + "@ros2_example_bazel_installed_environ//:environ.bzl", + "ROS2_DISTRO_PREFIX", +) + # Please keep this list sorted ROS2_PACKAGES = [ "action_msgs", diff --git a/ros2_example_bazel_installed/ros2_example_apps/BUILD.bazel b/ros2_example_bazel_installed/ros2_example_apps/BUILD.bazel index 92183db5..0c7d534b 100644 --- a/ros2_example_bazel_installed/ros2_example_apps/BUILD.bazel +++ b/ros2_example_bazel_installed/ros2_example_apps/BUILD.bazel @@ -1,8 +1,7 @@ # -*- mode: python -*- # vi: set ft=python : -load("@ros2//:ros_cc.bzl", "ros_cc_binary") -load("@ros2//:ros_cc.bzl", "ros_cc_test") +load("@ros2//:ros_cc.bzl", "ros_cc_binary", "ros_cc_test") load("@ros2//:ros_py.bzl", "ros_py_binary", "ros_py_test") load("@ros2//:rosidl.bzl", "rosidl_interfaces_group") load("//tools:cmd_test.bzl", "cmd_test") diff --git a/ros2_example_bazel_installed/tools/BUILD.bazel b/ros2_example_bazel_installed/tools/BUILD.bazel index 6262bb33..6258eac6 100644 --- a/ros2_example_bazel_installed/tools/BUILD.bazel +++ b/ros2_example_bazel_installed/tools/BUILD.bazel @@ -1,12 +1,12 @@ # -*- python -*- -exports_files(["cmd_exec.sh"]) - load( "@ros2//:ros_py.bzl", "ros_py_binary", ) +exports_files(["cmd_exec.sh"]) + ros_py_binary( name = "ros2", srcs = ["ros2.py"],