ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

is this how you use the Bool message type?

asked 2020-12-23 23:10:24 -0500

Asker Of Questions gravatar image

updated 2020-12-24 06:43:57 -0500

gvdhoorn gravatar image

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!

edit retag flag offensive close merge delete

Comments

Please see this question.

skpro19 gravatar image skpro19  ( 2020-12-24 06:47:13 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2020-12-24 06:35:42 -0500

ulashmetalcrush gravatar image

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)


edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2020-12-23 23:10:24 -0500

Seen: 6,970 times

Last updated: Dec 24 '20