open3d-ros-helper
- Helper for jointly using open3d and ROS
- Easy conversion between ROS and open3d point cloud (supports both XYZ & XYZRGB point cloud)
- Easy conversion between ROS pose and transform
Dependencies
- python 2.7
- ros-numpy
- open3d == 0.9
Installation
$ sudo apt install ros-melodic-ros-numpy
$ pip2 install numpy open3d==0.9.0 opencv-python==4.2.0.32 pyrsistent==0.13
$ pip2 install open3d_ros_helper
Usage
Import open3d-ros-helper
from open3d_ros_helper import open3d_ros_helper as orh
Convert 4x4 SE(3) to geometry_msgs/Transform
import numpy as np
se3 = np.eye(4)
ros_transform = orh.se3_to_transform(se3)
Convert sensor.msg.PointCloud2 to open3d.geometry.PointCloud
o3dpc = orh.rospc_to_o3dpc(some_ros_pointcloud)
Convert open3d.geometry.PointCloud to sensor.msg.PointCloud2
rospc = orh.rospc_to_o3dpc(o3dpc)
Authors
- Seunghyeok Back seungback
License
This project is licensed under the MIT License
References
Some codes are rewritten from
Documentation
Table of contents
- pose_to_pq
- pose_stamped_to_pq
- transform_to_pq
- transform_stamped_to_pq
- msg_to_se3
- pq_to_transform
- pq_to_transform_stamped
- se3_to_transform
- se3_to_transform_stamped
- average_q
- average_pq
- rospc_to_o3dpc
- o3dpc_to_rospc
- do_transform_point
- apply_pass_through_filter
- crop_with_2dmask
- p2p_icp_registration
- ppf_icp_registration
pose_to_pq
pose_to_pq(pose)
convert a ROS PoseS message into position/quaternion np arrays
Arguments:
posegeometry_msgs/Pose - ROS geometric message to be converted
Returns:
pnp.array - position array of [x, y, z]qnp.array - quaternion array of [x, y, z, w] source codes from https://answers.ros.org/question/332407/transformstamped-to-transformation-matrix-python/
pose_stamped_to_pq
pose_stamped_to_pq(pose_stamped)
convert a ROS PoseStamped message into position/quaternion np arrays
Arguments:
pose_stampedgeometry_msgs/PoseStamped - ROS geometric message to be converted
Returns:
pnp.array - position array of [x, y, z]qnp.array - quaternion array of [x, y, z, w] source codes from https://answers.ros.org/question/332407/transformstamped-to-transformation-matrix-python/
transform_to_pq
transform_to_pq(transform)
convert a ROS Transform message into position/quaternion np arrays
Arguments:
transformgeometry_msgs/Transform - ROS geometric message to be converted
Returns:
pnp.array - position array of [x, y, z]qnp.array - quaternion array of [x, y, z, w] source codes from https://answers.ros.org/question/332407/transformstamped-to-transformation-matrix-python/
transform_stamped_to_pq
transform_stamped_to_pq(transform_stamped)
convert a ROS TransformStamped message into position/quaternion np arrays
Arguments:
transform_stampedgeometry_msgs/TransformStamped - ROS geometric message to be converted
Returns:
pnp.array - position array of [x, y, z]qnp.array - quaternion array of [x, y, z, w] source codes from https://answers.ros.org/question/332407/transformstamped-to-transformation-matrix-python/
msg_to_se3
msg_to_se3(msg)
convert geometric ROS messages to SE(3)
Arguments:
msg (geometry_msgs/Pose, geometry_msgs/PoseStamped, geometry_msgs/Transform, geometry_msgs/TransformStamped): ROS geometric messages to be converted
Returns:
se3np.array - a 4x4 SE(3) matrix as a numpy array source codes from https://answers.ros.org/question/332407/transformstamped-to-transformation-matrix-python/
pq_to_transform
pq_to_transform(p, q)
convert position, quaternion to geometry_msgs/Transform
Arguments:
pnp.array - position array of [x, y, z]qnp.array - quaternion array of [x, y, z, w]
Returns:
transformgeometry_msgs/Transform - ROS transform of given p and q
pq_to_transform_stamped
pq_to_transform_stamped(p, q, source_frame, target_frame, stamp=None)
convert position, quaternion to geometry_msgs/TransformStamped
Arguments:
pnp.array - position array of [x, y, z]qnp.array - quaternion array of [x, y, z, w]source_framestring - name of tf source frametarget_framestring - name of tf target frame
Returns:
transform_stampedgeometry_msgs/TransformStamped - ROS transform_stamped of given p and q
se3_to_transform
se3_to_transform(transform_nparray)
convert 4x4 SE(3) to geometry_msgs/Transform
Arguments:
transform_nparraynp.array - 4x4 SE(3)
Returns:
transformgeometry_msgs/Transform - ROS transform of given SE(3)
se3_to_transform_stamped
se3_to_transform_stamped(transform_nparray, source_frame, target_frame, stamp=None)
convert 4x4 SE(3) to geometry_msgs/TransformStamped
Arguments:
transform_nparraynp.array - 4x4 SE(3)source_framestring - name of tf source frametarget_framestring - name of tf target frame
Returns:
transform_stampedgeometry_msgs/TransformStamped - ROS transform_stamped of given SE(3)
average_q
average_q(qs)
calculate the average of quaternions
Arguments:
qsnp.array - multiple quaternion array of shape Nx4
Returns:
q_averagenp.array - averaged quaternion array source codes from https://github.com/christophhagen/averaging-quaternions
average_pq
average_pq(ps, qs)
average the multiple position and quaternion array
Arguments:
psnp.array - multiple position array of shape Nx3qsnp.array - multiple quaternion array of shape Nx4
Returns:
p_meannp.array - averaged position arrayq_meannp.array - averaged quaternion array
rospc_to_o3dpc
rospc_to_o3dpc(rospc, remove_nans=False)
covert ros point cloud to open3d point cloud
Arguments:
rospcsensor.msg.PointCloud2 - ros point cloud messageremove_nansbool - if true, ignore the NaN points
Returns:
o3dpcopen3d.geometry.PointCloud - open3d point cloud
o3dpc_to_rospc
o3dpc_to_rospc(o3dpc, frame_id=None, stamp=None)
convert open3d point cloud to ros point cloud
Arguments:
o3dpcopen3d.geometry.PointCloud - open3d point cloudframe_idstring - frame id of ros point cloud headerstamprospy.Time - time stamp of ros point cloud header
Returns:
rospcsensor.msg.PointCloud2 - ros point cloud message
do_transform_point
do_transform_point(o3dpc, transform_stamped)
transform a input cloud with respect to the specific frame open3d version of tf2_geometry_msgs.do_transform_point
Arguments:
o3dpcopen3d.geometry.PointCloud - open3d point cloudtransform_stampedgeometry_msgs.msgs.TransformStamped - transform to be applied
Returns:
o3dpcopen3d.geometry.PointCloud - transformed open3d point cloud
apply_pass_through_filter
apply_pass_through_filter(o3dpc, x_range, y_range, z_range)
apply 3D pass through filter to the open3d point cloud
Arguments:
o3dpcopen3d.geometry.PointCloud - open3d point cloudx_rangelist - list of [x_min, x_maz]y_rangelist - list of [y_min, y_maz]z_rangelist - list of [z_min, z_max]
Returns:
o3dpcopen3d.geometry.PointCloud - filtered open3d point cloud some codes from https://github.com/powersimmani/example_3d_pass_through-filter_guide
crop_with_2dmask
crop_with_2dmask(o3dpc, mask)
crop open3d point cloud with given 2d binary mask
Arguments:
o3dpcopen3d.geometry.PointCloud - open3d point cloudmasknp.array - binary mask aligned with the point cloud frame
Returns:
o3dpcopen3d.geometry.PointCloud - filtered open3d point cloud
p2p_icp_registration
p2p_icp_registration(source_cloud, target_cloud, n_points=100, threshold=0.02, relative_fitness=1e-10, relative_rmse=1e-8, max_iteration=500, max_correspondence_distance=500)
align the source cloud to the target cloud using point-to-point ICP registration algorithm
Arguments:
source_cloudopen3d.geometry.PointCloud - source open3d point cloudtarget_cloudopen3d.geometry.PointCloud - target open3d point cloud for other parameter, go to http://www.open3d.org/docs/0.9.0/python_api/open3d.registration.registration_icp.html
Returns:
icp_resultopen3d.registration.RegistrationResult - registration result
ppf_icp_registration
ppf_icp_registration(source_cloud, target_cloud, n_points=3000, n_iter=100, tolerance=0.05, num_levels=5)
align the source cloud to the target cloud using point pair feature (PPF) match
Arguments:
source_cloudopen3d.geometry.PointCloud - source open3d point cloudtarget_cloudopen3d.geometry.PointCloud - target open3d point cloud for other parameter, go to https://docs.opencv.org/master/dc/d9b/classcv_1_1ppf__match__3d_1_1ICP.html
Returns:
posenp.array - 4x4 transformation between source and targe cloudresidualfloat - the output resistration error
Metadata
Release files for open3d-ros-helper 0.2.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| open3d_ros_helper-0.2.0.3.tar.gz | 10.7 kB | Without provenance | Details for open3d_ros_helper-0.2.0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| open3d_ros_helper-0.2.0.3-py2-none-any.whl | Python 2 | none | any | Details for open3d_ros_helper-0.2.0.3-py2-none-any.whl |
Total release size: 20.7 kB
Release files / open3d_ros_helper-0.2.0.3.tar.gz
| Download URL | open3d_ros_helper-0.2.0.3.tar.gz |
|---|---|
| Size | 10.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0179ea93b1c02d3ec433caa11eadf8675dacff7b5b28331676bb69aae509b6d0
|
|
BLAKE2b-256 checksum How to use checksums |
d043e8ba381e3c52768470b317450b8243b00fe3f061da7e4c8e5f156414737f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.15.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/44.1.1 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/2.7.18
|
Release files / open3d_ros_helper-0.2.0.3-py2-none-any.whl
| Download URL | open3d_ros_helper-0.2.0.3-py2-none-any.whl |
|---|---|
| Size | 9.9 kB |
| Tags | Python 2 |
|
SHA-256 checksum How to use checksums |
00364ef5486b219340a5255ff91c329a45f52a03cc0b5dfaa311c0938f62b7ad
|
|
BLAKE2b-256 checksum How to use checksums |
1aad88c440885110da8ba0636322b62cea00ff955a049fcadaf4e3010508432b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.15.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/44.1.1 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/2.7.18
|
Security for open3d-ros-helper 0.2.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.