Unknown message class and not registered to publish topic

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:

namespace RosMessageTypes.NmeaMessages
{
    [Serializable]
    public class Ais_type123Msg : Message
    {
        public const string k_RosMessageName = "nmea_messages/ais_type123";
        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.

2 Likes

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

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

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.

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.

Dont forget to delete previous C# msg from Unity project)