Ask Your Question
0

How to know how to import a message ?

asked 2020-12-12 09:47:30 -0500

Nbb gravatar image

This line of code imports the Int32 message for use in ros from std_msgs.msg import Int32For someone who is completely new, how am I supposed to know what to type to import the Int32 message? This is all I could find regarding the Int32 message http://docs.ros.org/en/api/std_msgs/h... where does it say that I must type std_msgs.msg import Int32 ?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2020-12-12 20:14:29 -0500

jayess gravatar image

This is essentially right out of the ROS Python tutorial on writing a publisher and subscriber. That's the pattern that std_msgs uses. If you look in the std_msgs GitHub repo you'll see that message definitions are in the msg subdirectory. Since the package is called std_msgs and the definition is in the msg subdirectory you can use

from std_msgs.msg import Int32

For other packages you'd look at their documentation or their source code if there's no documentation.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2020-12-12 09:47:30 -0500

Seen: 19 times

Last updated: Dec 12 '20