diff --git a/.github/workflows/bazelized.yml b/.github/workflows/bazelized.yml index b20ea061..8f037539 100644 --- a/.github/workflows/bazelized.yml +++ b/.github/workflows/bazelized.yml @@ -15,7 +15,7 @@ jobs: if: "! contains(github.event.pull_request.labels.*.name, 'status: defer ci')" runs-on: ubuntu-22.04 container: - image: ros:rolling-ros-base-jammy + image: ros:humble-ros-base-jammy # This is required for running lldb. # See https://stackoverflow.com/a/73613377/7829525 options: --cap-add=SYS_PTRACE --security-opt seccomp=unconfined diff --git a/.github/workflows/bazelized_drake_ros.yml b/.github/workflows/bazelized_drake_ros.yml index 98919f02..92a3cdb1 100755 --- a/.github/workflows/bazelized_drake_ros.yml +++ b/.github/workflows/bazelized_drake_ros.yml @@ -62,11 +62,14 @@ jobs: sudo apt-get install -y libconsole-bridge-dev sudo rm -rf /var/lib/apt/lists/* # CI for drake_ros. + - name: Install drake_ros's dependencies + run: yes | sudo ./setup/install_prereqs.sh + working-directory: drake_ros - name: Build drake_ros - run: bazel build //... + run: export ROS_DISTRO=humble; bazel build //... working-directory: drake_ros - name: Test drake_ros - run: bazel test //... + run: export ROS_DISTRO=humble; bazel test //... working-directory: drake_ros - name: Clean up drake_ros run: bazel clean diff --git a/drake_ros/BUILD.bazel b/drake_ros/BUILD.bazel index e005d384..ce3f292b 100644 --- a/drake_ros/BUILD.bazel +++ b/drake_ros/BUILD.bazel @@ -45,5 +45,6 @@ ros_py_test( name = "import_test", srcs = ["test/import_test.py"], main = "test/import_test.py", + rmw_implementation = "rmw_cyclonedds_cpp", deps = [":drake_ros_py"], ) diff --git a/drake_ros/WORKSPACE b/drake_ros/WORKSPACE index 0b2a8278..2a47749a 100644 --- a/drake_ros/WORKSPACE +++ b/drake_ros/WORKSPACE @@ -21,17 +21,18 @@ 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("//:required_packages.bzl", "DRAKE_ROS_REQUIRED_PACKAGES") load("//:required_packages.bzl", "DRAKE_ROS_TEST_DEPENDENCIES") +DRAKE_ROS_ALL_DEPENDENCIES = \ + DRAKE_ROS_REQUIRED_PACKAGES + DRAKE_ROS_TEST_DEPENDENCIES + # Use ROS 2 -ros2_archive( +ros2_local_repository( name = "ros2", - include_packages = DRAKE_ROS_REQUIRED_PACKAGES + DRAKE_ROS_TEST_DEPENDENCIES, # noqa - sha256_url = "https://repo.ros2.org/ci_archives/nightly-cyclonedds/ros2-humble-linux-jammy-amd64-ci-CHECKSUM", # noqa - strip_prefix = "ros2-linux", - url = "http://repo.ros2.org/ci_archives/nightly-cyclonedds/ros2-humble-linux-jammy-amd64-ci.tar.bz2", # noqa + include_packages = DRAKE_ROS_ALL_DEPENDENCIES, + workspaces = ["/opt/ros/humble"], ) # Depend on Drake diff --git a/drake_ros/drake_ros/BUILD.bazel b/drake_ros/drake_ros/BUILD.bazel index 1a3408df..f9cfa6c4 100644 --- a/drake_ros/drake_ros/BUILD.bazel +++ b/drake_ros/drake_ros/BUILD.bazel @@ -71,6 +71,7 @@ ros_py_test( name = "core_test", srcs = ["test/core_test.py"], main = "test/core_test.py", + rmw_implementation = "rmw_cyclonedds_cpp", deps = [ ":drake_ros_py", ":test_pub_and_sub_cc_py", @@ -86,6 +87,7 @@ ros_py_test( name = "tf2_test", srcs = ["test/tf2_test.py"], main = "test/tf2_test.py", + rmw_implementation = "rmw_cyclonedds_cpp", deps = [ ":drake_ros_py", "@drake//bindings/pydrake", @@ -99,6 +101,7 @@ ros_py_test( name = "viz_test", srcs = ["test/viz_test.py"], main = "test/viz_test.py", + rmw_implementation = "rmw_cyclonedds_cpp", deps = [ ":drake_ros_py", "@drake//bindings/pydrake", @@ -112,6 +115,7 @@ ros_py_test( name = "geometry_conversions_test", srcs = ["test/geometry_conversions_test.py"], main = "test/geometry_conversions_test.py", + rmw_implementation = "rmw_cyclonedds_cpp", deps = [ ":drake_ros_py", "@drake//bindings/pydrake", @@ -126,6 +130,7 @@ ros_py_test( name = "odr_py_test", srcs = ["test/odr_py_test.py"], main = "test/odr_py_test.py", + rmw_implementation = "rmw_cyclonedds_cpp", deps = [":drake_ros_py"], ) @@ -157,6 +162,7 @@ ros_py_test( name = "ros_message_type_caster_test", srcs = ["test/ros_message_type_caster_test.py"], main = "test/ros_message_type_caster_test.py", + rmw_implementation = "rmw_cyclonedds_cpp", deps = [ ":ros_message_type_caster_test_via_all_py", ":ros_message_type_caster_test_via_specific_types_py", diff --git a/drake_ros/required_packages.bzl b/drake_ros/required_packages.bzl index 422595a3..fbc8f466 100644 --- a/drake_ros/required_packages.bzl +++ b/drake_ros/required_packages.bzl @@ -7,6 +7,7 @@ DRAKE_ROS_REQUIRED_PACKAGES = [ "tf2_eigen", "tf2_ros", "visualization_msgs", + "rmw_cyclonedds_cpp", ] DRAKE_ROS_TEST_DEPENDENCIES = [ diff --git a/drake_ros/setup/install_prereqs.sh b/drake_ros/setup/install_prereqs.sh new file mode 100755 index 00000000..69e4e509 --- /dev/null +++ b/drake_ros/setup/install_prereqs.sh @@ -0,0 +1,30 @@ +#!/bin/bash +set -eux -o pipefail + +apt update && apt install locales +locale-gen en_US en_US.UTF-8 +update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 +export LANG=en_US.UTF-8 + +apt install software-properties-common +add-apt-repository universe + +apt update && apt install curl -y +curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg + +echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(. /etc/os-release && echo $UBUNTU_CODENAME) main" | tee /etc/apt/sources.list.d/ros2.list > /dev/null + +apt update + +apt install ros-dev-tools +rosdep init || true +rosdep update + +SCRIPT_DIRECTORY=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) +cd $SCRIPT_DIRECTORY +rosdep install --from-paths ../ --rosdistro=humble + +apt install ros-humble-test-msgs ros-humble-tf2-ros-py ros-humble-rmw-cyclonedds-cpp ros-humble-tf2-py + +# Required for bazel_ros2_rules +apt install python3 python3-toposort diff --git a/drake_ros_examples/BUILD.bazel b/drake_ros_examples/BUILD.bazel index 5a7a3f7e..34feeb2d 100644 --- a/drake_ros_examples/BUILD.bazel +++ b/drake_ros_examples/BUILD.bazel @@ -1,7 +1,10 @@ -py_test( +load("@ros2//:ros_py.bzl", "ros_py_test") + +ros_py_test( name = "drake_ros_py_import_test", srcs = ["test/drake_ros_py_import_test.py"], main = "test/drake_ros_py_import_test.py", + rmw_implementation = "rmw_cyclonedds_cpp", deps = [ "@drake_ros_repo//:drake_ros_py", ], diff --git a/drake_ros_examples/WORKSPACE b/drake_ros_examples/WORKSPACE index f7c2b61a..e659c47b 100644 --- a/drake_ros_examples/WORKSPACE +++ b/drake_ros_examples/WORKSPACE @@ -19,7 +19,7 @@ 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") # N.B. We do *not* name this as `drake_ros` to avoid module shadowing. # See https://github.com/bazelbuild/bazel/issues/17691 @@ -52,12 +52,10 @@ ROS_PACKAGES = DRAKE_ROS_REQUIRED_PACKAGES + [ drake_ros_fail_if_missing_required_packages(ROS_PACKAGES) # Use ROS 2 -ros2_archive( +ros2_local_repository( name = "ros2", include_packages = ROS_PACKAGES, - sha256_url = "https://repo.ros2.org/ci_archives/nightly-cyclonedds/ros2-humble-linux-jammy-amd64-ci-CHECKSUM", # noqa - strip_prefix = "ros2-linux", - url = "http://repo.ros2.org/ci_archives/nightly-cyclonedds/ros2-humble-linux-jammy-amd64-ci.tar.bz2", # noqa + workspaces = ["/opt/ros/humble"], ) load("@drake_ros_repo//:drake.bzl", "DRAKE_SUGGESTED_VERSION") diff --git a/drake_ros_examples/examples/hydroelastic/BUILD.bazel b/drake_ros_examples/examples/hydroelastic/BUILD.bazel index ae982492..bb40ad69 100644 --- a/drake_ros_examples/examples/hydroelastic/BUILD.bazel +++ b/drake_ros_examples/examples/hydroelastic/BUILD.bazel @@ -22,6 +22,7 @@ ros_cc_binary( ":hydroelastic_share", ], local_defines = ["BAZEL"], + rmw_implementation = "rmw_cyclonedds_cpp", deps = [ "@bazel_tools//tools/cpp/runfiles", "@drake//common:find_resource", @@ -52,6 +53,7 @@ ros_py_test( ":hydroelastic", ], main = "test/hydroelastic_test.py", + rmw_implementation = "rmw_cyclonedds_cpp", deps = [ "@ros2//resources/bazel_ros_env:bazel_ros_env_py", ], diff --git a/drake_ros_examples/examples/iiwa_manipulator/BUILD.bazel b/drake_ros_examples/examples/iiwa_manipulator/BUILD.bazel index d45f3b72..6abc6765 100644 --- a/drake_ros_examples/examples/iiwa_manipulator/BUILD.bazel +++ b/drake_ros_examples/examples/iiwa_manipulator/BUILD.bazel @@ -8,6 +8,7 @@ load("@ros2//:ros_py.bzl", "ros_py_test") ros_cc_binary( name = "iiwa_manipulator", srcs = ["iiwa_manipulator.cpp"], + rmw_implementation = "rmw_cyclonedds_cpp", visibility = ["//visibility:public"], deps = [ "@drake//examples/manipulation_station", @@ -26,6 +27,7 @@ ros_py_binary( name = "iiwa_manipulator_py", srcs = ["iiwa_manipulator.py"], main = "iiwa_manipulator.py", + rmw_implementation = "rmw_cyclonedds_cpp", visibility = ["//visibility:public"], deps = [ "@drake//bindings/pydrake", @@ -42,6 +44,7 @@ ros_py_test( ":iiwa_manipulator_py", ], main = "test/iiwa_manipulator_test.py", + rmw_implementation = "rmw_cyclonedds_cpp", deps = [ "@ros2//resources/bazel_ros_env:bazel_ros_env_py", ], diff --git a/drake_ros_examples/examples/multirobot/BUILD.bazel b/drake_ros_examples/examples/multirobot/BUILD.bazel index 0b5c28fe..53ce8df3 100644 --- a/drake_ros_examples/examples/multirobot/BUILD.bazel +++ b/drake_ros_examples/examples/multirobot/BUILD.bazel @@ -11,6 +11,7 @@ ros_cc_binary( data = [ "@drake//manipulation/models/iiwa_description:models", ], + rmw_implementation = "rmw_cyclonedds_cpp", visibility = ["//visibility:public"], deps = [ "@drake//common:find_resource", @@ -34,6 +35,7 @@ ros_py_binary( "@drake//manipulation/models/iiwa_description:models", ], main = "multirobot.py", + rmw_implementation = "rmw_cyclonedds_cpp", visibility = ["//visibility:public"], deps = [ "@drake//bindings/pydrake", @@ -50,6 +52,7 @@ ros_py_test( ":multirobot_py", ], main = "test/multirobot_test.py", + rmw_implementation = "rmw_cyclonedds_cpp", deps = [ "@ros2//resources/bazel_ros_env:bazel_ros_env_py", ], diff --git a/drake_ros_examples/examples/rs_flip_flop/BUILD.bazel b/drake_ros_examples/examples/rs_flip_flop/BUILD.bazel index efbcd867..718da224 100644 --- a/drake_ros_examples/examples/rs_flip_flop/BUILD.bazel +++ b/drake_ros_examples/examples/rs_flip_flop/BUILD.bazel @@ -8,6 +8,7 @@ load("@ros2//:ros_py.bzl", "ros_py_test") ros_cc_binary( name = "rs_flip_flop", srcs = ["rs_flip_flop.cpp"], + rmw_implementation = "rmw_cyclonedds_cpp", visibility = ["//visibility:public"], deps = [ "@drake//systems/analysis:simulator", @@ -23,6 +24,7 @@ ros_py_binary( name = "rs_flip_flop_py", srcs = ["rs_flip_flop.py"], main = "rs_flip_flop.py", + rmw_implementation = "rmw_cyclonedds_cpp", visibility = ["//visibility:public"], deps = [ "@drake//bindings/pydrake", @@ -40,6 +42,7 @@ ros_py_test( ":rs_flip_flop_py", ], main = "test/rs_flip_flop_test.py", + rmw_implementation = "rmw_cyclonedds_cpp", deps = [ "@ros2//resources/bazel_ros_env:bazel_ros_env_py", ], diff --git a/drake_ros_examples/setup/install_prereqs.sh b/drake_ros_examples/setup/install_prereqs.sh index c683aada..a368acc9 100755 --- a/drake_ros_examples/setup/install_prereqs.sh +++ b/drake_ros_examples/setup/install_prereqs.sh @@ -1,13 +1,32 @@ #!/bin/bash -set -euo pipefail +set -eux -o pipefail -cat_without_comments() { - sed -e 's|#.*||g;' "$(dirname $0)/$1" -} +apt update && apt install locales +locale-gen en_US en_US.UTF-8 +update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 +export LANG=en_US.UTF-8 -apt_install () { - apt-get -q install --no-install-recommends "$@" -} +apt install software-properties-common +add-apt-repository universe -apt-get update -apt_install $(cat_without_comments packages-ros2.txt) +apt update && apt install curl -y +curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg + +echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(. /etc/os-release && echo $UBUNTU_CODENAME) main" | tee /etc/apt/sources.list.d/ros2.list > /dev/null + +apt update + +apt install ros-dev-tools ros-humble-rmw-cyclonedds-cpp ros-humble-rviz2 ros-humble-ros2cli-common-extensions + +rosdep init || true +rosdep update + +SCRIPT_DIRECTORY=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) +cd $SCRIPT_DIRECTORY/../.. +rosdep install --from-paths drake_ros --rosdistro=humble +# TODO(eric.cousineau): This currently fails with +# `Cannot locate rosdep definition for [drake_ros]`. Should fix. +# rosdep install --from-paths drake_ros_examples --rosdistro=humble + +# Required for bazel_ros2_rules +apt install python3 python3-toposort diff --git a/ros2_example_bazel_installed/WORKSPACE b/ros2_example_bazel_installed/WORKSPACE index 9ff1440f..b0a663ff 100644 --- a/ros2_example_bazel_installed/WORKSPACE +++ b/ros2_example_bazel_installed/WORKSPACE @@ -81,20 +81,12 @@ ROS2_PACKAGES = [ # "rmw_fastrtps_cpp", ] -ros2_archive( - name = "ros2" if not ROS2_DISTRO_PREFIX else "ros2_ignored", - include_packages = ROS2_PACKAGES, - sha256_url = "https://repo.ros2.org/ci_archives/nightly-cyclonedds/ros2-humble-linux-jammy-amd64-ci-CHECKSUM", # noqa - strip_prefix = "ros2-linux", - # Note: If you want an exact / unchanging version, you will need to mirror - # the archive according to versions you want. - # TODO(hidmic,cottsay): Make release-pinned snapshots of this repository - # once `drake-ros` itself has versions. - url = "http://repo.ros2.org/ci_archives/nightly-cyclonedds/ros2-humble-linux-jammy-amd64-ci.tar.bz2", # noqa +RESOLVED_PREFIX = ( + ROS2_DISTRO_PREFIX if ROS2_DISTRO_PREFIX else "/opt/ros/humble" ) ros2_local_repository( - name = "ros2" if ROS2_DISTRO_PREFIX else "ros2_ignored", + name = "ros2", include_packages = ROS2_PACKAGES, - workspaces = [ROS2_DISTRO_PREFIX], + workspaces = [RESOLVED_PREFIX], ) diff --git a/ros2_example_bazel_installed/ros2_example_apps/BUILD.bazel b/ros2_example_bazel_installed/ros2_example_apps/BUILD.bazel index 8be86500..c0604769 100644 --- a/ros2_example_bazel_installed/ros2_example_apps/BUILD.bazel +++ b/ros2_example_bazel_installed/ros2_example_apps/BUILD.bazel @@ -194,6 +194,7 @@ cmd_test( ros_py_binary( name = "simple_talker", srcs = ["simple_talker.py"], + rmw_implementation = "rmw_cyclonedds_cpp", deps = [ ":ros2_example_apps_msgs_py", "@ros2//:rclpy_py", diff --git a/ros2_example_bazel_installed/setup/install_prereqs.sh b/ros2_example_bazel_installed/setup/install_prereqs.sh index efbad175..08a1a9e2 100755 --- a/ros2_example_bazel_installed/setup/install_prereqs.sh +++ b/ros2_example_bazel_installed/setup/install_prereqs.sh @@ -64,24 +64,27 @@ dpkg_install_from_curl \ https://github.com/bazelbuild/bazel/releases/download/6.4.0/bazel_6.4.0-linux-x86_64.deb \ 9276a1e11f03e9f7492f009803c95bddc307993c9ab3c463721c9f6cdaa2ccc1 -# TODO(hidmic): install distributions from debians when Drake supports 22.04 +# If the user did not explicitly specify their installation prefix, install +# ROS 2 Humble. if [[ -z "${ROS2_DISTRO_PREFIX:-}" ]]; then - # Install dependencies for ROS 2 Rolling on Jammy tarball - ROS2_APT_SOURCE="deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(lsb_release -cs) main" - if ! grep "${ROS2_APT_SOURCE}" /etc/apt/sources.list.d/ros2.list; then - echo ${ROS2_APT_SOURCE} | tee /etc/apt/sources.list.d/ros2.list - fi + apt update && apt install locales + locale-gen en_US en_US.UTF-8 + update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 + export LANG=en_US.UTF-8 + + apt install software-properties-common + add-apt-repository universe + + apt update && apt install curl -y + curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg + + echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(. /etc/os-release && echo $UBUNTU_CODENAME) main" | tee /etc/apt/sources.list.d/ros2.list > /dev/null - apt update && apt install python3-rosdep - [[ -d /etc/ros/rosdep ]] || rosdep init - as-user rosdep update --rosdistro=rolling + apt update - # TODO(hidmic): be very explicit about what installation mechanisms we allow - # NOTE: since no ROS distributions has been sourced or specified yet, - # force Python version to 3.x (which is standard in ROS 2 distributions) - SETUP_DIR=$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd) - apt install $(env ROS_PYTHON_VERSION=3 rosdep resolve \ - $(cat ${SETUP_DIR}/prereq-rosdep-keys.txt) 2>/dev/null | grep -v '^#') libssl-dev + apt install ros-humble-desktop + apt install ros-humble-rmw-cyclonedds-cpp + apt install ros-dev-tools fi # Install Python dependencies diff --git a/ros2_example_bazel_installed/setup/prereq-rosdep-keys.txt b/ros2_example_bazel_installed/setup/prereq-rosdep-keys.txt index 50b888d9..895c17b0 100644 --- a/ros2_example_bazel_installed/setup/prereq-rosdep-keys.txt +++ b/ros2_example_bazel_installed/setup/prereq-rosdep-keys.txt @@ -1,8 +1,5 @@ assimp -benchmark bullet -clang-format -clang-tidy cmake cppcheck curl @@ -13,11 +10,13 @@ gtest ignition-cmake2 ignition-math6 libatomic +libboost-python libconsole-bridge-dev libfreetype6 libfreetype6-dev libopencv-dev liborocos-kdl-dev +libpcl-all-dev libqt5-core libqt5-gui libqt5-opengl @@ -33,10 +32,8 @@ opengl pkg-config pybind11-dev pydocstyle -pyflakes3 python3 python3-argcomplete -python3-babeltrace python3-cairo python3-catkin-pkg-modules python3-cryptography @@ -46,27 +43,23 @@ python3-flake8 python3-importlib-metadata python3-importlib-resources python3-lark-parser -python3-lttng python3-lxml python3-matplotlib -python3-mypy python3-netifaces -python3-nose python3-numpy +python3-opencv python3-packaging python3-pil python3-pkg-resources python3-psutil -python3-pycodestyle python3-pydot -python3-pykdl python3-pytest python3-qt5-bindings python3-rosdistro-modules python3-setuptools -python3-vcstool python3-yaml qtbase5-dev +sdl2 spdlog tango-icon-theme tinyxml