Unity-Technologies / ROS-TCP-Connector

Apache License 2.0
296 stars 93 forks source link

publish messages from background threads #293

Open ipa-jsk opened 2 years ago

ipa-jsk commented 2 years ago

The usage of Time.realtimeSinceStartup in RosTopicState.cs allows publishing only from the main thread. Unity throws an error when trying to access Time.realtimeSinceStartup from other threads.

m_LastMessageReceivedRealtime = Time.realtimeSinceStartup;

Possible workarounds could be https://github.com/Unity-Technologies/ROS-TCP-Connector/commit/02c37cb53b4d370cd7dd28e7fe1671563145c0ff m_LastMessageReceivedRealtime = ((float)DateTime.Now.Hour + ((float)DateTime.Now.Minute * 0.01f)); (works somehow, but actually this is not the realtime since startup)