Provide a converter to convert ROS message to dict and vice versa
Project description
rosmsg_dict_converter
Description
This package provides a tool to convert a ROS message dictionary to a Python dictionary and vice versa.
Features
- Convert a ROS message dictionary to a Python dictionary
- Convert a Python dictionary to a ROS message dictionary
- Allow populate empty lists with default values for the message types.
- Also allows passing an existing message to update its fields with values from the dictionary.
Installation
pip install rosmsg_dict_converter
Usage
- ros_message_to_dict
from rosmsg_dict_converter.converver import ros_message_to_dict
from geometry_msgs.msg import Pose
# ros message to dict
pose = Pose()
pose_dict = ros_message_to_dict(pose)
- dict_to_ros_message
from rosmsg_dict_converter.converver import dict_to_ros_message
from geometry_msgs.msg import Pose
# dict to ros message
pose_dict = {
'position': {
'x': 1.0,
'y': 2.0,
'z': 3.0
},
'orientation': {
'x': 0.0,
'y': 0.0,
'z': 0.0,
'w': 1.0
}
}
pose = dict_to_ros_message("geometry_msgs/Pose", pose_dict)
- populate_empty_lists
from rosmsg_dict_converter.converver import ros_message_to_dict,
from geometry_msgs.msg import PoseArray
# ros message to dict
pose_array = PoseArray()
pose_array_dict = ros_message_to_dict(pose_array, include_defaults=True)
# output
# pose_array_dict={'header': {'seq': 0, 'stamp': {'secs': 0, 'nsecs': 0}, 'frame_id': ''}, 'poses': [{'position': {'x': 0.0, 'y': 0.0, 'z': 0.0}, 'orientation': {'x': 0.0, 'y': 0.0, 'z': 0.0, 'w': 0.0}}]}
- update_ros_message
from rosmsg_dict_converter.converver import a_dict_to_ros_message,ros_message_to_dict
from geometry_msgs.msg import Point
point = Point()
point.x = 1.0
point_dict = ros_message_to_dict(point)
point_dict["y"] = 2.0
# the value of point.x is still 1.0
point = a_dict_to_ros_message(point, point_dict)
console.print(f"{point=}")
# output
# point=Point(x=1.0, y=2.0, z=0.0)
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 rosmsg_dict_converter-0.1.1.tar.gz.
File metadata
- Download URL: rosmsg_dict_converter-0.1.1.tar.gz
- Upload date:
- Size: 9.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b9564304e063e72645083502e78eb1b24780ecdf3b515feb9c2564677cecf35a
|
|
| MD5 |
f2f459ac4d2c5c243d5ab2df78cddeba
|
|
| BLAKE2b-256 |
56d2fb85a8a24c2e15aac5aa85a4fa63f1001c5b111121f4f427a21190450edc
|
Provenance
The following attestation bundles were made for rosmsg_dict_converter-0.1.1.tar.gz:
Publisher:
ci.yaml on yumeminami/rosmsg_dict_converter
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rosmsg_dict_converter-0.1.1.tar.gz -
Subject digest:
b9564304e063e72645083502e78eb1b24780ecdf3b515feb9c2564677cecf35a - Sigstore transparency entry: 259068312
- Sigstore integration time:
-
Permalink:
yumeminami/rosmsg_dict_converter@e3ae229bb86844fcc1d8facd39fddb340a2b5f34 -
Branch / Tag:
refs/heads/master - Owner: https://github.com/yumeminami
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yaml@e3ae229bb86844fcc1d8facd39fddb340a2b5f34 -
Trigger Event:
push
-
Statement type:
File details
Details for the file rosmsg_dict_converter-0.1.1-py3-none-any.whl.
File metadata
- Download URL: rosmsg_dict_converter-0.1.1-py3-none-any.whl
- Upload date:
- Size: 13.8 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 |
db072d73a203303348da6eac643582fc24e8374daf6829bc5fc7b757bcddde71
|
|
| MD5 |
ae80efcb1d991f81b4f1e768185dac06
|
|
| BLAKE2b-256 |
930d85fcc13728264f7098e80d8a406fe7e77de71f18ca57b3a065b9e7f81e40
|
Provenance
The following attestation bundles were made for rosmsg_dict_converter-0.1.1-py3-none-any.whl:
Publisher:
ci.yaml on yumeminami/rosmsg_dict_converter
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rosmsg_dict_converter-0.1.1-py3-none-any.whl -
Subject digest:
db072d73a203303348da6eac643582fc24e8374daf6829bc5fc7b757bcddde71 - Sigstore transparency entry: 259068323
- Sigstore integration time:
-
Permalink:
yumeminami/rosmsg_dict_converter@e3ae229bb86844fcc1d8facd39fddb340a2b5f34 -
Branch / Tag:
refs/heads/master - Owner: https://github.com/yumeminami
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yaml@e3ae229bb86844fcc1d8facd39fddb340a2b5f34 -
Trigger Event:
push
-
Statement type: