Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice
  2. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  3. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Confused With Message Paths

Discussion in 'Robotics' started by boogie_muffins, Feb 2, 2023.

  1. boogie_muffins


    Oct 17, 2022
    Hi, I am new to Unity and ROS2 and I am developing a teleop controller on a HoloLens 2 headset for a school project and looking for some guidance/help. I'll start off by saying I am developing my Unity app on a PC running windows 11 and developing my ROS2 functionality on a RPi4 with the ROS2 foxy distribution. When I am creating my C# pub/sub script to attach to a game object in Unity, I see that people are using using "using RosMessageTypes.<msg_type>" in their scripts to gain access to available message types. As a result, I have a few questions:
    1. Where/What path are these coming from?
    2. Do I need to install anything on my Windows PC to access these message types?
    3. If I were to use custom messages in ROS2 on the Pi, how would I create them on the Unity side to publish/subscribe to?
    4. What documentation can I find to see which message types I have access to on the Unity side of things
    Thanks for any and all help with this matter as it would be greatly appreciated!!!
  2. SF_FrankvHoof


    Apr 1, 2022
    boogie_muffins likes this.
  3. Envilon


    Aug 8, 2020
    Hi! I'll try to answer this for you. The messages are generated by Unity itself. Part of the ROS-TCP-Connector is also an automatic message generator. This is similar to what you are doing in ROS2. You define your custom interfaces in your package as
    , or
    files, and during the build, you use the
    package to generate code for your interfaces in Python/C++. After that, you can use them in your code when developing your ROS applications. If you want to use your messages in your C# code in Unity, you have to go through the same process - using the message generation provided by Unity.

    In your editor, go to Robotics->Generate ROS Messages..., which will open the ROS Message Browser.


    Here, you'll want to navigate to your message definitions on your file system (ROS message path), and the utility will find and display all your interfaces found on that path. From the list, you can build any of your interfaces. This will automatically generate a C# code for a given interface and place it inside your Assets folder under the relative Build message path. You have to generate the C# code for any interface you wish to use in your project's code.
    For the example above, it would create these files in my project:


    To summarize, I'll answer your specific questions:

    1. The C# code generated for the ROS interfaces is inside your project. You can import any interfaces through the process described above and the code will be placed inside your Assets folder. However, some standard messages are already part of the ROS-TCP-Connector package and you'll find them in your packages folder:
    2. No, you just need the ROS-TCP-Connector package installed in your Unity project.
    3. Copy them from your Pi somewhere on your Windows machine and generate C# code for them using the process above.
    4. See the ROS-TCP-Connector package folder inside your project. I'm unaware of any documentation listing these messages.
    Also, check

    Note: I'm not sure, but I think only messages and services are supported. No action interfaces.
    boogie_muffins likes this.
  4. boogie_muffins


    Oct 17, 2022
    WOW thank you so much, @Envilon ... This is all so incredibly helpful!!!!!! Can't thank you enough for taking the time to explain this!!!