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

Unknown message class and not registered to publish topic

Discussion in 'Robotics' started by mbulucay, Jul 13, 2022.

  1. mbulucay

    mbulucay

    Joined:
    Mar 21, 2022
    Posts:
    4
    I am creating two custom ros messages and building them into unity. When I try to publish data these custom messages it is not finding the custom messages and gives me this error;

    SysCommand.subscribe - Unknown message class 'nmea_messages/ais_type123'
    UnityEngine.Debug:LogError (object)
    Unity.Robotics.ROSTCPConnector.ROSConnection:ReceiveSysCommand (string,string) (at Library/PackageCache/com.unity.robotics.ros-tcp-connector@c27f00c6cf/Runtime/TcpConnector/ROSConnection.cs:680)
    Unity.Robotics.ROSTCPConnector.ROSConnection:Update () (at Library/PackageCache/com.unity.robotics.ros-tcp-connector@c27f00c6cf/Runtime/TcpConnector/ROSConnection.cs:587)

    my message class:

    Code (CSharp):
    1. namespace RosMessageTypes.NmeaMessages
    2. {
    3.     [Serializable]
    4.     public class Ais_type123Msg : Message
    5.     {
    6.         public const string k_RosMessageName = "nmea_messages/ais_type123";
    7.         public override string RosMessageName => k_RosMessageName;
    and after gives me this error 3-4 times unity gives me this error:

    Not registered to publish topic 'ais_data_t'! Valid publish topics are: dict_keys([])
    UnityEngine.Debug:LogError (object)
    Unity.Robotics.ROSTCPConnector.ROSConnection:ReceiveSysCommand (string,string) (at Library/PackageCache/com.unity.robotics.ros-tcp-connector@c27f00c6cf/Runtime/TcpConnector/ROSConnection.cs:680)
    Unity.Robotics.ROSTCPConnector.ROSConnection:Update () (at Library/PackageCache/com.unity.robotics.ros-tcp-connector@c27f00c6cf/Runtime/TcpConnector/ROSConnection.cs:587)

    When I look for the solution on the web they have 2 workspace then getting this error but I just have one work spaces.

    How can I solve this issue.
     
    ActiveSim and DwTennant like this.
  2. ActiveSim

    ActiveSim

    Joined:
    May 10, 2019
    Posts:
    59
    Same here: I would like to publish just a few double values. I didn't found a documentation how to generate custom messages (just the predefined ones I found here), so I wrote my own class.

    So the general question is: How does a script look like to generate custom ROS messages? @hyounesy or @LaurieUnity thanks for any help
     
    Last edited: Jul 18, 2022
  3. mbulucay

    mbulucay

    Joined:
    Mar 21, 2022
    Posts:
    4
    In my case, Solved by the forgot to add required a package Ros message package's CmakeList for a custom message. Then rebuilding solve the issue

    Edit: But ros2 for unity need a well expalained documentation
     
  4. ActiveSim

    ActiveSim

    Joined:
    May 10, 2019
    Posts:
    59
    Using the Robotics --> Generate ROS message was working for me as well, with
    • scripting the message files,
    • source them and generate the C# classes with this window and
    • add them to CMakeLists.txt.
    Just be sure to source this files in the you local ROS system as well to read those messages.
     
  5. MartynovMV

    MartynovMV

    Joined:
    Mar 12, 2021
    Posts:
    2
    I have a solution!
    I have this problem when trying to connect to Raspberry Pi. That is, the ROS is installed on another computer. And it is not possible to generate C# msg files from .msg at ros folders.
    I made the same .msg file from .txt file just renaming it and then
    I created a similar path: ros2_ws\src\unity_robotics_demo_msgs\msg\smth.msg
    Then I put it in the folder (Folder\ros2_ws\.....) that I added to "ROS messege path" Robotics --> Generate ROS message.
    And it was generated correctly.
     
  6. MartynovMV

    MartynovMV

    Joined:
    Mar 12, 2021
    Posts:
    2
    Dont forget to delete previous C# msg from Unity project)