A helper tool for jointly using open3d and ROS
Project description
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file open3d_ros_helper-0.2.0.3.tar.gz.
File metadata
- Download URL: open3d_ros_helper-0.2.0.3.tar.gz
- Upload date:
- Size: 10.7 kB
- Tags: Source
- Uploaded using 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
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0179ea93b1c02d3ec433caa11eadf8675dacff7b5b28331676bb69aae509b6d0
|
|
| MD5 |
ea28773be05f7b0e0179cd2a7106ca82
|
|
| BLAKE2b-256 |
d043e8ba381e3c52768470b317450b8243b00fe3f061da7e4c8e5f156414737f
|
File details
Details for the file open3d_ros_helper-0.2.0.3-py2-none-any.whl.
File metadata
- Download URL: open3d_ros_helper-0.2.0.3-py2-none-any.whl
- Upload date:
- Size: 9.9 kB
- Tags: Python 2
- Uploaded using 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
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
00364ef5486b219340a5255ff91c329a45f52a03cc0b5dfaa311c0938f62b7ad
|
|
| MD5 |
e051b654fa4f05d30ca10543e1f2dd59
|
|
| BLAKE2b-256 |
1aad88c440885110da8ba0636322b62cea00ff955a049fcadaf4e3010508432b
|