A ROS2 package for transmitting NumPy ndarrays between ROS2 nodes.
Project description
ROS2 NDArray Message
A ROS2 package for transmitting NumPy ndarrays between ROS2 nodes.
Features
- Custom ROS2 message type for numpy.ndarray
- Bi-directional conversion between NumPy arrays and ROS2 messages
- Multi-dimensional array support with various data types
- Type-safe Python utilities with full type hints
Requirements
- ROS2 Humble or higher
- Python 3.10+
Installation
cd ~/ros2_ws/src
git clone https://github.com/Geson-anko/numpy_ndarray_msgs.git
cd ../
colcon build --packages-select numpy_ndarray_msgs
source install/setup.sh
Install Python Utility Package
pip install ros2-ndarray-msg-utils
Usage
Python Utility Package
import numpy as np
from ndarray_msg_utils import to_ros_msg, from_ros_msg, NDArray
from rclpy.clock import ROSClock
# Convert NumPy array to ROS2 message
array = np.array([[1, 2], [3, 4]], dtype=np.float32)
# Type Hint
msg: NDArray
msg = to_ros_msg(array)
# with Header
msg = to_ros_msg(array, timestamp=ROSClock().now(), frame_id="array_frame")
# Convert back to NumPy array
restored = from_ros_msg(msg)
PyTorch Support
pip install "ros2-ndarray-msg-utils[torch]"
import torch
from ndarray_msg_utils.torch import to_ros_msg, from_ros_msg
# Convert PyTorch tensor to ROS2 message
tensor = torch.tensor([[1, 2], [3, 4]], dtype=torch.float32)
msg = to_ros_msg(tensor)
# Convert back to PyTorch tensor
restored = from_ros_msg(msg)
License
MIT License
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 ros2_ndarray_msg_utils-0.2.0.tar.gz.
File metadata
- Download URL: ros2_ndarray_msg_utils-0.2.0.tar.gz
- Upload date:
- Size: 43.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9a0d1f11bb503ae7a810ce873e61bf46b6717257161ebb2962e677b0046f8f3d
|
|
| MD5 |
62f61bbe0c6b311dfe55224e2a120af7
|
|
| BLAKE2b-256 |
f85f31d4dbf826212037481b8a598c3213211b5e5d94bd31c3d638850de91d65
|
Provenance
The following attestation bundles were made for ros2_ndarray_msg_utils-0.2.0.tar.gz:
Publisher:
publish-to-pypi.yml on Geson-anko/numpy_ndarray_msgs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ros2_ndarray_msg_utils-0.2.0.tar.gz -
Subject digest:
9a0d1f11bb503ae7a810ce873e61bf46b6717257161ebb2962e677b0046f8f3d - Sigstore transparency entry: 188647462
- Sigstore integration time:
-
Permalink:
Geson-anko/numpy_ndarray_msgs@79d082f68d81e1e514682b366133d930f06b7060 -
Branch / Tag:
refs/tags/0.2.0 - Owner: https://github.com/Geson-anko
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@79d082f68d81e1e514682b366133d930f06b7060 -
Trigger Event:
push
-
Statement type:
File details
Details for the file ros2_ndarray_msg_utils-0.2.0-py3-none-any.whl.
File metadata
- Download URL: ros2_ndarray_msg_utils-0.2.0-py3-none-any.whl
- Upload date:
- Size: 5.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
624cc24e1af92326c2107b80043e730dd957956564bc49fb1034437ca0c7c6da
|
|
| MD5 |
5163bac791f6900e536361706871870f
|
|
| BLAKE2b-256 |
7c71376b8887b7fbeffe2f73eda263fe7579300b01008f617547858223eee21b
|
Provenance
The following attestation bundles were made for ros2_ndarray_msg_utils-0.2.0-py3-none-any.whl:
Publisher:
publish-to-pypi.yml on Geson-anko/numpy_ndarray_msgs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ros2_ndarray_msg_utils-0.2.0-py3-none-any.whl -
Subject digest:
624cc24e1af92326c2107b80043e730dd957956564bc49fb1034437ca0c7c6da - Sigstore transparency entry: 188647464
- Sigstore integration time:
-
Permalink:
Geson-anko/numpy_ndarray_msgs@79d082f68d81e1e514682b366133d930f06b7060 -
Branch / Tag:
refs/tags/0.2.0 - Owner: https://github.com/Geson-anko
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@79d082f68d81e1e514682b366133d930f06b7060 -
Trigger Event:
push
-
Statement type: