Closed flymaxty closed 3 years ago
Hi @flymaxty !
all your custom messages seem to work fine. The error above is thrown in line 31 of the UnityPublisher
base class:
publicationId = rosConnector.RosSocket.Advertise<T>(Topic);
where rosConnector
is null. It should have been assigned to a non-null value directly above in line 30.
Did you put your HeadController
Component in the same GameObject where your RosConnector
is in?
I don't understand why this error happens on PC Standalone build only. Do you have any other scripts that might disable or remove your RosConnector? Make sure that all required runtime scripts are included in the build, e.g. dont' put them in folders named Editor
.
This might help you debugging: https://assetstore.unity.com/packages/tools/integration/log-viewer-12047 (I didn't test it myself yet, though.)
Best, Martin
Hi @MartinBischoff , Thanks for your reply!
Did you put your HeadController Component in the same GameObject where your RosConnector is in? Yes
Do you have any other scripts that might disable or remove your RosConnector? No, but has multiple rosconnector in different GameObject
Make sure that all required runtime scripts are included in the build, e.g. dont' put them in folders named Editor. Yes, I'm sure.
There are also other subscribers in differect GameObject, receiving image and joint_states. All subscriber works well, except this one, which publish message to ROS.
I also tried to rebuild the Libraries on my PC, replace RosBridgeClient.dll, and the result is same.
Hi @flymaxty
a RosConnector is intended to be used once per scene with all Publishers and Subscribers located in the same GameObject. Why are you using several RosConnectors? Each of them sets up a separate Websocket connection. Does your build work when you disable all but one?
A RosConnector creates a new thread to communicate with ROS asynchronously to Unity's (fixed) update processes. Depending on your machine and cpu load, another reason for above error might be that the thread is not initialized in time. Nevertheless the RosConnector should be non-null?! Can you Debug.Log the relevant objects RosConnector, RosSocket to clarify what is null when it should not be?
Hi @flymaxty did my suggestions help? Please close this issue if it is resolved.
Hi @MartinBischoff , Sorry for the late reply, I was in a hard time to catch up with the project schedule, and forgot this issue after everythings done.
I recreate a new unity project and follow your suggest to create only one RosConnector per scene, and the issue was solved.
I'm not sure which is the key reason, but yes, I use RosConnector in wrong way.
I'll close this issue and thanks for your help!
I have a question!
Here is my question:
I'm trying to use
Auto Generate Messages
to generate custom messages. It works well when I run in Unity withPlay
button.But when I build a PC Standalone Application, it returns the following error:
It seems that did not find a ros connector, but I don't know why.
Here's my code
I'm using Unity 2019.4.13f1c1 with steamvr and latest ros_sharp from repo.