-
Notifications
You must be signed in to change notification settings - Fork 7
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
Added point_cloud_transport_py #26
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
Empty file.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,70 @@ | ||
cmake_minimum_required(VERSION 3.5) | ||
project(point_cloud_transport_py) | ||
|
||
# Default to C99 | ||
if(NOT CMAKE_C_STANDARD) | ||
set(CMAKE_C_STANDARD 99) | ||
endif() | ||
|
||
# Default to C++17 | ||
if(NOT CMAKE_CXX_STANDARD) | ||
set(CMAKE_CXX_STANDARD 17) | ||
set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
endif() | ||
|
||
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") | ||
add_compile_options(-Wall -Wextra -Wpedantic) | ||
endif() | ||
|
||
# Figure out Python3 debug/release before anything else can find_package it | ||
if(WIN32 AND CMAKE_BUILD_TYPE STREQUAL "Debug") | ||
find_package(python_cmake_module REQUIRED) | ||
find_package(PythonExtra REQUIRED) | ||
|
||
# Force FindPython3 to use the debug interpreter where ROS 2 expects it | ||
set(Python3_EXECUTABLE "${PYTHON_EXECUTABLE_DEBUG}") | ||
endif() | ||
|
||
|
||
find_package(ament_cmake REQUIRED) | ||
find_package(ament_cmake_python REQUIRED) | ||
find_package(ament_cmake_ros REQUIRED) | ||
find_package(point_cloud_transport REQUIRED) | ||
find_package(pluginlib REQUIRED) | ||
find_package(rclcpp REQUIRED) | ||
find_package(sensor_msgs REQUIRED) | ||
|
||
# Find python before pybind11 | ||
find_package(Python3 REQUIRED COMPONENTS Interpreter Development) | ||
|
||
find_package(pybind11_vendor REQUIRED) | ||
find_package(pybind11 REQUIRED) | ||
|
||
ament_python_install_package(${PROJECT_NAME}) | ||
|
||
pybind11_add_module(_point_cloud_transport SHARED | ||
src/point_cloud_transport_py/pybind_point_cloud_transport.cpp | ||
) | ||
target_link_libraries(_point_cloud_transport PUBLIC | ||
point_cloud_transport::point_cloud_transport | ||
rclcpp::rclcpp | ||
${sensor_msgs_TARGETS} | ||
) | ||
|
||
pybind11_add_module(_codec SHARED | ||
src/point_cloud_transport_py/pybind_codec.cpp | ||
) | ||
target_link_libraries(_codec PUBLIC | ||
point_cloud_transport::point_cloud_transport | ||
pluginlib::pluginlib | ||
) | ||
|
||
# Install cython modules as sub-modules of the project | ||
install( | ||
TARGETS | ||
_point_cloud_transport | ||
_codec | ||
DESTINATION "${PYTHON_INSTALL_DIR}/${PROJECT_NAME}" | ||
) | ||
|
||
ament_package() |
File renamed without changes.
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 |
---|---|---|
|
@@ -75,7 +75,7 @@ def __init__(self): | |
print('Topics to publish: \n', self.topics_to_publish) | ||
|
||
self.declare_parameter('enable_pub_plugins', Parameter.Type.STRING_ARRAY) | ||
whitelist = self.get_parameter('enable_pub_plugins') | ||
whitelist = self.get_parameter_or('enable_pub_plugins', ["raw", "draco"]) | ||
|
||
self.transport_publishers = {} | ||
for transport in self.topics_to_publish: | ||
|
@@ -86,15 +86,16 @@ def __init__(self): | |
stringToMsgType(topic_to_publish.data_type), topic_to_publish.topic, 1) | ||
|
||
def publish(self, raw: PointCloud2): | ||
for transport, transport_info in self.topics_to_publish.items(): | ||
compressed_buffer = self.codec.encode( | ||
transport_info.name, pointCloud2ToString(raw)) | ||
if compressed_buffer: | ||
# rclpy is smart and will publish the correct type even though we | ||
# are giving it a serialized array of bytes | ||
self.transport_publishers[transport].publish(compressed_buffer) | ||
else: | ||
self.get_logger().error('Error encoding message!') | ||
# for transport, transport_info in self.topics_to_publish.items(): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you need to uncomment this for loop, right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. publisher.py and subscriber.py should be removed. This functionality is available from pybind11 |
||
self.transport_publishers[transport].publish(raw) | ||
# compressed_buffer = self.codec.encode( | ||
# transport_info.name, pointCloud2ToString(raw)) | ||
# if compressed_buffer: | ||
# # rclpy is smart and will publish the correct type even though we | ||
# # are giving it a serialized array of bytes | ||
# self.transport_publishers[transport].publish(raw) | ||
# else: | ||
# self.get_logger().error('Error encoding message!') | ||
|
||
|
||
if __name__ == '__main__': | ||
|
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,34 @@ | ||
<package format="3"> | ||
<name>point_cloud_transport_py</name> | ||
|
||
<version>0.0.0</version> | ||
|
||
<description>Python API for point_cloud_transport</description> | ||
|
||
<author>Alejandro Hernandez Cordero</author> | ||
|
||
<maintainer email="[email protected]">Alejandro Hernández</maintainer> | ||
<maintainer email="[email protected]">John D'Angelo</maintainer> | ||
|
||
<license>BSD</license> | ||
|
||
<url type="repository">https://github.com/ros-perception/point_cloud_transport</url> | ||
<url type="bugtracker">https://github.com/ros-perception/point_cloud_transport/issues</url> | ||
|
||
<buildtool_depend>ament_cmake_ros</buildtool_depend> | ||
<buildtool_depend>ament_cmake_python</buildtool_depend> | ||
<buildtool_depend>python_cmake_module</buildtool_depend> | ||
|
||
<depend>point_cloud_transport</depend> | ||
<depend>pybind11_vendor</depend> | ||
<depend>pluginlib</depend> | ||
<depend>rclcpp</depend> | ||
<depend>sensor_msgs</depend> | ||
|
||
<exec_depend>rpyutils</exec_depend> | ||
|
||
<export> | ||
<build_type>ament_cmake</build_type> | ||
</export> | ||
|
||
</package> |
38 changes: 38 additions & 0 deletions
38
point_cloud_transport_py/point_cloud_transport_py/__init__.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Copyright 2023 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. | ||
|
||
from rpyutils import add_dll_directories_from_env | ||
|
||
# Since Python 3.8, on Windows we should ensure DLL directories are explicitly added | ||
# to the search path. | ||
# See https://docs.python.org/3/whatsnew/3.8.html#bpo-36085-whatsnew | ||
with add_dll_directories_from_env('PATH'): | ||
from point_cloud_transport_py._point_cloud_transport import ( | ||
PointCloudTransport, | ||
Publisher, | ||
Subscriber, | ||
) | ||
from point_cloud_transport_py._codec import ( | ||
PointCloudCodec, | ||
VectorString, | ||
) | ||
|
||
|
||
__all__ = [ | ||
'Publisher', | ||
'Subscriber', | ||
'PointCloudTransport', | ||
'PointCloudCodec', | ||
'VectorString' | ||
] |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this necessary, considering the existing definition of advertise on line 167 below?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah is this to make the python binding easier?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, it's to simplify things