mehmetkillioglu / ros2_message_converter

Ros2_message_converter is a lightweight ROS2 package and Python library to convert from Python dictionaries and JSON messages to rclpy messages, and vice versa
BSD 3-Clause "New" or "Revised" License
11 stars 7 forks source link

Found built-in conversion to and from dict in rosidl_runtime_py #8

Closed Interpause closed 2 years ago

Interpause commented 2 years ago

I discovered functionality for conversion to and between Python dictionaries (& consequently JSON) seem to be present in rosidl_runtime_py:

https://github.com/ros2/rosidl_runtime_py/blob/1979f566c3b446ddbc5c3fb6896e1f03ccbc6a27/rosidl_runtime_py/set_message.py#L28-L37

https://github.com/ros2/rosidl_runtime_py/blob/1979f566c3b446ddbc5c3fb6896e1f03ccbc6a27/rosidl_runtime_py/convert.py#L159-L176

Hence, in ROS2, it seems possible to convert messages without a separate package for it.

mehmetkillioglu commented 2 years ago

Thank you for the comment. The main purpose of this package was to work with MiR100 mobile robots. It has a websocket bridge for transferring messages from the internal computer in order to expose it to other onboard-computers. But, the messages coming as json from MiR100 internal ROS is with ROS1. Therefore, there are changes between the data format.

So main purpose of this was to receive ROS1 json msgs, and transform them into ROS2 msgs. It can also be used for the ROS2 json msgs of course, but some additional conditions added if the json format is in ROS1 format.

For instance, the time coming from the ROS1 has fields nsecs and secs, though in ROS2, they are defined as nanosec and sec.

I last worked with this package nearly two years ago. So, I am not sure what is the latest format the MiR uses, or @mintar from uos/rospy_message_converter has any plans on the ROS2 support.

mintar commented 2 years ago

Yes, I'm working on the ROS2 support in my repo and will release it next month!

Interpause commented 2 years ago

Thank you for the comment. The main purpose of this package was to work with MiR100 mobile robots. It has a websocket bridge for transferring messages from the internal computer in order to expose it to other onboard-computers. But, the messages coming as json from MiR100 internal ROS is with ROS1. Therefore, there are changes between the data format.

So main purpose of this was to receive ROS1 json msgs, and transform them into ROS2 msgs. It can also be used for the ROS2 json msgs of course, but some additional conditions added if the json format is in ROS1 format.

For instance, the time coming from the ROS1 has fields nsecs and secs, though in ROS2, they are defined as nanosec and sec.

I last worked with this package nearly two years ago. So, I am not sure what is the latest format the MiR uses, or @mintar from uos/rospy_message_converter has any plans on the ROS2 support.

I see, I didn't consider such a use case. I see how that could be useful.

mintar commented 2 years ago

I have just finished converting uos/rospy_message_converter to ROS2 and released it (as rclpy_message_converter) to ROS2 foxy, galactic, humble and rolling. It should be available as binary package after the next sync.