- 
                Notifications
    
You must be signed in to change notification settings  - Fork 392
 
Description
Hi!
Earlier I had some thoughts about ROS - Unity communication performance (see #55), and I've now done some more testing and want to share the results. I also have some concerns about one test which I'd like some feedback on if possible.
Scripts
I am appending the scripts used in this issue: 2 C# Unity scripts using ROS#, 1 C++ and 1 CMakeLists.txt file to create a ROS package.
C#/Unity
Files: unity.zip
SimplifiedPublisher- Publishes a string. The publication can be set to occur either every time FixedUpdate is called; or to be related to a call to a trigger method. If the PublicationType enum is set toFixedUpdateTrigger, the trigger method will make sure the message is published the next time a FixedUpdate callback is called. If it is set to FastTrigger, the message will be published immediately.SimplifiedPublishSubscriber- Calls the trigger method of theSimplifiedPublisherscript when a string message is received.
C++/ROS
Files: ros.zip
listen_and_talk.cpp- ROS node that subscribes to the/unity_talkertopic, and publishes "ros" to the/ros_talkertopic each time a message is received.CMakeLists.txt- CMakeLists
To compile into a ROS node (execute at the top level of a Catkin workspace):
cd src
catkin_create_pkg unity_listener std_msgs roscpp
cp [path to unity_listener.cpp] unity_listener/src
cp [path to CMakeLists.txt] unity_listener
cd ..
catkin_make
and run using
rosrun unity_listener unity_listener
Tests
I think all of these tests should be simple to reproduce using the scripts provided above. All test cases use a Unity scene with a single GameObject, which is described under each subsection. Test cases 2 and 3 also uses the ROS node provided.
All frequencies have been measured using the ROS command:
rostopic hz /topic_name
Test case 1: One-way communication
Unity scene
RosConnector GameObject with the following components
RosConnectorSimplifiedPublisherpublishing the string "unity" to the/unity_talkertopic. Configured to use the FixedUpdate publication type.
Results
I ramped down the time step using Edit -> Project Settings -> Time, and the maximum stable frequency achieved was about 4000 Hz.
Test case 2: Two-way communication outside of FixedUpdate
Unity scene
RosConnector GameObject with the following components
RosConnectorSimplifiedPublishSubscribersubscribed to the/ros_talkertopic.SimplifiedPublisherpublishing the string "unity" to the/unity_talkertopic. Configured to use the FastTrigger publication type.
ROS node
Uses the unity_listener node described under the Scripts section.
Notes
You might have to start the communication by manually sending a message to either topic, using for example:
rostopic pub /unity_talker std_msgs/String "data: 'xxx'" --once
Results
The frequency lies around 1000 Hz.
Test case 3: Two-way communication using FixedUpdate
Unity scene
Same as Test case 2, but with the SimplifiedPublisher configured to use the FixedUpdateTrigger publication type.
ROS node
See Test case 2.
Results
The frequency never goes above 60 hz, even when the time step is ramped down. Setting a time step above 1/60 makes the frequency go down accordingly.
Analysis
Test case 1 shows that FixedUpdate is able to publish at an approximate rate of about 4000 messages/second. Test case 2 shows that it is possible to communicate between ROS and ROS# at a rate of about 1000 message/second. Therefore I do not understand why the results look like they do for Test case 3. I also tried to alter the SimplifiedPublisher script to publish to a second topic during Test case 3, and it was able to publish at a rate similar to Test case 1. Do you have any thoughts on this, or if there are other test cases I can make to shed some light?


