Unity-Technologies / ROS-TCP-Endpoint

ROS package used to create an endpoint to accept ROS messages sent from a Unity scene using the ROS TCP Connector scripts
Apache License 2.0
189 stars 127 forks source link

implement ROS-TCP-ENDPOINT with C++ #172

Open ketewang opened 8 months ago

ketewang commented 8 months ago

I'm trying to rewrite this module with C++ as this python project runs with high and unsteady cpu resource. have you ever considered this thought before? It looks like I'm facing the problem of dynamically deserialize ros2 msg or srv class. Any good suggestion for this? thanks.

sebastieninria commented 2 months ago

I just made a C++ implementation of the Endpoint for ROS2. I plan to make it available quite soon, as soon as i've cleaned the code. It's currently written for Windows but would be easily ported to any Posix system just by replacing the WinSocks with standard sockets.

ketewang commented 2 months ago

I have finished using C++ to rewrite the endpoint in April, and it works with extremely low cpu usage like 1% in C++ while 60% in python running the same demon code. I also conducted a pressure test running 200 topics with 1 publisher and 1 subscriber for each topic, publish frequency is about 100Hz. The CPU usage is about 6%(16 cores).

Hydran00 commented 1 month ago

Hi @ketewang, would you mind making the C++ code open source? Using the python endpoint with high bandwidth topics (like point clouds or FHD images) is not feasible, I would be happy to contribute to the C++ version.

sebastieninria commented 1 month ago

For anyone who may need it, our C++ implementation of the ROS-TCP-Endpoint node is available here : https://github.com/IH2A/ROS-TCP-Endpoint/blob/ros2-cpp/README_CPP.md It's a fork of this repository in which i added a ros2-cpp branch which contains the C++ implementation based on the main-ros2 branch. As i said, it's written for Windows systems because of the WinSock2 socket library, but it shall be quite easily ported to any Posix system without many changes since the socket paradigm is the same as Berkeley sockets.

For the tests i've made so far, it shows improved performances and much better stability than the python version. Publishers, Subscribers, ROS services and Unity services are available.