Closed izakisyoutarou closed 5 months ago
Hi,
The ROS 2 spin works in a different thread. Some Unity functions require the main thread to work, therefore you need to pass the data between "other" and "main" threads.
You can do it, for example, with ConcurrentQueue<T>
. Enqueue
the data in the ROS 2 spin thread, and TryDequeue
in the main thread (in Update
or FixedUpdate
).
Thanks for your reply. I was aware that there are different threads that process the code, but I don't know how to handle them, and after looking up how to use ConcurrentQueue
Is your feature request related to a problem? Please describe. A clear and concise description of what the problem is. We thought it would be easier to see the data if the talker and listener display could be reflected in the scene. I have not had any problems using it and thought the user interface could be improved by introducing this feature.
Describe the solution you'd like A clear and concise description of what you want to happen. I want to display data on the scene to make it easier to see the data display.
Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered. Using TextMeshPro to output data to the scene
Additional context Add any other context or screenshots about the feature request here. TalkerExample.cs could output data to the scene. The script looks like this.![image](https://github.com/RobotecAI/ros2-for-unity/assets/106851544/5aa22bbb-e4f4-4ac6-a28a-570ad844b9f6)
It will be displayed in the scene like this.![image](https://github.com/RobotecAI/ros2-for-unity/assets/106851544/13c8ddcd-dd7b-4985-b8f9-3b05b12a1283)
I tried to output ListenerExample.cs in the same way, but an error occurred and it did not work. I wrote the script like this, and I thought I could get there by changing the Debug.Log function, but I got an error.![image](https://github.com/RobotecAI/ros2-for-unity/assets/106851544/6ab76136-a35e-4d93-947f-8988256b23ee)
The error statement is as follows: It seems that the problem is not done in the main thread, but I don't know how to solve it, so I would like to know if you know how to solve this problem.![Screenshot from 2023-09-23 16-22-54](https://github.com/RobotecAI/ros2-for-unity/assets/106851544/6487c7bd-5775-4bcc-b371-2ce2da82424a)
I know this is a long story, but the point is that I want to use TextMeshPro to output to a scene. Thank you in advance for your help. Thank you for reading to the end.