drake-ros
drake-ros copied to clipboard
[plugins] Unclear how to succinctly incorporate plotjugger data
I am trying to use plotjugger in our internal codebase (Anzu). I envisioned doing something like this in a BUILD.bazel
:
anzu_ros_sh_alias(
name = "plotjuggler",
data = [
# Ensures we can access the ROS 2 subscriber topic.
"@ros2//:plotjuggler_ros_cc",
],
# Provides access to custom-generated messages.
py_interface_deps = ["//:ros_msgs_all_py"],
target = "@ros2//:plotjuggler_plotjuggler",
)
However, to make this work, I had to do hack our our ros2/repository.bzl
(
click to expand)
_ROS_PACKAGES = [
...
"plotjuggler",
"plotjuggler_ros",
...
]
_BUILD_EXTRA_TPL = """
# Extra content for Anzu.
cc_library(
name = "plotjuggler_ros_cc",
data = [
":plotjuggler_ros_share",
":plotjuggler_ros_transitive_py",
] + glob(
["${workspace_prefix}/lib/plotjuggler_ros/lib*.so*"],
allow_empty=False,
),
)
"""
def _append_to_file(repo_ctx, file, content):
orig_content = repo_ctx.read(file)
new_content = orig_content + "\n" + content
repo_ctx.file(file, new_content)
def _anzu_ros2_local_repository_impl(repo_ctx):
...
base_ros2_repository(repo_ctx, workspaces_in_sandbox)
workspace_local_path = repo_ctx.attr.workspaces[0].replace("/", "_")
build_extra = _BUILD_EXTRA_TPL.replace(
"${workspace_prefix}",
workspace_local_path,
)
_append_to_file(repo_ctx, "BUILD.bazel", build_extra)
Questions
- Why did I have to inject my own
plotjuggler_ros_cc
library? I would've thought this would be caught by scanning. - Why did I have to include
plotjuggler_ros_transitive_py
? I would've thoughtplotjuggler_ros_share
should have covered it.