Robotics StackExchange | Archived questions

is this how you use the Bool message type?

is this how you use the Bool message type?

from std_msgs.msg import Bool

p = rospy.Publisher('/dock_led',Bool,queue_size=1)`
c = Bool()
p.publish(c)

I dont see any examples of anyone using it...

thanks!

Asked by Asker Of Questions on 2020-12-24 00:10:24 UTC

Comments

Please see this question.

Asked by skpro19 on 2020-12-24 07:47:13 UTC

Answers

Hi, Bool messages has data field, you can see it by calling dir(c) in your case.

I have checked this scenario in terminal by simpling typing python and then:


import rospy

from std_msgs.msg import Bool

z = Bool()

dir(z) # This outputs the values below

['class', 'delattr', 'doc', 'eq', 'format', 'getattribute', 'getstate', 'hash', 'init', 'module', 'ne', 'new', 'reduce', 'reduce_ex', 'repr', 'setattr', 'setstate', 'sizeof', 'slots', 'str', 'subclasshook', '_check_types', '_connection_header', '_full_text', '_get_types', '_has_header', '_md5sum', '_slot_types', '_type', 'data', 'deserialize', 'deserialize_numpy', 'serialize', 'serialize_numpy']

z.data # This outputs the value of the data

False

z.data = True

p = rospy.Publisher('/asd',Bool,queue_size=1)

rospy.init_node('asdd')

p.publish(z)


Asked by ulashmetalcrush on 2020-12-24 07:35:42 UTC

Comments