ros2_numpy
Note: This is the same as the original ros_numpy package by eric-wieser and ros2_numpy package by box-robotics just edited to be OS independent and installable using pip.
Pointcloud manipulation is updated ros2_numpy.pointcloud2 to be compatible with ROS2. It now gives a structured numpy array with the fields x, y, z, rgb, intensity. The rgb field is a 3-tuple of uint8 values. The intensity field is a float32 value. The x, y, z fields are float32 values.
This project is a fork of ros2_numpy to work with ROS 2. It provides tools for converting ROS messages to and from numpy arrays. In the ROS 2 port, the module has been renamed to
ros2_numpy. Users are encouraged to update their application code to import
the module as shown below.
pip install ros2-numpy
import ros2_numpy as rnp
Prefacing your calls like rnp.numpify(...) or rnp.msgify(...) should help
future proof your codebase while the ROS 2 ports are API compatible.
This module contains two core functions:
arr = numpify(msg, ...)- try to get a numpy object from a messagemsg = msgify(MessageType, arr, ...)- try and convert a numpy object to a message
Currently supports:
-
sensor_msgs.msg.PointCloud2↔ structureddict: # See PointCloud2 message type in ros2data = {"xyz": np.random.rand(100, 3), "rgb": np.random.rand(100, 3)} msg = ros2_numpy.msgify(PointCloud2, data)
data = ros2_numpy.numpify(msg) -
sensor_msgs.msg.Image↔ 2/3-Dnp.array, similar to the function ofcv_bridge, but without the dependency oncv2 -
nav_msgs.msg.OccupancyGrid↔np.ma.array -
geometry.msg.Vector3↔ 1-Dnp.array.hom=Truegives[x, y, z, 0] -
geometry.msg.Point↔ 1-Dnp.array.hom=Truegives[x, y, z, 1] -
geometry.msg.Quaternion↔ 1-Dnp.array,[x, y, z, w] -
geometry.msg.Transform↔ 4×4np.array, the homogeneous transformation matrix -
geometry.msg.Pose↔ 4×4np.array, the homogeneous transformation matrix from the origin
Support for more types can be added with:
@ros2_numpy.converts_to_numpy(SomeMessageClass)
def convert(my_msg):
return np.array(...)
@ros2_numpy.converts_from_numpy(SomeMessageClass)
def convert(my_array):
return SomeMessageClass(...)
Any extra args or kwargs to numpify or msgify will be forwarded to your conversion function
Future work
-
Add simple conversions for:
geometry_msgs.msg.Inertia
Metadata
Release files for ros2-numpy 0.0.5
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 |
|---|---|---|---|---|
| ros2_numpy-0.0.5.tar.gz | 10.8 kB | Without provenance | Details for ros2_numpy-0.0.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ros2_numpy-0.0.5-py3-none-any.whl | Python 3 | none | any | Details for ros2_numpy-0.0.5-py3-none-any.whl |
Total release size: 19.6 kB
Release files / ros2_numpy-0.0.5.tar.gz
| Download URL | ros2_numpy-0.0.5.tar.gz |
|---|---|
| Size | 10.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e7e446647e5e4d1020ea0e6b389f750d3fdb642bbe3e56ab0e53f41746ddd6f8
|
|
BLAKE2b-256 checksum How to use checksums |
ef1cf693a49765543a890f3cc04f8bb129d1209c2cf85c322f8ea64d189a966c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.9.21
|
Release files / ros2_numpy-0.0.5-py3-none-any.whl
| Download URL | ros2_numpy-0.0.5-py3-none-any.whl |
|---|---|
| Size | 8.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0c4db675c25cc7de163455d6dcbf338e28aaee5d0805754843f60ac663d48362
|
|
BLAKE2b-256 checksum How to use checksums |
b11bb27812080944ce0657d2bd44e8bf3f89e41af702e157fa9b542cbf02cb2b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.9.21
|
Security for ros2-numpy 0.0.5
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.