How to use multiple RsDevice in Unity to render pointclouds
| Required Info | |
|---|---|
| Camera Model | D415 |
| Camera Firmware | 5.10.3.0 |
| Operating System & Version | Win10 |
| Platform | PC |
| SDK Version | 2.16.0 |
| Language | Unity |
Issue Description
I need to use at least 2 RsDevices to render pointcloiuds in unity. I've tried duplicating the RsDevice object and assigning a different serial number for each one. But still seems the camera initialization does not read the serial number field and takes randomly only one of the connected devices to use the same for both instances. So It is rendering twice the same.
Do I need to build my own custom RsDevice to allow that or is there anything I am doing wrong. It seems there is some comented code on the SDK related to this feature, why is that?
Thanks for the help.
The user frenchtouchXR recently published a method for editing a script in the Unity wrapper to enable multiple devices to be recognized.
https://github.com/IntelRealSense/librealsense/issues/2203#issuecomment-412218681
Yes, this code is already in the Live mode of the SDK, but still the RsDevice acts as a singleton so I can not start more than one device.
That´s the error I get
Exception: RsDevice singleton already instanced RsDevice.Awake () (at Assets/RealSenseSDK2.0/Scripts/RsDevice.cs:85)
My apologies, I see now that you already commented about your detection issue immediately after frenchtochXR's comment in that linked-to post.
What firmware driver version are your cameras currently using please? Updating to the latest firmware can sometimes help to reduce or resolve problems.
https://downloadcenter.intel.com/download/28076/Latest-Firmware-for-Intel-RealSense-D400-Product-Family?v=t
Thanks for the quick reply. I am using latest firmware 5.10.3.0 And the same problem is there at least from sdk version 2.14
The problem is in the RsDevice class from the SDK as it is checking another instance is running when it awakes.
void Awake() { if (Instance != null && Instance != this) throw new Exception(string.Format("{0} singleton already instanced", this.GetType())); Instance = this; }
Any idea how to solve it?
Would it be possible to check whether you have the problem in SDK version 2.15.0 (the previous one)?
Same problem is there at least from sdk version 2.14 RsDevice is a Singleton
Thanks. I asked about trying an earlier version because I had a case yesterday over at the Intel Support site where a user had problems using two D415s where only one of them would work properly, but their project worked fine when three cameras were connected. They wanted to use multi-streaming in Untiy too.
https://communities.intel.com/message/563718#563718
This is likely an issue that one of the Intel development staff on this forum such as Dorodnic or RealSense-Customer-Engineering can answer, unfortunately.
Edit: I see frenchtouchXR was using 3 cameras too (D435s).

Heya. The problem comes from the rsdevice class is static. You need to make it public only and correct all the errors. Then use the s/n and create new shaders. I published this method a couple of weeks ago as an answer to an issue.
Thanks so much for your help on this case! :)
I published this method a couple of weeks ago as an answer to an issue.
@frenchtouchXR could you send me the link to this publication? thanks
Hi,
I've turned back to unity test to give it another try. And I'm still facing the same problem when trying to stream multiple D415 to Unity. "RSDevice Singleton already instanced..." Using the latest SDK/Unitypackage and latest Unity version this should be solved...I was assuming. I have no clue what I'm doing wrong here. I just add 2 devices with pointcloud to unity. One is working but two cause the error. devide is set to public (static button deactivated in unity) Well, I guess this issue remains since MAY?

Heya. The problem comes from the rsdevice class is static. You need to make it public only and correct all the errors. Then use the s/n and create new shaders. I published this method a couple of weeks ago as an answer to an issue.
@frenchtouchXR Do you happen to still have a link to this method you published ? I am interested in it, since I am facing multi-cam issues in Unity as well.
It is probably this link:
https://github.com/IntelRealSense/librealsense/issues/2203#issuecomment-412218681
That link doesn't have all of the information about how to do it, and a lot of the links off of that link are broken (it looks like Intel changed its Forum format).
@frenchtouchXR (or anyone else): do you have the code you used to address the issue? I made RsDevice non-static, which introduced a bunch of errors, many in other files that now need an instance to reference. There's also a CustomProcessingBlock reference which apparently can take a static variable but not an instanced one. I could probably puzzle all of this out, but I'm not an expert C# programmer and I don't have a lot of time, so if someone has figured all this out and can send me the source files, I would appreciate it.