Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to ros system packages #278

Merged
merged 41 commits into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
4bd4bf9
Make drake_ros, drake_ros_examples use humble debs
adityapande-1995 May 16, 2023
23bc8b0
Migrated ros2_examples_bazel_installed to use humble debs
adityapande-1995 May 17, 2023
e55a20b
install drake_ros deps in CI
adityapande-1995 May 17, 2023
271135e
CI fix
adityapande-1995 May 17, 2023
e4ddc8c
CI fix
adityapande-1995 May 17, 2023
248adcd
linter
adityapande-1995 May 17, 2023
41085d3
linter
adityapande-1995 May 17, 2023
45332e1
linter
adityapande-1995 May 17, 2023
629c70b
fixed tests in drake_ros
adityapande-1995 May 18, 2023
0371417
Added explicit rmw_implementation in drake_ros_egs
adityapande-1995 May 18, 2023
1d8337e
bazel linter
adityapande-1995 May 18, 2023
85f2a50
install cyclonedds dep in drake_ros_egs
adityapande-1995 May 19, 2023
87e7bc5
ros2_egs_bzl_installed ci fix
adityapande-1995 May 19, 2023
642b876
Change ros2_egs_bzl_installed to humble
adityapande-1995 May 19, 2023
e8b67fe
rosdep fix
adityapande-1995 May 22, 2023
3aff699
removed unnecessary pkgs file
adityapande-1995 May 22, 2023
199016f
make drake_ros use rosdeps for a minimal ros installation
adityapande-1995 May 22, 2023
2284f92
typo
adityapande-1995 May 22, 2023
fc24b49
bash exit on fail flag removed due to rosdep step
adityapande-1995 May 23, 2023
4333e95
make drake_ros_egs use minimal ros pacakges
adityapande-1995 May 23, 2023
dcdbf82
Fix install prereqs path issues
adityapande-1995 May 24, 2023
3b39f88
Fixed path issue in setup script
adityapande-1995 May 31, 2023
3af6b18
Merge branch 'main' into aditya/switch_to_debs
adityapande-1995 Sep 25, 2023
6c782b8
Deleted vcstool entry in rosdep keys
adityapande-1995 Sep 25, 2023
2f03bc3
CI fix: rmw not found
adityapande-1995 Sep 27, 2023
15e549b
CI fix for drake_ros_examples
adityapande-1995 Sep 27, 2023
ef48059
clean disk space
adityapande-1995 Sep 28, 2023
13f8418
clear man pages
adityapande-1995 Sep 28, 2023
b9fd99e
CI cleanup
adityapande-1995 Sep 28, 2023
d87d1da
Chang import test to ros_py_test() instead of py_test()
adityapande-1995 Oct 6, 2023
1f6d3d7
Added missing rmw_implementation to simple_talker (#320)
ahcorde Nov 23, 2023
8930a19
Merge branch 'main' into aditya/switch_to_debs
adityapande-1995 Nov 27, 2023
5a23bec
linter fix
adityapande-1995 Nov 27, 2023
da9f5c9
typecaster test fixed
adityapande-1995 Nov 27, 2023
57e434a
address comments
EricCousineau-TRI Nov 27, 2023
826e139
dbg prereqs
EricCousineau-TRI Nov 27, 2023
9c30070
fix rosdep inti
EricCousineau-TRI Nov 27, 2023
d323c6d
try one more config, then just revert back to export ROS_DISTRO
EricCousineau-TRI Nov 27, 2023
534df6b
restore export
EricCousineau-TRI Nov 27, 2023
5af8bb7
remove --rosdistro sepcifier from review
EricCousineau-TRI Nov 27, 2023
98a54b5
ignore rosdep for drake_ros_examples
EricCousineau-TRI Nov 27, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/bazelized.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions .github/workflows/bazelized_drake_ros.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions drake_ros/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
)
13 changes: 7 additions & 6 deletions drake_ros/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions drake_ros/drake_ros/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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"],
)

Expand Down Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions drake_ros/required_packages.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ DRAKE_ROS_REQUIRED_PACKAGES = [
"tf2_eigen",
"tf2_ros",
"visualization_msgs",
"rmw_cyclonedds_cpp",
]

DRAKE_ROS_TEST_DEPENDENCIES = [
Expand Down
30 changes: 30 additions & 0 deletions drake_ros/setup/install_prereqs.sh
Original file line number Diff line number Diff line change
@@ -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
5 changes: 4 additions & 1 deletion drake_ros_examples/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -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",
],
Expand Down
8 changes: 3 additions & 5 deletions drake_ros_examples/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")
Expand Down
2 changes: 2 additions & 0 deletions drake_ros_examples/examples/hydroelastic/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
],
Expand Down
3 changes: 3 additions & 0 deletions drake_ros_examples/examples/iiwa_manipulator/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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",
],
Expand Down
3 changes: 3 additions & 0 deletions drake_ros_examples/examples/multirobot/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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",
],
Expand Down
3 changes: 3 additions & 0 deletions drake_ros_examples/examples/rs_flip_flop/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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",
],
Expand Down
37 changes: 28 additions & 9 deletions drake_ros_examples/setup/install_prereqs.sh
Original file line number Diff line number Diff line change
@@ -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
16 changes: 4 additions & 12 deletions ros2_example_bazel_installed/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -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],
)
1 change: 1 addition & 0 deletions ros2_example_bazel_installed/ros2_example_apps/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
33 changes: 18 additions & 15 deletions ros2_example_bazel_installed/setup/install_prereqs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading