Ask Your Question
0

Are ROS messages classes with slots?

asked 2021-02-15 02:56:16 -0500

Kansai gravatar image

I am trying to understand some python code dealing with ROS messages and I have a Subscriber Callback method where

 def thecallback(self, msg):
     # some code here involving a variable k
     if(k in msg.__slots__):
        #some other code

What does this mean?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2021-02-15 06:16:53 -0500

mgruhler gravatar image

updated 2021-02-15 06:17:25 -0500

Well, yes: ROS messages are (more precisely, are compiled into) classes, and in Python they do have a __slots__ member, if this is what you are asking.

The __slots__ member basically contains the fields from the message definition. See also the wiki.

Basically, the code you have checks if the message contains the field described by the variable k. The std_msgs/Float32Multiarray message has the slots layout and data, for example.

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: 2021-02-15 02:56:16 -0500

Seen: 57 times

Last updated: Feb 15