Reading a string from a node
def callback(data):
w = data.String()
brush_msg = UInt16()
motor_msg = UInt16()
if w=="frontwall":
motor_msg.data=int(70)
pub_motor0.publish(motor_msg)
if w == "backwall":
motor_msg.data = int(71)
pub_motor0.publish(motor_msg)
if w == "nowall":
motor_msg.data = int(72)
pub_motor0.publish(motor_msg)
if __name__ == '__main__':
rospy.init_node('auto_control', anonymous=True)
rospy.Subscriber("/waller", String, callback)
rospy.spin()
When I run this script this message appears on console: w = data.String() AttributeError: 'String' object has no attribute 'String'
https://answers.ros.org/question/2781...
PeteBlacker solved the issue I had with regards the constant publishing and my missunderstanding of the issue. I'm trying to update the same script to publish the message in function of some string data published by an arduino by rosserial in the node "waller".
edit: Oh shit and I tried data.waller and waller.String and such... Same msg.