-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Decode ROS2 raw byte data using rclpy.serialization.deserialize_message
ros2/rclpy#1273 Signed-off-by: Tomoya Fujita <[email protected]>
- Loading branch information
1 parent
886f1da
commit 81f587f
Showing
2 changed files
with
21 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from std_msgs.msg import String | ||
from rclpy.serialization import deserialize_message, serialize_message | ||
|
||
# Serialized message data | ||
#serialized_data = b'\x01\x03\x00\x00\x00\xb3\xa8\xbfFb\x89\xc8\x17\x00\x01\x00\x00I\x00\x00\x00Hello, world! Time(nanoseconds=1713770713401001821, clock_type=ROS_TIME)\x00\x00\x00\x00' | ||
|
||
def main(): | ||
msg = String() | ||
msg.data = 'Hello, world!' | ||
msg_serialized = serialize_message(msg) | ||
print(msg_serialized) | ||
msg_deserialized = deserialize_message(msg_serialized, String) | ||
print(msg_deserialized) | ||
|
||
#message_type = String() | ||
#decoded_data = deserialize_message(serialized_data, String) | ||
#print(decoded_data) | ||
|
||
if __name__ == "__main__": | ||
main() |