RobotecAI / ros2-for-unity

High-performance ROS2 solution for Unity3D
Apache License 2.0
448 stars 58 forks source link

Generates ROS1 messages with ROS2 setting #36

Closed philipholler closed 2 years ago

philipholler commented 2 years ago

Describe the bug I have created a local custom package with some msgs, srvs, and actions. I sourced it correctly, and it runs fine.

However, when i want to generate .cs files to use inside unity (going to Robotics -> Generate ROS Messages -> Build n msgs) the messages are generated alright, but they seem to be generated for ROS1. This became clear when i tried to use the class as type parameter to the ROS2.ISubscription. I then get the error message "The type 'RosMessageTypes.MyPkg.CustomMsg' must be convertible to 'ROS2.Message'".

I have set the protocol to ROS2 under Robotics -> ROS Settings -> Protocol.

I would expect the generated classes to extend the ROS2.Message class, but instead they extend a Message class from "Unity.Robotics.ROSTCPConnector.MessageGeneration".

Desktop:

adamdbrw commented 2 years ago

I believe that you are referring to a different project altogether. This ros2-for-unity has nothing to do with https://github.com/Unity-Technologies/Unity-Robotics-Hub, it is an independent solution.

With ros2-for-unity, custom messages are built. These are managed+native plugins that actually call ros2 API, not a socket-based bridging solution as in case of Unity Robotics Hub. Thus, you can not generate ros2-for-unity messages from Unity, you do so by building ros2-for-unity with your custom message package (which will involve generation, automatically) - this is as easy as placing your folder in a specific place (refer to the build process README).

Instead of using a release, since you have custom messages, go ahead and build ros2-for-unity on your machine. This is a straightforward process and well described in the README. Let me know if you need any assistance.

You don't need anything else than this repository to work with ros2 using ros2-for-unity.

adamdbrw commented 2 years ago

By the way, we do not support sevices and actions in ros2cs yet - it would be a nice contribution to add these!

adamdbrw commented 2 years ago

@philipholler does my explanation clarify things? Were you able to run your sim with custom messages?

philipholler commented 2 years ago

Yes, it explained a lot, thank you!

Since i need services, i switched to using the Unity Robotics Hub.