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

Add support for LZ4 compressed rosbags to the py_rosbag target #63

Open
jmauthe opened this issue Oct 30, 2024 · 2 comments
Open

Add support for LZ4 compressed rosbags to the py_rosbag target #63

jmauthe opened this issue Oct 30, 2024 · 2 comments

Comments

@jmauthe
Copy link

jmauthe commented Oct 30, 2024

To read LZ4 compressed rosbags via the py_rosbag target from Python, the roslz4 module needs to be passed as a dependency, as it is dynamically loaded during the imports of the bag.py module. See, in the bag.py implementation in the ros_comm repository.

Can we please add this support to the rule set here?

@mvukov
Copy link
Owner

mvukov commented Nov 2, 2024

Sounds good to me. Please feel free to impl this and open a PR.

@jmauthe
Copy link
Author

jmauthe commented Nov 21, 2024

I've started implementing on this. These are the changes I currently have for the ros_comm.BUILD.bazel:

diff --git a/ros/repositories/ros_comm.BUILD.bazel b/ros/repositories/ros_comm.BUILD.bazel
index 29a8062..5ad229e 100644
--- a/ros/repositories/ros_comm.BUILD.bazel
+++ b/ros/repositories/ros_comm.BUILD.bazel
@@ -239,6 +239,40 @@ cc_ros_library(
     ],
 )
 
+
+cc_ros_library(
+    name = "roslz4_py_lib",
+    srcs = ["utilities/roslz4/src/_roslz4module.c"],
+    visibility = ["//visibility:public"],
+    copts = ["-Wno-missing-field-initializers", "-Wno-unused-variable", "-Wno-strict-aliasing"],
+    deps = [
+        ":roslz4",
+        "@roscpp_core//:cpp_common",
+        "@rules_python//python/cc:current_py_cc_headers"
+    ],
+)
+
+cc_binary(
+    name = "_roslz4.so",
+    linkshared = 1,
+    deps = [":roslz4_py_lib"],
+)
+
+genrule(
+    name = "copy_roslz4_py_so",
+    srcs = ["_roslz4.so"],
+    outs = ["utilities/roslz4/src/roslz4/_roslz4.so"],
+    cmd = "cp $< $@",
+)
+
+py_library(
+    name = "roslz4_py",
+    srcs = glob(["utilities/roslz4/**/*.py"]),
+    imports = ["utilities/roslz4/src"],
+    data = [":copy_roslz4_py_so"],
+    visibility = ["//visibility:public"],
+)
+
 cc_ros_library(
     name = "rosbag_storage",
     srcs = [
@@ -349,6 +383,7 @@ py_library(
     deps = [
         ":py_topic_tools",
         ":rospy",
+        ":roslz4_py",
         "@rules_ros//third_party/ros:roslib",
         requirement("gnupg"),
         requirement("pycryptodomex"),



I'm currently struggling when importing the python bag module, which tries to load the _roslz4 module. There I get the following error: dynamic module does not define module export function (PyInit__roslz4)
So it seems python does not find the init function in the shared object file, which should be there
Any idea what is causing this?

I can also open a PR if it's easier to discuss there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants