ros-sharp icon indicating copy to clipboard operation
ros-sharp copied to clipboard

Subscription somehow disabled by WinRT API's

Open krajFHI opened this issue 2 years ago • 2 comments

  • [x] I am at the right place and my issue is directly related to ROS#. General technical questions I would post e.g. at ROS Answers or Stack Overflow. For library-specific questions I would look for help in the corresponding library forums.
  • [x] I have thoroughly read the Contributing Guideline and writing this issue is the right thing to do in my case.

I have a question!

  • [x] I searched the Wiki, open and closed issues for an answer. I tried my best to find the answer by myself without success. I believe that the discussion we will have in this issue, and the solutions we might find, will help me, and likely other community members who have a similar problem.

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.

krajFHI avatar Oct 24 '23 15:10 krajFHI

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.

EricVoll avatar Oct 27 '23 11:10 EricVoll

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?

krajFHI avatar Oct 30 '23 14:10 krajFHI