Should I define ROS2Message msg type? #739
-
|
I am applying RAI to my ROS robotic arm. This means this part needs a /panda_state topic in the shape of ROS2Message. However, when I use connector.send_message method, it required me a message type so I tried to use ROS2Message type. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 7 replies
-
|
Hi, thank you for your interest in rai. ROS2Message is a python class (not a ROS2 message) which allows transferring all sorts of ROS2 messages in similar API. To use it (e.g., send message) please pass it to the method with payload={} dict of your message. For example: connector.send_message(ROS2Message(payload={"data": "Hello from RAI", ...))The additional required arguments of send message are target (topic name) and msg_type e.g., "std_msgs/msg/String". Not every part of the api requires explicit message type- receive_message does not need this. |
Beta Was this translation helpful? Give feedback.
-
|
Hi @kumaemon0903, we're glad to hear that resolved your issue! 🎉. From the code snippet in your first message, it looks like you were following this walkthrough: https://robotecai.github.io/rai/tutorials/walkthrough. If that's correct, I'd love to hear your thoughts on it. For example, what parts did you find straightforward, and were there any areas that could use some improvement? If you have the time and feel inclined, it would be wonderful if you could capture any improvement ideas in a GitHub issue. And if you're interested in contributing directly, make a PR. I also noticed you're working on running RAI with your ROS robotic arm—that sounds exciting! If you're open to it, I'd love to see updates on your progress in the RAI Discord channel: https://discord.com/channels/1309212732578336808/1309212732578336813. The community would really enjoy following along 😊! |
Beta Was this translation helpful? Give feedback.
Correct, the msg_type needs to be a valid ROS 2 message type. In your case, you would need to define a custom type with a status field. Find more info in ROS 2 tutorial https://docs.ros.org/en/jazzy/Tutorials/Beginner-Client-Libraries/Custom-ROS2-Interfaces.html. Cheers!