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

Adds support for plotjuggler & improves parsing logic. #336

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
17 changes: 17 additions & 0 deletions bazel_ros2_rules/ros2/resources/ros2bzl/scraping/metadata.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,27 @@
import os
import xml.etree.ElementTree as ET

# Remove elemets that have a condition attribute on ROS1
def remove_ros1_elements(root):
ros1_condition_value = "$ROS_VERSION == 1"
elements_to_remove = []

for parent in root.iter():
for child in list(parent):
if "condition" in child.attrib:
if child.get('condition') == ros1_condition_value :
elements_to_remove.append((parent, child))
else :
child.attrib.pop("condition")

for parent, child in elements_to_remove:
parent.remove(child)

def parse_package_xml(path_to_package_xml):
tree = ET.parse(path_to_package_xml)

remove_ros1_elements(tree.getroot())

depends = set([
tag.text for tag in tree.findall('./depend')
])
Expand Down
8 changes: 8 additions & 0 deletions bazel_ros2_rules/ros2/resources/ros2bzl/templates.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
import pathlib
import glob

from ros2bzl.resources import load_resource
from ros2bzl.scraping.system import find_library_path
Expand Down Expand Up @@ -108,6 +109,13 @@ def configure_package_cc_library(
sandbox(find_library_path(library))
for library in metadata['plugin_libraries']
)
# Add an exception for plotjuggler-ros, as it does not
# use pluginlib, and the manifest does not mention its plugins.
# The paths for the plugins are hardcoded in plotjuggler :
# https://github.com/facontidavide/PlotJuggler/blob/15dce41f598daed841bf2093aa10ebdf2aa1052f/plotjuggler_app/mainwindow.cpp#L560-L566
if 'plotjuggler_ros' in target_name:
prefix = "_opt_ros_humble/lib/plotjuggler_ros/"
data.extend(glob.glob(prefix + "lib*.so"))
# Prepare runfiles to support dynamic loading
data.extend(library for library in libraries if library not in data)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ if("@PACKAGE@" STREQUAL "rviz_ogre_vendor")
set(CMAKE_FIND_LIBRARY_PREFIXES ";lib")
endif()

if("@PACKAGE@" STREQUAL "plotjuggler")
find_package(Qt5 COMPONENTS Widgets Concurrent Svg REQUIRED)
endif()

find_package(@PACKAGE@ REQUIRED)

file(WRITE empty.cc "")
Expand Down
2 changes: 2 additions & 0 deletions ros2_example_bazel_installed/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ git_repository(

# Please keep this list sorted
ROS2_PACKAGES = [
"plotjuggler",
"plotjuggler_ros",
"action_msgs",
"builtin_interfaces",
"console_bridge_vendor",
Expand Down
18 changes: 18 additions & 0 deletions ros2_example_bazel_installed/ros2_example_apps/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -272,3 +272,21 @@ ros_cc_test(
"@ros2//resources/rmw_isolation:rmw_isolation_cc",
],
)

# This is a roll-up target to use plotjuggler with the required
# ROS plugins. Usage :
# bazel run //ros2_example_apps:plotjuggler
ros_py_binary(
name = "plotjuggler",
srcs = ["plotjuggler.py"],
data = [
"@ros2//:plotjuggler_ros_cc",
"@ros2//:plotjuggler_ros_share",
"@ros2//:plotjuggler_ros_transitive_py",
],
deps = [
"//:ros_msgs_all_py",
"@bazel_tools//tools/python/runfiles",
"@ros2//:plotjuggler_plotjuggler",
],
)
21 changes: 21 additions & 0 deletions ros2_example_bazel_installed/ros2_example_apps/plotjuggler.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
"""
adityapande-1995 marked this conversation as resolved.
Show resolved Hide resolved
Roll up script for plotjuggler with ROS.
"""


import os
import subprocess
from bazel_tools.tools.python.runfiles import runfiles

def main():
r = runfiles.Create()
binary_path = r.Rlocation("ros2/plotjuggler_plotjuggler")

if not binary_path:
raise FileNotFoundError("Could not find plotjuggler binary")

# Run the binary
subprocess.run(binary_path, check=True)

if __name__ == "__main__":
main()
1 change: 1 addition & 0 deletions ros2_example_bazel_installed/setup/install_prereqs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ if [[ -z "${ROS2_DISTRO_PREFIX:-}" ]]; then
apt install ros-humble-desktop
apt install ros-humble-rmw-cyclonedds-cpp
apt install ros-dev-tools
apt install ros-humble-plotjuggler-ros
fi

# Install Python dependencies
Expand Down
9 changes: 9 additions & 0 deletions ros2_example_bazel_installed/setup/prereq-rosdep-keys.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
assimp
binutils
boost
bullet
cmake
cppcheck
Expand All @@ -20,16 +22,23 @@ libpcl-all-dev
libqt5-core
libqt5-gui
libqt5-opengl
libqt5-opengl-dev
libqt5-svg
libqt5-svg-dev
libqt5-websockets-dev
libqt5-widgets
libqt5x11extras5-dev
libsqlite3-dev
libx11-dev
libxaw
libxml2-utils
libxrandr
libzmq3-dev
libzstd-dev
lz4
opengl
pkg-config
protobuf-dev
pybind11-dev
pydocstyle
python3
Expand Down
Loading