-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[drake_ros_tf2] Add BUILD.bazel and WORKSPACE (#200)
Use rmw_isolation Use legacy_create_init to workaround bazelbuild/bazel#7386 Add TODO about ODR violations Use C++17
- Loading branch information
Showing
5 changed files
with
194 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Use C++17. | ||
build --cxxopt=-std=c++17 | ||
build --host_cxxopt=-std=c++17 | ||
|
||
# Put ROS logs into /tmp | ||
build --action_env=ROS_HOME=/tmp/.ros |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
# Copyright 2022 Open Source Robotics Foundation, Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
load("@ros2//:ros_cc.bzl", "ros_cc_test") | ||
load("@ros2//:ros_py.bzl", "ros_py_test") | ||
load( | ||
"@drake//tools/skylark:pybind.bzl", | ||
"pybind_py_library", | ||
) | ||
|
||
PYBIND_EXCLUDES = [ | ||
"**/*_py.cc", | ||
"**/*_pybind.h", | ||
] | ||
|
||
# TODO(sloretz) more granular targets for static linking | ||
cc_library( | ||
name = "drake_ros_tf2", | ||
srcs = glob( | ||
[ | ||
"src/*.cc", | ||
"src/*.h", | ||
], | ||
exclude = PYBIND_EXCLUDES, | ||
), | ||
hdrs = glob( | ||
["include/**/*.h"], | ||
exclude = PYBIND_EXCLUDES, | ||
), | ||
strip_include_prefix = "include", | ||
visibility = ["//visibility:public"], | ||
deps = [ | ||
"@drake//geometry:scene_graph_inspector", | ||
"@drake//multibody/plant", | ||
"@drake_ros_core", | ||
"@ros2//:geometry_msgs_cc", | ||
"@ros2//:rclcpp_cc", | ||
"@ros2//:tf2_ros_cc", | ||
], | ||
) | ||
|
||
ros_cc_test( | ||
name = "test_tf_broadcaster", | ||
size = "small", | ||
srcs = ["test/test_tf_broadcaster.cc"], | ||
rmw_implementation = "rmw_cyclonedds_cpp", | ||
deps = [ | ||
":drake_ros_tf2", | ||
"@com_google_googletest//:gtest_main", | ||
"@drake//common", | ||
"@drake//systems/primitives", | ||
"@ros2//:geometry_msgs_cc", | ||
"@ros2//:rclcpp_cc", | ||
"@ros2//:tf2_ros_cc", | ||
"@ros2//resources/rmw_isolation:rmw_isolation_cc", | ||
], | ||
) | ||
|
||
cc_library( | ||
name = "python_bindings_internal_hdrs", | ||
hdrs = glob(["include/**/*_pybind.h"]), | ||
strip_include_prefix = "include/", | ||
) | ||
|
||
pybind_py_library( | ||
name = "drake_ros_tf2_py", | ||
cc_deps = [ | ||
# TODO(sloretz) - depend on a shared library target | ||
# This links statically, and so can lead to ODR violations if the | ||
# python and C++ libraries are depended upon by the same python target. | ||
":drake_ros_tf2", | ||
":python_bindings_internal_hdrs", | ||
], | ||
cc_so_name = "drake_ros_tf2", | ||
cc_srcs = glob(["src/**/*_py.cc"]), | ||
py_deps = [ | ||
"@drake_ros_core//:drake_ros_core_py", | ||
], | ||
py_imports = ["src"], | ||
py_srcs = glob(["src/drake_ros_tf2/**/*.py"]), | ||
visibility = ["//visibility:public"], | ||
) | ||
|
||
ros_py_test( | ||
name = "test_tf_broadcaster_py", | ||
srcs = ["test/test_tf_broadcaster.py"], | ||
legacy_create_init = False, | ||
main = "test/test_tf_broadcaster.py", | ||
deps = [ | ||
":drake_ros_tf2_py", | ||
"@drake//bindings/pydrake", | ||
"@ros2//:rclpy_py", | ||
"@ros2//:tf2_ros_py_py", | ||
"@ros2//resources/rmw_isolation:rmw_isolation_py", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
workspace(name = "drake_ros_tf2") | ||
|
||
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") | ||
|
||
http_archive( | ||
name = "com_google_googletest", | ||
sha256 = "5cf189eb6847b4f8fc603a3ffff3b0771c08eec7dd4bd961bfd45477dd13eb73", # noqa | ||
strip_prefix = "googletest-609281088cfefc76f9d0ce82e1ff6c30cc3591e5", | ||
urls = ["https://github.com/google/googletest/archive/609281088cfefc76f9d0ce82e1ff6c30cc3591e5.zip"], # noqa | ||
) | ||
|
||
# Use the ROS 2 bazel rules | ||
local_repository( | ||
name = "bazel_ros2_rules", | ||
path = "../bazel_ros2_rules", | ||
) | ||
|
||
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") | ||
|
||
# Use ROS 2 | ||
ros2_archive( | ||
name = "ros2", | ||
include_packages = [ | ||
"geometry_msgs", | ||
"rclcpp", | ||
"tf2_ros", | ||
"tf2_ros_py", | ||
], | ||
sha256_url = "https://repo.ros2.org/ci_archives/drake-ros-underlay/ros2-humble-linux-focal-amd64-ci-CHECKSUM", # noqa | ||
strip_prefix = "ros2-linux", | ||
url = "http://repo.ros2.org/ci_archives/drake-ros-underlay/ros2-humble-linux-focal-amd64-ci.tar.bz2", # noqa | ||
) | ||
|
||
# Depend on Drake | ||
DRAKE_TAG = "v1.10.0" | ||
|
||
DRAKE_CHECKSUM = "78bd251bcfb349c988ee9225175a803a50cc53eaacdeb3bba200dfc82dcea305" # noqa | ||
|
||
http_archive( | ||
name = "drake", | ||
sha256 = DRAKE_CHECKSUM, | ||
strip_prefix = "drake-{}".format(DRAKE_TAG.lstrip("v")), | ||
urls = [ | ||
"https://github.com/RobotLocomotion/drake/archive/refs/tags/{}.tar.gz".format(DRAKE_TAG), # noqa | ||
], | ||
) | ||
|
||
load("@drake//tools/workspace:default.bzl", "add_default_workspace") | ||
|
||
add_default_workspace() | ||
|
||
local_repository( | ||
name = "drake_ros_core", | ||
path = "../drake_ros_core", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters