ros2_msg_conversions
Implements ros2 message conversion operations.
Methods
Convert ROS2 structures to OrderedDict
Can be used to convert any type of ROS2 communication structure (Topic Message, Service, Action).
def ros2_msg_to_dict(msg: Any) -> OrderedDict:
"""ros2_msg_to_dict.
Converts a ROS2 communication message to an OrderedDict.
Args:
msg: ROS2 Message to transform. Can be one of type:
- Topic Message (Message)
- Service Request Message (Service.Request)
- Service Response Message (Service.Response)
- Action Goal Message (Action.Goal)
- Action Cancel Message (Action.Cancel)
- Action Result Message (Action.Result)
- Action Status Message (Action.Status)
- Action Feedback Message (Action.Feedback)
"""
Below are two examples, one for converting a ROS2 msg and one for converting a ROS2 srv into an OrderedDict.
from sensor_msgs.msg import Range
msg = Range()
_dict = ros2_msg_to_dict(msg)
from std_srvs.srv import SetBool
req = SetBool.Request()
_dict = ros2_msg_to_dict(req)
Convert an OrderedDict to a ROS2 communication structure
Can be used to convert into any type of ROS2 communication structure (Topic Message, Service, Action).
def dict_to_ros2_msg(py_dict: OrderedDict, msg_cls: Any) -> Any:
"""dict_to_ros2_msg.
Converts a dict/OrderedDict into a ROS2 message, given the message cls
as input.
Args:
py_dict (OrderedDict): Dict/OrderedDict to convert to ROS2 message.
msg_cls (Any): ROS2 Message class.
- Topic Message (Message)
- Service Request Message (Service.Request)
- Service Response Message (Service.Response)
- Action Goal Message (Action.Goal)
- Action Cancel Message (Action.Cancel)
- Action Result Message (Action.Result)
- Action Status Message (Action.Status)
- Action Feedback Message (Action.Feedback)
"""
Below are two examples, one for converting a ROS2 msg and one for converting a ROS2 srv into an OrderedDict.
from sensor_msgs.msg import Range
_dict = {
'range': 10.0,
'min_range': 0.2,
'max_range': 240.0,
'field_of_view': 60.0,
'radiation_type': 0,
}
_msg = dict_to_ros2_msg(_dict, Range)
from std_srvs.srv import SetBool
...
_req = dict_to_ros2_msg(_dict, SetBool.Request)
_resp = dict_to_ros2_msg(_dict, SetBool.Response)
You can also construct from and to ROS2 message structures without the need to import them. This is achieved via passing a string that includes the namespace of the message.
_msg = dict_to_ros2_msg_from_ns(_dict, 'sensor_msgs/Range')
_msg = dict_to_ros2_srv_from_ns(_dict, 'std_srvs/SetBool.Request')
Metadata
Release files for ros2-msg-transform 0.2.2
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_msg_transform-0.2.2.tar.gz | 2.9 kB | Without provenance | Details for ros2_msg_transform-0.2.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ros2_msg_transform-0.2.2-py3-none-any.whl | Python 3 | none | any | Details for ros2_msg_transform-0.2.2-py3-none-any.whl |
Total release size: 6.9 kB
Release files / ros2_msg_transform-0.2.2.tar.gz
| Download URL | ros2_msg_transform-0.2.2.tar.gz |
|---|---|
| Size | 2.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
597a91a2330ad73224c8c1fa2c61c5ea4495ea6bdb33cf3b53b1bfd1e784ae48
|
|
BLAKE2b-256 checksum How to use checksums |
2afdd04059dcb2b677ddd8ba365a64403e0904ab6ea03aca19160786d1f58bcc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.7.1 CPython/3.11.6 Linux/6.6.8-2-MANJARO
|
Release files / ros2_msg_transform-0.2.2-py3-none-any.whl
| Download URL | ros2_msg_transform-0.2.2-py3-none-any.whl |
|---|---|
| Size | 4.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
847c1d5a5ee22da254c391afe336690895219796cd03326c40b2e4add0dbeee8
|
|
BLAKE2b-256 checksum How to use checksums |
6b8afd508990e403215b0ef6f296a8209bfd3f7ede231f3ae1f2988ac6786285
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.7.1 CPython/3.11.6 Linux/6.6.8-2-MANJARO
|
Security for ros2-msg-transform 0.2.2
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.