ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
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

Question Tools

2 followers

Stats

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

Seen: 315 times

Last updated: Feb 15 '21