EricVoll / ros-sharp

ROS# is a set of open source software libraries and tools in C# for communicating with ROS from .NET applications, in particular Unity3D
Apache License 2.0
36 stars 7 forks source link

Subscription somehow disabled by WinRT API's #22

Open krajFHI opened 1 year ago

krajFHI commented 1 year ago

I have a question!

Here is my question:

Hello,

I am trying to stream Audiodata to the Hololens 2 with a custom message type using the ROS audio_common package. Since using Unity's Audio classes does not lead to my desired quality in processing WAVE data I was trying to make use of the Windows AudioGraph class.

When I use it though, the previous working Subscriber does not subscribe receive data anymore. It does register to the topic over rosbridge but the ReceiveMessage() method is not being executed anymore.

Can you imagine what might be the problem?

Besides the standard ones have the following conditional using statements since using WinRT API's inside the Unity Editor leads to compile errors:

#if ENABLE_WINMD_SUPPORT using Windows.Foundation; using Windows.Media; using Windows.Media.Audio; using Windows.Media.MediaProperties; using Windows.Media.Render; using Windows.Devices.Enumeration; #endif

Also this is the way I try to start the subscriber and initialize the AudioGraph pipeline

namespace RosSharp.RosBridgeClient { public class AudioGraphScript : UnitySubscriber<MessageTypes.AudioCommon.AudioData> { protected override async void Start() { graphInitialized = false; graphReady = false; base.Start(); await CreateAudioGraph(); }

protected override void ReceiveMessage(MessageTypes.AudioCommon.AudioData message) { // Printing in a debug window when method is executed tmpOne.SetText($"Received Data from Publisher Publisher:\n{message.data}"); }

private async Task CreateAudioGraph() { #if ENABLE_WINMD_SUPPORT ... Initialize AudioGraphNodes... #else return; #endif

When I run this in the Unity editor ReceiveMessage() is executed, but when I deploy it on Hololens 2 it is not even once executed even though subscription is registered by rosbridge as I said.

Also I print out to a debug windows the status of the creation of the AudioGraph nodes which returns a success status for every node creation and does not cause errors.

Every help is very much appreciated.

EricVoll commented 1 year ago

Hi @krajFHI

I've never used these classes in ROS messages, but I have the feeling they aren't serializable or the AOT compiler has issues to serialize them. What you can always do is simply replace the message with a byte array, stream it and (de)serialize the object in the different clients.

Alternatively you can checkout the Unity Robotics Hub with their ROS message solution, which handles a few things a bit differently. Maybe that works.

krajFHI commented 1 year ago

Thank you for answering.

Where exactly do you mean should I replace the message with a byte array? The MessageTypes.AudioCommon.AudioData class is a custom class which holds a byte array and when I use it without the AudioGraph classes it works just fine.

When the AOT compiler had issues serializing the AudioGraph classes, then wouldnt it be impossible to receive the success status of the node creation when executing the app on HoloLens 2?